1
0
Fork 0
peertube/client/e2e/src/videos.e2e-spec.ts

202 lines
6 KiB
TypeScript
Raw Normal View History

2018-05-17 04:55:01 -04: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'
2019-06-17 02:11:25 -04:00
import { VideoUpdatePage } from './po/video-update.po'
import { MyAccountPage } from './po/my-account'
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
}
async function isMobileDevice () {
const caps = await browser.getCapabilities()
return caps.get('realMobile') === 'true' || caps.get('realMobile') === true
}
async function isSafari () {
const caps = await browser.getCapabilities()
return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
}
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
2019-06-17 02:11:25 -04:00
2018-05-17 04:55:01 -04:00
const videoName = new Date().getTime() + ' video'
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()
2018-05-19 07:58:29 -04:00
2019-06-17 02:11:25 -04:00
if (await isMobileDevice()) {
2019-02-21 05:24:07 -05:00
console.log('Mobile device detected.')
}
2019-06-17 02:11:25 -04:00
if (await isSafari()) {
2019-02-21 05:24:07 -05:00
console.log('Safari detected.')
}
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()
})
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()
await videoWatchPage.playAndPauseVideo(true, await isMobileDevice())
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()
2019-06-17 02:11:25 -04:00
await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
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()
2019-06-17 02:11:25 -04:00
await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
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()
await videoUpdatePage.updateName('my new name')
await videoUpdatePage.validUpdate()
const name = await videoWatchPage.getVideoName()
expect(name).toEqual('my new name')
})
it('Should add the video in my playlist', async () => {
if (await skipIfUploadNotSupported()) return
await videoWatchPage.clickOnSave()
await videoWatchPage.saveToWatchLater()
await videoUploadPage.navigateTo()
await videoUploadPage.uploadVideo()
await videoUploadPage.validSecondUploadStep('second video')
await videoWatchPage.clickOnSave()
await videoWatchPage.saveToWatchLater()
})
it('Should have the watch later playlist in my account', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyPlaylists()
const name = await myAccountPage.getLastUpdatedPlaylistName()
expect(name).toEqual('Watch later')
const videosNumberText = await myAccountPage.getLastUpdatedPlaylistVideosText()
expect(videosNumberText).toEqual('2 videos')
await myAccountPage.clickOnLastUpdatedPlaylist()
const count = await myAccountPage.countTotalPlaylistElements()
expect(count).toEqual(2)
})
it('Should watch the playlist', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.playPlaylist()
await videoWatchPage.waitUntilVideoName('second video', 20000 * 1000)
})
it('Should have the video in my account', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyVideos()
const lastVideoName = await myAccountPage.getLastVideoName()
expect(lastVideoName).toEqual('second video')
})
it('Should delete the last video', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.removeLastVideo()
await myAccountPage.validRemove()
const count = await myAccountPage.countVideos()
expect(count).toEqual(1)
})
it('Should delete the first video', async () => {
if (await skipIfUploadNotSupported()) return
await myAccountPage.removeLastVideo()
await myAccountPage.validRemove()
const count = await myAccountPage.countVideos()
expect(count).toEqual(0)
})
2018-05-17 04:55:01 -04:00
})