aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/videos.e2e-spec.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-30 16:24:25 +0200
committerChocobozzz <me@florianbigard.com>2021-09-01 15:06:46 +0200
commit3419e0e1fe8e48a08b63ca0ded31087f913eb2b6 (patch)
tree63ac7190b79194e93aec9bbfd3c336e60f469e9d /client/e2e/src/videos.e2e-spec.ts
parent2a4c9669d2d6ac6cd4ae43544698f826ae98080f (diff)
downloadPeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.gz
PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.zst
PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.zip
Migrate to webdriverio
Diffstat (limited to 'client/e2e/src/videos.e2e-spec.ts')
-rw-r--r--client/e2e/src/videos.e2e-spec.ts140
1 files changed, 62 insertions, 78 deletions
diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts
index fc816d1bf..7f7c814e1 100644
--- a/client/e2e/src/videos.e2e-spec.ts
+++ b/client/e2e/src/videos.e2e-spec.ts
@@ -1,14 +1,13 @@
1import { browser } from 'protractor'
2import { LoginPage } from './po/login.po' 1import { LoginPage } from './po/login.po'
3import { MyAccountPage } from './po/my-account' 2import { MyAccountPage } from './po/my-account'
4import { PlayerPage } from './po/player.po' 3import { PlayerPage } from './po/player.po'
5import { VideoUpdatePage } from './po/video-update.po' 4import { VideoUpdatePage } from './po/video-update.po'
6import { VideoUploadPage } from './po/video-upload.po' 5import { VideoUploadPage } from './po/video-upload.po'
7import { VideoWatchPage } from './po/video-watch.po' 6import { VideoWatchPage } from './po/video-watch.po'
8import { isIOS, isMobileDevice, isSafari } from './utils' 7import { browserSleep, go, isIOS, isMobileDevice, isSafari } from './utils'
9 8
10async function skipIfUploadNotSupported () { 9function isUploadUnsupported () {
11 if (await isMobileDevice() || await isSafari()) { 10 if (isMobileDevice() || isSafari()) {
12 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') 11 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
13 return true 12 return true
14 } 13 }
@@ -24,11 +23,30 @@ describe('Videos workflow', () => {
24 let loginPage: LoginPage 23 let loginPage: LoginPage
25 let playerPage: PlayerPage 24 let playerPage: PlayerPage
26 25
27 let videoName = new Date().getTime() + ' video' 26 let videoName = Math.random() + ' video'
28 const video2Name = new Date().getTime() + ' second video' 27 const video2Name = Math.random() + ' second video'
29 const playlistName = new Date().getTime() + ' playlist' 28 const playlistName = Math.random() + ' playlist'
30 let videoWatchUrl: string 29 let videoWatchUrl: string
31 30
31 before(async () => {
32 if (isIOS()) {
33 console.log('iOS detected')
34 } else if (isMobileDevice()) {
35 console.log('Android detected.')
36 } else if (isSafari()) {
37 console.log('Safari detected.')
38 }
39
40 if (isUploadUnsupported()) return
41
42 await browser.waitUntil(async () => {
43 await go('/')
44 await browserSleep(500)
45
46 return $('<my-app>').isDisplayed()
47 }, { timeout: 20 * 1000 })
48 })
49
32 beforeEach(async () => { 50 beforeEach(async () => {
33 videoWatchPage = new VideoWatchPage() 51 videoWatchPage = new VideoWatchPage()
34 videoUploadPage = new VideoUploadPage() 52 videoUploadPage = new VideoUploadPage()
@@ -37,25 +55,13 @@ describe('Videos workflow', () => {
37 loginPage = new LoginPage() 55 loginPage = new LoginPage()
38 playerPage = new PlayerPage() 56 playerPage = new PlayerPage()
39 57
40 if (await isIOS()) { 58 if (!isMobileDevice()) {
41 // iOS does not seem to work with protractor 59 await browser.maximizeWindow()
42 // https://github.com/angular/protractor/issues/2840
43 browser.waitForAngularEnabled(false)
44
45 console.log('iOS detected')
46 } else if (await isMobileDevice()) {
47 console.log('Android detected.')
48 } else if (await isSafari()) {
49 console.log('Safari detected.')
50 }
51
52 if (!await isMobileDevice()) {
53 await browser.driver.manage().window().maximize()
54 } 60 }
55 }) 61 })
56 62
57 it('Should log in', async () => { 63 it('Should log in', async () => {
58 if (await isMobileDevice() || await isSafari()) { 64 if (isMobileDevice() || isSafari()) {
59 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') 65 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
60 return 66 return
61 } 67 }
@@ -64,7 +70,7 @@ describe('Videos workflow', () => {
64 }) 70 })
65 71
66 it('Should upload a video', async () => { 72 it('Should upload a video', async () => {
67 if (await skipIfUploadNotSupported()) return 73 if (isUploadUnsupported()) return
68 74
69 await videoUploadPage.navigateTo() 75 await videoUploadPage.navigateTo()
70 76
@@ -73,62 +79,52 @@ describe('Videos workflow', () => {
73 }) 79 })
74 80
75 it('Should list videos', async () => { 81 it('Should list videos', async () => {
76 await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari()) 82 await videoWatchPage.goOnVideosList(isMobileDevice(), isSafari())
77 83
78 if (await skipIfUploadNotSupported()) return 84 if (isUploadUnsupported()) return
79 85
80 const videoNames = videoWatchPage.getVideosListName() 86 const videoNames = await videoWatchPage.getVideosListName()
81 expect(videoNames).toContain(videoName) 87 expect(videoNames).toContain(videoName)
82 }) 88 })
83 89
84 it('Should go on video watch page', async () => { 90 it('Should go on video watch page', async () => {
85 let videoNameToExcept = videoName 91 let videoNameToExcept = videoName
86 92
87 if (await isMobileDevice() || await isSafari()) { 93 if (isMobileDevice() || isSafari()) {
88 await browser.get('https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e') 94 await go('https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e')
89 videoNameToExcept = 'E2E tests' 95 videoNameToExcept = 'E2E tests'
90 } else { 96 } else {
91 await videoWatchPage.clickOnVideo(videoName) 97 await videoWatchPage.clickOnVideo(videoName)
92 } 98 }
93 99
94 return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari()) 100 return videoWatchPage.waitWatchVideoName(videoNameToExcept, isMobileDevice(), isSafari())
95 }) 101 })
96 102
97 it('Should play the video', async () => { 103 it('Should play the video', async () => {
98 videoWatchUrl = await browser.getCurrentUrl() 104 videoWatchUrl = await browser.getUrl()
99 105
100 await playerPage.playAndPauseVideo(true) 106 await playerPage.playAndPauseVideo(true)
101 expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 107 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
102 }) 108 })
103 109
104 it('Should watch the associated embed video', async () => { 110 it('Should watch the associated embed video', async () => {
105 const oldValue = await browser.waitForAngularEnabled()
106 await browser.waitForAngularEnabled(false)
107
108 await videoWatchPage.goOnAssociatedEmbed() 111 await videoWatchPage.goOnAssociatedEmbed()
109 112
110 await playerPage.playAndPauseVideo(false) 113 await playerPage.playAndPauseVideo(false)
111 expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 114 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
112
113 await browser.waitForAngularEnabled(oldValue)
114 }) 115 })
115 116
116 it('Should watch the p2p media loader embed video', async () => { 117 it('Should watch the p2p media loader embed video', async () => {
117 const oldValue = await browser.waitForAngularEnabled()
118 await browser.waitForAngularEnabled(false)
119
120 await videoWatchPage.goOnP2PMediaLoaderEmbed() 118 await videoWatchPage.goOnP2PMediaLoaderEmbed()
121 119
122 await playerPage.playAndPauseVideo(false) 120 await playerPage.playAndPauseVideo(false)
123 expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 121 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
124
125 await browser.waitForAngularEnabled(oldValue)
126 }) 122 })
127 123
128 it('Should update the video', async () => { 124 it('Should update the video', async () => {
129 if (await skipIfUploadNotSupported()) return 125 if (isUploadUnsupported()) return
130 126
131 await browser.get(videoWatchUrl) 127 await go(videoWatchUrl)
132 128
133 await videoWatchPage.clickOnUpdate() 129 await videoWatchPage.clickOnUpdate()
134 130
@@ -142,14 +138,14 @@ describe('Videos workflow', () => {
142 }) 138 })
143 139
144 it('Should add the video in my playlist', async () => { 140 it('Should add the video in my playlist', async () => {
145 if (await skipIfUploadNotSupported()) return 141 if (isUploadUnsupported()) return
146 142
147 await videoWatchPage.clickOnSave() 143 await videoWatchPage.clickOnSave()
148 144
149 await videoWatchPage.createPlaylist(playlistName) 145 await videoWatchPage.createPlaylist(playlistName)
150 146
151 await videoWatchPage.saveToPlaylist(playlistName) 147 await videoWatchPage.saveToPlaylist(playlistName)
152 await browser.sleep(5000) 148 await browser.pause(5000)
153 149
154 await videoUploadPage.navigateTo() 150 await videoUploadPage.navigateTo()
155 151
@@ -161,7 +157,7 @@ describe('Videos workflow', () => {
161 }) 157 })
162 158
163 it('Should have the playlist in my account', async () => { 159 it('Should have the playlist in my account', async () => {
164 if (await skipIfUploadNotSupported()) return 160 if (isUploadUnsupported()) return
165 161
166 await myAccountPage.navigateToMyPlaylists() 162 await myAccountPage.navigateToMyPlaylists()
167 163
@@ -175,26 +171,18 @@ describe('Videos workflow', () => {
175 }) 171 })
176 172
177 it('Should watch the playlist', async () => { 173 it('Should watch the playlist', async () => {
178 if (await skipIfUploadNotSupported()) return 174 if (isUploadUnsupported()) return
179 175
180 await myAccountPage.playPlaylist() 176 await myAccountPage.playPlaylist()
181 177
182 const oldValue = await browser.waitForAngularEnabled() 178 await videoWatchPage.waitUntilVideoName(video2Name, 30 * 1000)
183 await browser.waitForAngularEnabled(false)
184
185 await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
186
187 await browser.waitForAngularEnabled(oldValue)
188 }) 179 })
189 180
190 it('Should watch the webtorrent playlist in the embed', async () => { 181 it('Should watch the webtorrent playlist in the embed', async () => {
191 if (await skipIfUploadNotSupported()) return 182 if (isUploadUnsupported()) return
192
193 const accessToken = await browser.executeScript(`return window.localStorage.getItem('access_token');`)
194 const refreshToken = await browser.executeScript(`return window.localStorage.getItem('refresh_token');`)
195 183
196 const oldValue = await browser.waitForAngularEnabled() 184 const accessToken = await browser.execute(`return window.localStorage.getItem('access_token');`)
197 await browser.waitForAngularEnabled(false) 185 const refreshToken = await browser.execute(`return window.localStorage.getItem('refresh_token');`)
198 186
199 await myAccountPage.goOnAssociatedPlaylistEmbed() 187 await myAccountPage.goOnAssociatedPlaylistEmbed()
200 188
@@ -202,49 +190,45 @@ describe('Videos workflow', () => {
202 190
203 console.log('Will set %s and %s tokens in local storage.', accessToken, refreshToken) 191 console.log('Will set %s and %s tokens in local storage.', accessToken, refreshToken)
204 192
205 await browser.executeScript(`window.localStorage.setItem('access_token', '${accessToken}');`) 193 await browser.execute(`window.localStorage.setItem('access_token', '${accessToken}');`)
206 await browser.executeScript(`window.localStorage.setItem('refresh_token', '${refreshToken}');`) 194 await browser.execute(`window.localStorage.setItem('refresh_token', '${refreshToken}');`)
207 await browser.executeScript(`window.localStorage.setItem('token_type', 'Bearer');`) 195 await browser.execute(`window.localStorage.setItem('token_type', 'Bearer');`)
208 196
209 await browser.refresh() 197 await browser.refresh()
210 198
211 await playerPage.playVideo() 199 await playerPage.playVideo()
212 200
213 await playerPage.waitUntilPlaylistInfo('2/2') 201 await playerPage.waitUntilPlaylistInfo('2/2', 30 * 1000)
214
215 await browser.waitForAngularEnabled(oldValue)
216 }) 202 })
217 203
218 it('Should watch the HLS playlist in the embed', async () => { 204 it('Should watch the HLS playlist in the embed', async () => {
219 const oldValue = await browser.waitForAngularEnabled()
220 await browser.waitForAngularEnabled(false)
221
222 await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed() 205 await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed()
223 206
224 await playerPage.playVideo() 207 await playerPage.playVideo()
225 208
226 await playerPage.waitUntilPlaylistInfo('2/2') 209 await playerPage.waitUntilPlaylistInfo('2/2', 30 * 1000)
227
228 await browser.waitForAngularEnabled(oldValue)
229 }) 210 })
230 211
231 it('Should delete the video 2', async () => { 212 it('Should delete the video 2', async () => {
232 if (await skipIfUploadNotSupported()) return 213 if (isUploadUnsupported()) return
233 214
234 // Go to the dev website 215 // Go to the dev website
235 await browser.get(videoWatchUrl) 216 await go(videoWatchUrl)
236 217
237 await myAccountPage.navigateToMyVideos() 218 await myAccountPage.navigateToMyVideos()
238 219
239 await myAccountPage.removeVideo(video2Name) 220 await myAccountPage.removeVideo(video2Name)
240 await myAccountPage.validRemove() 221 await myAccountPage.validRemove()
241 222
242 const count = await myAccountPage.countVideos([ videoName, video2Name ]) 223 await browser.waitUntil(async () => {
243 expect(count).toEqual(1) 224 const count = await myAccountPage.countVideos([ videoName, video2Name ])
225
226 return count === 1
227 })
244 }) 228 })
245 229
246 it('Should delete the first video', async () => { 230 it('Should delete the first video', async () => {
247 if (await skipIfUploadNotSupported()) return 231 if (isUploadUnsupported()) return
248 232
249 await myAccountPage.removeVideo(videoName) 233 await myAccountPage.removeVideo(videoName)
250 await myAccountPage.validRemove() 234 await myAccountPage.validRemove()