-import { VideoWatchPage } from './po/video-watch.po'
-import { VideoUploadPage } from './po/video-upload.po'
-import { LoginPage } from './po/login.po'
import { browser } from 'protractor'
-import { VideoUpdatePage } from './po/video-update.po'
+import { LoginPage } from './po/login.po'
import { MyAccountPage } from './po/my-account'
+import { PlayerPage } from './po/player.po'
+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'
async function skipIfUploadNotSupported () {
if (await isMobileDevice() || await isSafari()) {
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'
-}
-
describe('Videos workflow', () => {
let videoWatchPage: VideoWatchPage
let videoUploadPage: VideoUploadPage
let videoUpdatePage: VideoUpdatePage
let myAccountPage: MyAccountPage
let loginPage: LoginPage
+ let playerPage: PlayerPage
- const videoName = new Date().getTime() + ' video'
+ let videoName = new Date().getTime() + ' video'
+ const video2Name = new Date().getTime() + ' second video'
+ const playlistName = new Date().getTime() + ' playlist'
let videoWatchUrl: string
beforeEach(async () => {
videoUpdatePage = new VideoUpdatePage()
myAccountPage = new MyAccountPage()
loginPage = new LoginPage()
+ playerPage = new PlayerPage()
- if (await isMobileDevice()) {
- console.log('Mobile device detected.')
- }
+ if (await isIOS()) {
+ // iOS does not seem to work with protractor
+ // https://github.com/angular/protractor/issues/2840
+ browser.waitForAngularEnabled(false)
- if (await isSafari()) {
+ console.log('iOS detected')
+ } else if (await isMobileDevice()) {
+ console.log('Android detected.')
+ } else if (await isSafari()) {
console.log('Safari detected.')
}
+
+ if (!await isMobileDevice()) {
+ await browser.driver.manage().window().maximize()
+ }
})
it('Should log in', async () => {
it('Should go on video watch page', async () => {
let videoNameToExcept = videoName
- if (await isMobileDevice() || await isSafari()) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
- else await videoWatchPage.clickOnVideo(videoName)
+ if (await isMobileDevice() || await isSafari()) {
+ await browser.get('https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e')
+ videoNameToExcept = 'E2E tests'
+ } else {
+ await videoWatchPage.clickOnVideo(videoName)
+ }
return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari())
})
it('Should play the video', async () => {
videoWatchUrl = await browser.getCurrentUrl()
- await videoWatchPage.playAndPauseVideo(true, await isMobileDevice())
- expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
+ await playerPage.playAndPauseVideo(true)
+ expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
})
it('Should watch the associated embed video', async () => {
+ const oldValue = await browser.waitForAngularEnabled()
await browser.waitForAngularEnabled(false)
await videoWatchPage.goOnAssociatedEmbed()
- await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
- expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
+ await playerPage.playAndPauseVideo(false)
+ expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
- await browser.waitForAngularEnabled(true)
+ await browser.waitForAngularEnabled(oldValue)
})
it('Should watch the p2p media loader embed video', async () => {
+ const oldValue = await browser.waitForAngularEnabled()
await browser.waitForAngularEnabled(false)
await videoWatchPage.goOnP2PMediaLoaderEmbed()
- await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
- expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
+ await playerPage.playAndPauseVideo(false)
+ expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
- await browser.waitForAngularEnabled(true)
+ await browser.waitForAngularEnabled(oldValue)
})
it('Should update the video', async () => {
await videoWatchPage.clickOnUpdate()
- await videoUpdatePage.updateName('my new name')
+ videoName += ' updated'
+ await videoUpdatePage.updateName(videoName)
await videoUpdatePage.validUpdate()
const name = await videoWatchPage.getVideoName()
- expect(name).toEqual('my new name')
+ expect(name).toEqual(videoName)
})
it('Should add the video in my playlist', async () => {
if (await skipIfUploadNotSupported()) return
await videoWatchPage.clickOnSave()
- await videoWatchPage.saveToWatchLater()
+
+ await videoWatchPage.createPlaylist(playlistName)
+
+ await videoWatchPage.saveToPlaylist(playlistName)
+ await browser.sleep(5000)
await videoUploadPage.navigateTo()
await videoUploadPage.uploadVideo()
- await videoUploadPage.validSecondUploadStep('second video')
+ await videoUploadPage.validSecondUploadStep(video2Name)
await videoWatchPage.clickOnSave()
- await videoWatchPage.saveToWatchLater()
+ await videoWatchPage.saveToPlaylist(playlistName)
})
- it('Should have the watch later playlist in my account', async () => {
+ it('Should have the 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()
+ const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
expect(videosNumberText).toEqual('2 videos')
- await myAccountPage.clickOnLastUpdatedPlaylist()
+ await myAccountPage.clickOnPlaylist(playlistName)
const count = await myAccountPage.countTotalPlaylistElements()
expect(count).toEqual(2)
await myAccountPage.playPlaylist()
- await videoWatchPage.waitUntilVideoName('second video', 20000 * 1000)
+ const oldValue = await browser.waitForAngularEnabled()
+ await browser.waitForAngularEnabled(false)
+
+ await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
+
+ await browser.waitForAngularEnabled(oldValue)
})
- it('Should have the video in my account', async () => {
+ it('Should watch the webtorrent playlist in the embed', async () => {
if (await skipIfUploadNotSupported()) return
- await myAccountPage.navigateToMyVideos()
+ const accessToken = await browser.executeScript(`return window.localStorage.getItem('access_token');`)
+ const refreshToken = await browser.executeScript(`return window.localStorage.getItem('refresh_token');`)
+
+ const oldValue = await browser.waitForAngularEnabled()
+ await browser.waitForAngularEnabled(false)
+
+ await myAccountPage.goOnAssociatedPlaylistEmbed()
+
+ await playerPage.waitUntilPlayerWrapper()
+
+ console.log('Will set %s and %s tokens in local storage.', accessToken, refreshToken)
+
+ await browser.executeScript(`window.localStorage.setItem('access_token', '${accessToken}');`)
+ await browser.executeScript(`window.localStorage.setItem('refresh_token', '${refreshToken}');`)
+ await browser.executeScript(`window.localStorage.setItem('token_type', 'Bearer');`)
+
+ await browser.refresh()
+
+ await playerPage.playVideo()
+
+ await playerPage.waitUntilPlaylistInfo('2/2')
+
+ await browser.waitForAngularEnabled(oldValue)
+ })
+
+ it('Should watch the HLS playlist in the embed', async () => {
+ const oldValue = await browser.waitForAngularEnabled()
+ await browser.waitForAngularEnabled(false)
+
+ await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed()
+
+ await playerPage.playVideo()
+
+ await playerPage.waitUntilPlaylistInfo('2/2')
- const lastVideoName = await myAccountPage.getLastVideoName()
- expect(lastVideoName).toEqual('second video')
+ await browser.waitForAngularEnabled(oldValue)
})
- it('Should delete the last video', async () => {
+ it('Should delete the video 2', async () => {
if (await skipIfUploadNotSupported()) return
- await myAccountPage.removeLastVideo()
+ // Go to the dev website
+ await browser.get(videoWatchUrl)
+
+ await myAccountPage.navigateToMyVideos()
+
+ await myAccountPage.removeVideo(video2Name)
await myAccountPage.validRemove()
- const count = await myAccountPage.countVideos()
+ const count = await myAccountPage.countVideos([ videoName, video2Name ])
expect(count).toEqual(1)
})
it('Should delete the first video', async () => {
if (await skipIfUploadNotSupported()) return
- await myAccountPage.removeLastVideo()
+ await myAccountPage.removeVideo(videoName)
await myAccountPage.validRemove()
-
- const count = await myAccountPage.countVideos()
- expect(count).toEqual(0)
})
})