2018-05-17 03:55:01 -05:00
|
|
|
import { VideoWatchPage } from './po/video-watch.po'
|
|
|
|
import { VideoUploadPage } from './po/video-upload.po'
|
|
|
|
import { LoginPage } from './po/login.po'
|
|
|
|
import { browser } from 'protractor'
|
|
|
|
|
|
|
|
describe('Videos workflow', () => {
|
|
|
|
let videoWatchPage: VideoWatchPage
|
|
|
|
let pageUploadPage: VideoUploadPage
|
|
|
|
let loginPage: LoginPage
|
|
|
|
const videoName = new Date().getTime() + ' video'
|
2018-05-19 06:58:29 -05:00
|
|
|
let isMobileDevice = false
|
|
|
|
let isIphoneDevice = false
|
2018-05-22 09:02:29 -05:00
|
|
|
let isSafari = false
|
2018-05-19 06:58:29 -05:00
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
browser.waitForAngularEnabled(false)
|
2018-05-17 03:55:01 -05:00
|
|
|
|
|
|
|
videoWatchPage = new VideoWatchPage()
|
|
|
|
pageUploadPage = new VideoUploadPage()
|
|
|
|
loginPage = new LoginPage()
|
2018-05-19 06:58:29 -05:00
|
|
|
|
|
|
|
const caps = await browser.getCapabilities()
|
|
|
|
isMobileDevice = caps.get('realMobile') === 'true' || caps.get('realMobile') === true
|
|
|
|
isIphoneDevice = caps.get('device') === 'iphone'
|
2018-05-22 09:02:29 -05:00
|
|
|
isSafari = caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
|
2018-05-17 03:55:01 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should log in', () => {
|
2018-05-19 06:58:29 -05:00
|
|
|
if (isMobileDevice) {
|
|
|
|
console.log('Skipping because we are on a real device and BrowserStack does not support file upload.')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-05-17 03:55:01 -05:00
|
|
|
return loginPage.loginAsRootUser()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should upload a video', async () => {
|
2018-05-19 06:58:29 -05:00
|
|
|
if (isMobileDevice) {
|
|
|
|
console.log('Skipping because we are on a real device and BrowserStack does not support file upload.')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-05-22 09:02:29 -05:00
|
|
|
await pageUploadPage.navigateTo()
|
2018-05-17 03:55:01 -05:00
|
|
|
|
|
|
|
await pageUploadPage.uploadVideo()
|
|
|
|
return pageUploadPage.validSecondUploadStep(videoName)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should list the video', async () => {
|
2018-05-22 09:02:29 -05:00
|
|
|
await videoWatchPage.goOnVideosList(isIphoneDevice, isSafari)
|
2018-05-19 06:58:29 -05:00
|
|
|
|
|
|
|
if (isMobileDevice) {
|
|
|
|
console.log('Skipping because we are on a real device and BrowserStack does not support file upload.')
|
|
|
|
return
|
|
|
|
}
|
2018-05-17 03:55:01 -05:00
|
|
|
|
|
|
|
const videoNames = videoWatchPage.getVideosListName()
|
|
|
|
expect(videoNames).toContain(videoName)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should go on video watch page', async () => {
|
2018-05-19 06:58:29 -05:00
|
|
|
let videoNameToExcept = videoName
|
|
|
|
|
2018-05-22 09:02:29 -05:00
|
|
|
if (isMobileDevice) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
|
2018-05-19 06:58:29 -05:00
|
|
|
else await videoWatchPage.clickOnVideo(videoName)
|
2018-05-17 03:55:01 -05:00
|
|
|
|
2018-05-19 06:58:29 -05:00
|
|
|
return videoWatchPage.waitWatchVideoName(videoNameToExcept)
|
2018-05-17 03:55:01 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should play the video', async () => {
|
2018-05-22 09:02:29 -05:00
|
|
|
await videoWatchPage.pauseVideo(7000, !isMobileDevice, isSafari)
|
|
|
|
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should watch the associated embed video', async () => {
|
|
|
|
await videoWatchPage.goOnAssociatedEmbed()
|
|
|
|
|
|
|
|
await videoWatchPage.pauseVideo(7000, false, isSafari)
|
2018-05-17 03:55:01 -05:00
|
|
|
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
|
|
|
})
|
|
|
|
})
|