PeerTube/client/e2e/src/videos.e2e-spec.ts

75 lines
2.3 KiB
TypeScript
Raw Normal View History

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
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-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-17 03:55:01 -05:00
pageUploadPage.navigateTo()
await pageUploadPage.uploadVideo()
return pageUploadPage.validSecondUploadStep(videoName)
})
it('Should list the video', async () => {
2018-05-19 06:58:29 -05:00
await videoWatchPage.goOnVideosList(isIphoneDevice)
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
if (isMobileDevice && isIphoneDevice) videoNameToExcept = 'PeerTube_Mobile.v.1'
if (isMobileDevice && isIphoneDevice === false) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
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-19 06:58:29 -05:00
await videoWatchPage.pauseVideo(7000, isMobileDevice, isIphoneDevice)
2018-05-17 03:55:01 -05:00
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
})
})