Fix e2e tests in parallel

This commit is contained in:
Chocobozzz 2019-06-18 10:20:55 +02:00
parent e379f813d4
commit bbe078ba55
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 64 additions and 58 deletions

View File

@ -18,25 +18,30 @@ exports.config = {
multiCapabilities: [ multiCapabilities: [
{ {
browserName: 'Chrome', browserName: 'Chrome',
name: 'Latest Chrome Desktop' name: 'Latest Chrome Desktop',
resolution: '1280x1024'
}, },
{ {
browserName: 'Safari', browserName: 'Safari',
version: '11.1', version: '11.1',
name: 'Safari Desktop' name: 'Safari Desktop',
resolution: '1280x1024'
}, },
{ {
browserName: 'Firefox', browserName: 'Firefox',
version: '60', // ESR, version: '60', // ESR,
name: 'Firefox ESR Desktop' name: 'Firefox ESR Desktop',
resolution: '1280x1024'
}, },
{ {
browserName: 'Firefox', browserName: 'Firefox',
name: 'Latest Firefox Desktop' name: 'Latest Firefox Desktop',
resolution: '1280x1024'
}, },
{ {
browserName: 'Edge', browserName: 'Edge',
name: 'Latest Edge Desktop' name: 'Latest Edge Desktop',
resolution: '1280x1024'
}, },
{ {
browserName: 'Chrome', browserName: 'Chrome',

View File

@ -16,34 +16,32 @@ export class MyAccountPage {
// My account Videos // My account Videos
getLastVideoName () { removeVideo (name: string) {
return this.getAllVideoNameElements().first().getText() return this.getVideoElement(name).element(by.css('my-delete-button')).click()
}
removeLastVideo () {
return this.getLastVideoElement().element(by.css('my-delete-button')).click()
} }
validRemove () { validRemove () {
return element(by.css('.action-button-submit')).click() return element(by.css('.action-button-submit')).click()
} }
countVideos () { countVideos (names: string[]) {
return this.getAllVideoNameElements().count() return element.all(by.css('.video'))
.filter(e => {
return e.element(by.css('.video-miniature-name'))
.getText()
.then(t => names.some(n => t.includes(n)))
})
.count()
} }
// My account playlists // My account playlists
getLastUpdatedPlaylistName () { getPlaylistVideosText (name: string) {
return this.getLastUpdatedPlaylist().element(by.css('.miniature-name')).getText() return this.getPlaylist(name).element(by.css('.miniature-playlist-info-overlay')).getText()
} }
getLastUpdatedPlaylistVideosText () { clickOnPlaylist (name: string) {
return this.getLastUpdatedPlaylist().element(by.css('.miniature-playlist-info-overlay')).getText() return this.getPlaylist(name).element(by.css('.miniature-thumbnail')).click()
}
clickOnLastUpdatedPlaylist () {
return this.getLastUpdatedPlaylist().element(by.css('.miniature-thumbnail')).click()
} }
countTotalPlaylistElements () { countTotalPlaylistElements () {
@ -56,17 +54,17 @@ export class MyAccountPage {
// My account Videos // My account Videos
private getLastVideoElement () { private getVideoElement (name: string) {
return element.all(by.css('.video')).first() return element.all(by.css('.video'))
} .filter(e => e.element(by.css('.video-miniature-name')).getText().then(t => t.includes(name)))
.first()
private getAllVideoNameElements () {
return element.all(by.css('.video-miniature-name'))
} }
// My account playlists // My account playlists
private getLastUpdatedPlaylist () { private getPlaylist (name: string) {
return element.all(by.css('my-video-playlist-miniature')).first() return element.all(by.css('my-video-playlist-miniature'))
.filter(e => e.element(by.css('.miniature-name')).getText().then(t => t.includes(name)))
.first()
} }
} }

View File

@ -126,8 +126,18 @@ export class VideoWatchPage {
return element(by.css('.action-button-save')).click() return element(by.css('.action-button-save')).click()
} }
async saveToWatchLater () { async createPlaylist (name: string) {
return element.all(by.css('my-video-add-to-playlist .playlist')).first().click() await element(by.css('.new-playlist-button')).click()
await element(by.css('#displayName')).sendKeys(name)
return element(by.css('.new-playlist-block input[type=submit]')).click()
}
async saveToPlaylist (name: string) {
return element.all(by.css('my-video-add-to-playlist .playlist'))
.filter(p => p.getText().then(t => t === name))
.click()
} }
waitUntilVideoName (name: string, maxTime: number) { waitUntilVideoName (name: string, maxTime: number) {

View File

@ -31,7 +31,9 @@ describe('Videos workflow', () => {
let myAccountPage: MyAccountPage let myAccountPage: MyAccountPage
let loginPage: LoginPage let loginPage: LoginPage
const videoName = new Date().getTime() + ' video' let videoName = new Date().getTime() + ' video'
const video2Name = new Date().getTime() + ' second video'
const playlistName = new Date().getTime() + ' playlist'
let videoWatchUrl: string let videoWatchUrl: string
beforeEach(async () => { beforeEach(async () => {
@ -122,41 +124,42 @@ describe('Videos workflow', () => {
await videoWatchPage.clickOnUpdate() await videoWatchPage.clickOnUpdate()
await videoUpdatePage.updateName('my new name') videoName += ' updated'
await videoUpdatePage.updateName(videoName)
await videoUpdatePage.validUpdate() await videoUpdatePage.validUpdate()
const name = await videoWatchPage.getVideoName() const name = await videoWatchPage.getVideoName()
expect(name).toEqual('my new name') expect(name).toEqual(videoName)
}) })
it('Should add the video in my playlist', async () => { it('Should add the video in my playlist', async () => {
if (await skipIfUploadNotSupported()) return if (await skipIfUploadNotSupported()) return
await videoWatchPage.clickOnSave() await videoWatchPage.clickOnSave()
await videoWatchPage.saveToWatchLater()
await videoWatchPage.createPlaylist(playlistName)
await videoWatchPage.saveToPlaylist(playlistName)
await videoUploadPage.navigateTo() await videoUploadPage.navigateTo()
await videoUploadPage.uploadVideo() await videoUploadPage.uploadVideo()
await videoUploadPage.validSecondUploadStep('second video') await videoUploadPage.validSecondUploadStep(video2Name)
await videoWatchPage.clickOnSave() await videoWatchPage.clickOnSave()
await videoWatchPage.saveToWatchLater() await videoWatchPage.saveToPlaylist(playlistName)
}) })
it('Should have the watch later playlist in my account', async () => { it('Should have the playlist in my account', async () => {
if (await skipIfUploadNotSupported()) return if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyPlaylists() await myAccountPage.navigateToMyPlaylists()
const name = await myAccountPage.getLastUpdatedPlaylistName() const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
expect(name).toEqual('Watch later')
const videosNumberText = await myAccountPage.getLastUpdatedPlaylistVideosText()
expect(videosNumberText).toEqual('2 videos') expect(videosNumberText).toEqual('2 videos')
await myAccountPage.clickOnLastUpdatedPlaylist() await myAccountPage.clickOnPlaylist(playlistName)
const count = await myAccountPage.countTotalPlaylistElements() const count = await myAccountPage.countTotalPlaylistElements()
expect(count).toEqual(2) expect(count).toEqual(2)
@ -167,35 +170,25 @@ describe('Videos workflow', () => {
await myAccountPage.playPlaylist() await myAccountPage.playPlaylist()
await videoWatchPage.waitUntilVideoName('second video', 20000 * 1000) await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
}) })
it('Should have the video in my account', async () => { it('Should delete the video 2', async () => {
if (await skipIfUploadNotSupported()) return if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyVideos() await myAccountPage.navigateToMyVideos()
const lastVideoName = await myAccountPage.getLastVideoName() await myAccountPage.removeVideo(video2Name)
expect(lastVideoName).toEqual('second video')
})
it('Should delete the last video', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.removeLastVideo()
await myAccountPage.validRemove() await myAccountPage.validRemove()
const count = await myAccountPage.countVideos() const count = await myAccountPage.countVideos([ videoName, video2Name ])
expect(count).toEqual(1) expect(count).toEqual(1)
}) })
it('Should delete the first video', async () => { it('Should delete the first video', async () => {
if (await skipIfUploadNotSupported()) return if (await skipIfUploadNotSupported()) return
await myAccountPage.removeLastVideo() await myAccountPage.removeVideo(videoName)
await myAccountPage.validRemove() await myAccountPage.validRemove()
const count = await myAccountPage.countVideos()
expect(count).toEqual(0)
}) })
}) })