2018-05-17 04:55:01 -04:00
|
|
|
import { browser } from 'protractor'
|
2020-01-23 08:23:19 -05:00
|
|
|
import { AppPage } from './po/app.po'
|
2020-05-12 10:38:55 -04:00
|
|
|
import { LoginPage } from './po/login.po'
|
|
|
|
import { MyAccountPage } from './po/my-account'
|
|
|
|
import { VideoUpdatePage } from './po/video-update.po'
|
|
|
|
import { VideoUploadPage } from './po/video-upload.po'
|
|
|
|
import { VideoWatchPage } from './po/video-watch.po'
|
|
|
|
import { isIOS, isMobileDevice, isSafari } from './utils'
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
async function skipIfUploadNotSupported () {
|
|
|
|
if (await isMobileDevice() || await isSafari()) {
|
|
|
|
console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-05-17 04:55:01 -04:00
|
|
|
describe('Videos workflow', () => {
|
|
|
|
let videoWatchPage: VideoWatchPage
|
2019-06-17 02:11:25 -04:00
|
|
|
let videoUploadPage: VideoUploadPage
|
|
|
|
let videoUpdatePage: VideoUpdatePage
|
|
|
|
let myAccountPage: MyAccountPage
|
2018-05-17 04:55:01 -04:00
|
|
|
let loginPage: LoginPage
|
2020-01-23 08:23:19 -05:00
|
|
|
let appPage: AppPage
|
2019-06-17 02:11:25 -04:00
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
let videoName = new Date().getTime() + ' video'
|
|
|
|
const video2Name = new Date().getTime() + ' second video'
|
|
|
|
const playlistName = new Date().getTime() + ' playlist'
|
2019-06-17 02:11:25 -04:00
|
|
|
let videoWatchUrl: string
|
2018-05-19 07:58:29 -04:00
|
|
|
|
|
|
|
beforeEach(async () => {
|
2018-05-17 04:55:01 -04:00
|
|
|
videoWatchPage = new VideoWatchPage()
|
2019-06-17 02:11:25 -04:00
|
|
|
videoUploadPage = new VideoUploadPage()
|
|
|
|
videoUpdatePage = new VideoUpdatePage()
|
|
|
|
myAccountPage = new MyAccountPage()
|
2018-05-17 04:55:01 -04:00
|
|
|
loginPage = new LoginPage()
|
2020-01-23 08:23:19 -05:00
|
|
|
appPage = new AppPage()
|
2018-05-19 07:58:29 -04:00
|
|
|
|
2020-05-12 10:38:55 -04:00
|
|
|
if (await isIOS()) {
|
|
|
|
// iOS does not seem to work with protractor
|
|
|
|
// https://github.com/angular/protractor/issues/2840
|
|
|
|
browser.ignoreSynchronization = true
|
2019-02-21 05:24:07 -05:00
|
|
|
|
2020-05-12 10:38:55 -04:00
|
|
|
console.log('iOS detected')
|
|
|
|
} else if (await isMobileDevice()) {
|
|
|
|
console.log('Android detected.')
|
|
|
|
} else if (await isSafari()) {
|
2019-02-21 05:24:07 -05:00
|
|
|
console.log('Safari detected.')
|
|
|
|
}
|
2020-05-11 03:41:39 -04:00
|
|
|
|
|
|
|
if (!await isMobileDevice()) {
|
|
|
|
await browser.driver.manage().window().maximize()
|
|
|
|
}
|
2018-05-17 04:55:01 -04:00
|
|
|
})
|
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
it('Should log in', async () => {
|
|
|
|
if (await isMobileDevice() || await isSafari()) {
|
2018-05-24 03:05:58 -04:00
|
|
|
console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
|
2018-05-19 07:58:29 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-05-17 04:55:01 -04:00
|
|
|
return loginPage.loginAsRootUser()
|
|
|
|
})
|
|
|
|
|
2020-01-23 08:23:19 -05:00
|
|
|
it('Should close the welcome modal', async () => {
|
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await appPage.closeWelcomeModal()
|
|
|
|
})
|
|
|
|
|
2018-05-17 04:55:01 -04:00
|
|
|
it('Should upload a video', async () => {
|
2019-06-17 02:11:25 -04:00
|
|
|
if (await skipIfUploadNotSupported()) return
|
2018-05-19 07:58:29 -04:00
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
await videoUploadPage.navigateTo()
|
2018-05-17 04:55:01 -04:00
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
await videoUploadPage.uploadVideo()
|
|
|
|
return videoUploadPage.validSecondUploadStep(videoName)
|
2018-05-17 04:55:01 -04:00
|
|
|
})
|
|
|
|
|
2019-05-14 07:59:10 -04:00
|
|
|
it('Should list videos', async () => {
|
2019-06-17 02:11:25 -04:00
|
|
|
await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari())
|
2018-05-19 07:58:29 -04:00
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
if (await skipIfUploadNotSupported()) return
|
2018-05-17 04:55:01 -04:00
|
|
|
|
|
|
|
const videoNames = videoWatchPage.getVideosListName()
|
|
|
|
expect(videoNames).toContain(videoName)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should go on video watch page', async () => {
|
2018-05-19 07:58:29 -04:00
|
|
|
let videoNameToExcept = videoName
|
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
if (await isMobileDevice() || await isSafari()) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
|
2018-05-19 07:58:29 -04:00
|
|
|
else await videoWatchPage.clickOnVideo(videoName)
|
2018-05-17 04:55:01 -04:00
|
|
|
|
2019-06-17 02:11:25 -04:00
|
|
|
return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari())
|
2018-05-17 04:55:01 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should play the video', async () => {
|
2019-06-17 02:11:25 -04:00
|
|
|
videoWatchUrl = await browser.getCurrentUrl()
|
|
|
|
|
2020-05-13 04:15:31 -04:00
|
|
|
await videoWatchPage.playAndPauseVideo(true)
|
2018-05-22 10:02:29 -04:00
|
|
|
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should watch the associated embed video', async () => {
|
2019-02-21 05:24:07 -05:00
|
|
|
await browser.waitForAngularEnabled(false)
|
|
|
|
|
2018-05-22 10:02:29 -04:00
|
|
|
await videoWatchPage.goOnAssociatedEmbed()
|
|
|
|
|
2020-05-13 04:15:31 -04:00
|
|
|
await videoWatchPage.playAndPauseVideo(false)
|
2018-05-17 04:55:01 -04:00
|
|
|
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
2019-02-21 05:24:07 -05:00
|
|
|
|
|
|
|
await browser.waitForAngularEnabled(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should watch the p2p media loader embed video', async () => {
|
|
|
|
await browser.waitForAngularEnabled(false)
|
|
|
|
|
|
|
|
await videoWatchPage.goOnP2PMediaLoaderEmbed()
|
|
|
|
|
2020-05-13 04:15:31 -04:00
|
|
|
await videoWatchPage.playAndPauseVideo(false)
|
2019-02-21 05:24:07 -05:00
|
|
|
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
|
|
|
|
|
|
|
await browser.waitForAngularEnabled(true)
|
2018-05-17 04:55:01 -04:00
|
|
|
})
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
it('Should update the video', async () => {
|
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await browser.get(videoWatchUrl)
|
|
|
|
|
|
|
|
await videoWatchPage.clickOnUpdate()
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
videoName += ' updated'
|
|
|
|
await videoUpdatePage.updateName(videoName)
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
await videoUpdatePage.validUpdate()
|
|
|
|
|
|
|
|
const name = await videoWatchPage.getVideoName()
|
2019-06-18 04:20:55 -04:00
|
|
|
expect(name).toEqual(videoName)
|
2019-06-17 02:11:25 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should add the video in my playlist', async () => {
|
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await videoWatchPage.clickOnSave()
|
2019-06-18 04:20:55 -04:00
|
|
|
|
|
|
|
await videoWatchPage.createPlaylist(playlistName)
|
|
|
|
|
|
|
|
await videoWatchPage.saveToPlaylist(playlistName)
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
await videoUploadPage.navigateTo()
|
|
|
|
|
|
|
|
await videoUploadPage.uploadVideo()
|
2019-06-18 04:20:55 -04:00
|
|
|
await videoUploadPage.validSecondUploadStep(video2Name)
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
await videoWatchPage.clickOnSave()
|
2019-06-18 04:20:55 -04:00
|
|
|
await videoWatchPage.saveToPlaylist(playlistName)
|
2019-06-17 02:11:25 -04:00
|
|
|
})
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
it('Should have the playlist in my account', async () => {
|
2019-06-17 02:11:25 -04:00
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await myAccountPage.navigateToMyPlaylists()
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
|
2019-06-17 02:11:25 -04:00
|
|
|
expect(videosNumberText).toEqual('2 videos')
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
await myAccountPage.clickOnPlaylist(playlistName)
|
2019-06-17 02:11:25 -04:00
|
|
|
|
|
|
|
const count = await myAccountPage.countTotalPlaylistElements()
|
|
|
|
expect(count).toEqual(2)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should watch the playlist', async () => {
|
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await myAccountPage.playPlaylist()
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
|
2019-06-17 02:11:25 -04:00
|
|
|
})
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
it('Should delete the video 2', async () => {
|
2019-06-17 02:11:25 -04:00
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
|
|
|
await myAccountPage.navigateToMyVideos()
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
await myAccountPage.removeVideo(video2Name)
|
2019-06-17 02:11:25 -04:00
|
|
|
await myAccountPage.validRemove()
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
const count = await myAccountPage.countVideos([ videoName, video2Name ])
|
2019-06-17 02:11:25 -04:00
|
|
|
expect(count).toEqual(1)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should delete the first video', async () => {
|
|
|
|
if (await skipIfUploadNotSupported()) return
|
|
|
|
|
2019-06-18 04:20:55 -04:00
|
|
|
await myAccountPage.removeVideo(videoName)
|
2019-06-17 02:11:25 -04:00
|
|
|
await myAccountPage.validRemove()
|
|
|
|
})
|
2018-05-17 04:55:01 -04:00
|
|
|
})
|