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

195 lines
5.8 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'
2019-06-17 01:11:25 -05: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 03:55:01 -05:00
describe('Videos workflow', () => {
let videoWatchPage: VideoWatchPage
2019-06-17 01:11:25 -05:00
let videoUploadPage: VideoUploadPage
let videoUpdatePage: VideoUpdatePage
let myAccountPage: MyAccountPage
2018-05-17 03:55:01 -05:00
let loginPage: LoginPage
2019-06-17 01:11:25 -05:00
2019-06-18 03:20:55 -05:00
let videoName = new Date().getTime() + ' video'
const video2Name = new Date().getTime() + ' second video'
const playlistName = new Date().getTime() + ' playlist'
2019-06-17 01:11:25 -05:00
let videoWatchUrl: string
2018-05-19 06:58:29 -05:00
beforeEach(async () => {
2018-05-17 03:55:01 -05:00
videoWatchPage = new VideoWatchPage()
2019-06-17 01:11:25 -05:00
videoUploadPage = new VideoUploadPage()
videoUpdatePage = new VideoUpdatePage()
myAccountPage = new MyAccountPage()
2018-05-17 03:55:01 -05:00
loginPage = new LoginPage()
2018-05-19 06:58:29 -05:00
2019-06-17 01:11:25 -05:00
if (await isMobileDevice()) {
2019-02-21 04:24:07 -06:00
console.log('Mobile device detected.')
}
2019-06-17 01:11:25 -05:00
if (await isSafari()) {
2019-02-21 04:24:07 -06:00
console.log('Safari detected.')
}
2018-05-17 03:55:01 -05:00
})
2019-06-17 01:11:25 -05:00
it('Should log in', async () => {
if (await isMobileDevice() || await isSafari()) {
2018-05-24 02:05:58 -05:00
console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
2018-05-19 06:58:29 -05:00
return
}
2018-05-17 03:55:01 -05:00
return loginPage.loginAsRootUser()
})
it('Should upload a video', async () => {
2019-06-17 01:11:25 -05:00
if (await skipIfUploadNotSupported()) return
2018-05-19 06:58:29 -05:00
2019-06-17 01:11:25 -05:00
await videoUploadPage.navigateTo()
2018-05-17 03:55:01 -05:00
2019-06-17 01:11:25 -05:00
await videoUploadPage.uploadVideo()
return videoUploadPage.validSecondUploadStep(videoName)
2018-05-17 03:55:01 -05:00
})
2019-05-14 06:59:10 -05:00
it('Should list videos', async () => {
2019-06-17 01:11:25 -05:00
await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari())
2018-05-19 06:58:29 -05:00
2019-06-17 01:11:25 -05:00
if (await skipIfUploadNotSupported()) 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
2019-06-17 01:11:25 -05:00
if (await isMobileDevice() || await isSafari()) 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
2019-06-17 01:11:25 -05:00
return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari())
2018-05-17 03:55:01 -05:00
})
it('Should play the video', async () => {
2019-06-17 01:11:25 -05:00
videoWatchUrl = await browser.getCurrentUrl()
await videoWatchPage.playAndPauseVideo(true, await isMobileDevice())
2018-05-22 09:02:29 -05:00
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
})
it('Should watch the associated embed video', async () => {
2019-02-21 04:24:07 -06:00
await browser.waitForAngularEnabled(false)
2018-05-22 09:02:29 -05:00
await videoWatchPage.goOnAssociatedEmbed()
2019-06-17 01:11:25 -05:00
await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
2018-05-17 03:55:01 -05:00
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
2019-02-21 04:24:07 -06: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 01:11:25 -05:00
await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
2019-02-21 04:24:07 -06:00
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
await browser.waitForAngularEnabled(true)
2018-05-17 03:55:01 -05:00
})
2019-06-17 01:11:25 -05:00
it('Should update the video', async () => {
if (await skipIfUploadNotSupported()) return
await browser.get(videoWatchUrl)
await videoWatchPage.clickOnUpdate()
2019-06-18 03:20:55 -05:00
videoName += ' updated'
await videoUpdatePage.updateName(videoName)
2019-06-17 01:11:25 -05:00
await videoUpdatePage.validUpdate()
const name = await videoWatchPage.getVideoName()
2019-06-18 03:20:55 -05:00
expect(name).toEqual(videoName)
2019-06-17 01:11:25 -05:00
})
it('Should add the video in my playlist', async () => {
if (await skipIfUploadNotSupported()) return
await videoWatchPage.clickOnSave()
2019-06-18 03:20:55 -05:00
await videoWatchPage.createPlaylist(playlistName)
await videoWatchPage.saveToPlaylist(playlistName)
2019-06-17 01:11:25 -05:00
await videoUploadPage.navigateTo()
await videoUploadPage.uploadVideo()
2019-06-18 03:20:55 -05:00
await videoUploadPage.validSecondUploadStep(video2Name)
2019-06-17 01:11:25 -05:00
await videoWatchPage.clickOnSave()
2019-06-18 03:20:55 -05:00
await videoWatchPage.saveToPlaylist(playlistName)
2019-06-17 01:11:25 -05:00
})
2019-06-18 03:20:55 -05:00
it('Should have the playlist in my account', async () => {
2019-06-17 01:11:25 -05:00
if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyPlaylists()
2019-06-18 03:20:55 -05:00
const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
2019-06-17 01:11:25 -05:00
expect(videosNumberText).toEqual('2 videos')
2019-06-18 03:20:55 -05:00
await myAccountPage.clickOnPlaylist(playlistName)
2019-06-17 01:11:25 -05: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 03:20:55 -05:00
await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
2019-06-17 01:11:25 -05:00
})
2019-06-18 03:20:55 -05:00
it('Should delete the video 2', async () => {
2019-06-17 01:11:25 -05:00
if (await skipIfUploadNotSupported()) return
await myAccountPage.navigateToMyVideos()
2019-06-18 03:20:55 -05:00
await myAccountPage.removeVideo(video2Name)
2019-06-17 01:11:25 -05:00
await myAccountPage.validRemove()
2019-06-18 03:20:55 -05:00
const count = await myAccountPage.countVideos([ videoName, video2Name ])
2019-06-17 01:11:25 -05:00
expect(count).toEqual(1)
})
it('Should delete the first video', async () => {
if (await skipIfUploadNotSupported()) return
2019-06-18 03:20:55 -05:00
await myAccountPage.removeVideo(videoName)
2019-06-17 01:11:25 -05:00
await myAccountPage.validRemove()
})
2018-05-17 03:55:01 -05:00
})