]>
Commit | Line | Data |
---|---|---|
5f92c4dc | 1 | import { browser } from 'protractor' |
44d4ee4f | 2 | import { AppPage } from './po/app.po' |
ee68bbc4 C |
3 | import { LoginPage } from './po/login.po' |
4 | import { MyAccountPage } from './po/my-account' | |
7f90579c | 5 | import { PlayerPage } from './po/player.po' |
ee68bbc4 C |
6 | import { VideoUpdatePage } from './po/video-update.po' |
7 | import { VideoUploadPage } from './po/video-upload.po' | |
8 | import { VideoWatchPage } from './po/video-watch.po' | |
9 | import { isIOS, isMobileDevice, isSafari } from './utils' | |
e69cb173 C |
10 | |
11 | async function skipIfUploadNotSupported () { | |
12 | if (await isMobileDevice() || await isSafari()) { | |
13 | console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') | |
14 | return true | |
15 | } | |
16 | ||
17 | return false | |
18 | } | |
19 | ||
5f92c4dc C |
20 | describe('Videos workflow', () => { |
21 | let videoWatchPage: VideoWatchPage | |
e69cb173 C |
22 | let videoUploadPage: VideoUploadPage |
23 | let videoUpdatePage: VideoUpdatePage | |
24 | let myAccountPage: MyAccountPage | |
5f92c4dc | 25 | let loginPage: LoginPage |
44d4ee4f | 26 | let appPage: AppPage |
7f90579c | 27 | let playerPage: PlayerPage |
e69cb173 | 28 | |
bbe078ba C |
29 | let videoName = new Date().getTime() + ' video' |
30 | const video2Name = new Date().getTime() + ' second video' | |
31 | const playlistName = new Date().getTime() + ' playlist' | |
e69cb173 | 32 | let videoWatchUrl: string |
0b33c520 C |
33 | |
34 | beforeEach(async () => { | |
5f92c4dc | 35 | videoWatchPage = new VideoWatchPage() |
e69cb173 C |
36 | videoUploadPage = new VideoUploadPage() |
37 | videoUpdatePage = new VideoUpdatePage() | |
38 | myAccountPage = new MyAccountPage() | |
5f92c4dc | 39 | loginPage = new LoginPage() |
44d4ee4f | 40 | appPage = new AppPage() |
7f90579c | 41 | playerPage = new PlayerPage() |
0b33c520 | 42 | |
ee68bbc4 C |
43 | if (await isIOS()) { |
44 | // iOS does not seem to work with protractor | |
45 | // https://github.com/angular/protractor/issues/2840 | |
c8bc2a1a | 46 | browser.waitForAngularEnabled(false) |
84c7cde6 | 47 | |
ee68bbc4 C |
48 | console.log('iOS detected') |
49 | } else if (await isMobileDevice()) { | |
50 | console.log('Android detected.') | |
51 | } else if (await isSafari()) { | |
84c7cde6 C |
52 | console.log('Safari detected.') |
53 | } | |
60c8b8a5 C |
54 | |
55 | if (!await isMobileDevice()) { | |
56 | await browser.driver.manage().window().maximize() | |
57 | } | |
5f92c4dc C |
58 | }) |
59 | ||
e69cb173 C |
60 | it('Should log in', async () => { |
61 | if (await isMobileDevice() || await isSafari()) { | |
1fad099d | 62 | console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') |
0b33c520 C |
63 | return |
64 | } | |
65 | ||
5f92c4dc C |
66 | return loginPage.loginAsRootUser() |
67 | }) | |
68 | ||
44d4ee4f C |
69 | it('Should close the welcome modal', async () => { |
70 | if (await skipIfUploadNotSupported()) return | |
71 | ||
72 | await appPage.closeWelcomeModal() | |
73 | }) | |
74 | ||
5f92c4dc | 75 | it('Should upload a video', async () => { |
e69cb173 | 76 | if (await skipIfUploadNotSupported()) return |
0b33c520 | 77 | |
e69cb173 | 78 | await videoUploadPage.navigateTo() |
5f92c4dc | 79 | |
e69cb173 C |
80 | await videoUploadPage.uploadVideo() |
81 | return videoUploadPage.validSecondUploadStep(videoName) | |
5f92c4dc C |
82 | }) |
83 | ||
ac043122 | 84 | it('Should list videos', async () => { |
e69cb173 | 85 | await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari()) |
0b33c520 | 86 | |
e69cb173 | 87 | if (await skipIfUploadNotSupported()) return |
5f92c4dc C |
88 | |
89 | const videoNames = videoWatchPage.getVideosListName() | |
90 | expect(videoNames).toContain(videoName) | |
91 | }) | |
92 | ||
93 | it('Should go on video watch page', async () => { | |
0b33c520 C |
94 | let videoNameToExcept = videoName |
95 | ||
61c299eb C |
96 | if (await isMobileDevice() || await isSafari()) { |
97 | await browser.get('https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e') | |
98 | videoNameToExcept = 'E2E tests' | |
99 | } else { | |
100 | await videoWatchPage.clickOnVideo(videoName) | |
101 | } | |
5f92c4dc | 102 | |
e69cb173 | 103 | return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari()) |
5f92c4dc C |
104 | }) |
105 | ||
106 | it('Should play the video', async () => { | |
e69cb173 C |
107 | videoWatchUrl = await browser.getCurrentUrl() |
108 | ||
7f90579c C |
109 | await playerPage.playAndPauseVideo(true) |
110 | expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) | |
d1bd87e0 C |
111 | }) |
112 | ||
113 | it('Should watch the associated embed video', async () => { | |
c8bc2a1a | 114 | const oldValue = await browser.waitForAngularEnabled() |
84c7cde6 C |
115 | await browser.waitForAngularEnabled(false) |
116 | ||
d1bd87e0 C |
117 | await videoWatchPage.goOnAssociatedEmbed() |
118 | ||
7f90579c C |
119 | await playerPage.playAndPauseVideo(false) |
120 | expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) | |
84c7cde6 | 121 | |
c8bc2a1a | 122 | await browser.waitForAngularEnabled(oldValue) |
84c7cde6 C |
123 | }) |
124 | ||
125 | it('Should watch the p2p media loader embed video', async () => { | |
c8bc2a1a | 126 | const oldValue = await browser.waitForAngularEnabled() |
84c7cde6 C |
127 | await browser.waitForAngularEnabled(false) |
128 | ||
129 | await videoWatchPage.goOnP2PMediaLoaderEmbed() | |
130 | ||
7f90579c C |
131 | await playerPage.playAndPauseVideo(false) |
132 | expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) | |
84c7cde6 | 133 | |
c8bc2a1a | 134 | await browser.waitForAngularEnabled(oldValue) |
5f92c4dc | 135 | }) |
e69cb173 C |
136 | |
137 | it('Should update the video', async () => { | |
138 | if (await skipIfUploadNotSupported()) return | |
139 | ||
140 | await browser.get(videoWatchUrl) | |
141 | ||
142 | await videoWatchPage.clickOnUpdate() | |
143 | ||
bbe078ba C |
144 | videoName += ' updated' |
145 | await videoUpdatePage.updateName(videoName) | |
e69cb173 C |
146 | |
147 | await videoUpdatePage.validUpdate() | |
148 | ||
149 | const name = await videoWatchPage.getVideoName() | |
bbe078ba | 150 | expect(name).toEqual(videoName) |
e69cb173 C |
151 | }) |
152 | ||
153 | it('Should add the video in my playlist', async () => { | |
154 | if (await skipIfUploadNotSupported()) return | |
155 | ||
156 | await videoWatchPage.clickOnSave() | |
bbe078ba C |
157 | |
158 | await videoWatchPage.createPlaylist(playlistName) | |
159 | ||
160 | await videoWatchPage.saveToPlaylist(playlistName) | |
f74832ce | 161 | await browser.sleep(5000) |
e69cb173 C |
162 | |
163 | await videoUploadPage.navigateTo() | |
164 | ||
165 | await videoUploadPage.uploadVideo() | |
bbe078ba | 166 | await videoUploadPage.validSecondUploadStep(video2Name) |
e69cb173 C |
167 | |
168 | await videoWatchPage.clickOnSave() | |
bbe078ba | 169 | await videoWatchPage.saveToPlaylist(playlistName) |
e69cb173 C |
170 | }) |
171 | ||
bbe078ba | 172 | it('Should have the playlist in my account', async () => { |
e69cb173 C |
173 | if (await skipIfUploadNotSupported()) return |
174 | ||
175 | await myAccountPage.navigateToMyPlaylists() | |
176 | ||
bbe078ba | 177 | const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName) |
e69cb173 C |
178 | expect(videosNumberText).toEqual('2 videos') |
179 | ||
bbe078ba | 180 | await myAccountPage.clickOnPlaylist(playlistName) |
e69cb173 C |
181 | |
182 | const count = await myAccountPage.countTotalPlaylistElements() | |
183 | expect(count).toEqual(2) | |
184 | }) | |
185 | ||
186 | it('Should watch the playlist', async () => { | |
187 | if (await skipIfUploadNotSupported()) return | |
188 | ||
189 | await myAccountPage.playPlaylist() | |
190 | ||
c8bc2a1a | 191 | const oldValue = await browser.waitForAngularEnabled() |
7f90579c C |
192 | await browser.waitForAngularEnabled(false) |
193 | ||
bbe078ba | 194 | await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000) |
7f90579c | 195 | |
c8bc2a1a | 196 | await browser.waitForAngularEnabled(oldValue) |
e69cb173 C |
197 | }) |
198 | ||
5ab7fd9d C |
199 | it('Should watch the webtorrent playlist in the embed', async () => { |
200 | if (await skipIfUploadNotSupported()) return | |
201 | ||
7f90579c C |
202 | const accessToken = await browser.executeScript(`return window.localStorage.getItem('access_token');`) |
203 | const refreshToken = await browser.executeScript(`return window.localStorage.getItem('refresh_token');`) | |
204 | ||
c8bc2a1a | 205 | const oldValue = await browser.waitForAngularEnabled() |
5ab7fd9d C |
206 | await browser.waitForAngularEnabled(false) |
207 | ||
208 | await myAccountPage.goOnAssociatedPlaylistEmbed() | |
209 | ||
6b88559b C |
210 | await playerPage.waitUntilPlayerWrapper() |
211 | ||
48586fe0 C |
212 | console.log('Will set %s and %s tokens in local storage.', accessToken, refreshToken) |
213 | ||
7f90579c C |
214 | await browser.executeScript(`window.localStorage.setItem('access_token', '${accessToken}');`) |
215 | await browser.executeScript(`window.localStorage.setItem('refresh_token', '${refreshToken}');`) | |
216 | await browser.executeScript(`window.localStorage.setItem('token_type', 'Bearer');`) | |
5ab7fd9d | 217 | |
7f90579c C |
218 | await browser.refresh() |
219 | ||
220 | await playerPage.playVideo() | |
221 | ||
222 | await playerPage.waitUntilPlaylistInfo('2/2') | |
223 | ||
c8bc2a1a | 224 | await browser.waitForAngularEnabled(oldValue) |
7f90579c C |
225 | }) |
226 | ||
227 | it('Should watch the HLS playlist in the embed', async () => { | |
c8bc2a1a | 228 | const oldValue = await browser.waitForAngularEnabled() |
7f90579c C |
229 | await browser.waitForAngularEnabled(false) |
230 | ||
231 | await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed() | |
232 | ||
233 | await playerPage.playVideo() | |
234 | ||
235 | await playerPage.waitUntilPlaylistInfo('2/2') | |
5ab7fd9d | 236 | |
c8bc2a1a | 237 | await browser.waitForAngularEnabled(oldValue) |
5ab7fd9d C |
238 | }) |
239 | ||
bbe078ba | 240 | it('Should delete the video 2', async () => { |
e69cb173 C |
241 | if (await skipIfUploadNotSupported()) return |
242 | ||
7f90579c C |
243 | // Go to the dev website |
244 | await browser.get(videoWatchUrl) | |
245 | ||
e69cb173 C |
246 | await myAccountPage.navigateToMyVideos() |
247 | ||
bbe078ba | 248 | await myAccountPage.removeVideo(video2Name) |
e69cb173 C |
249 | await myAccountPage.validRemove() |
250 | ||
bbe078ba | 251 | const count = await myAccountPage.countVideos([ videoName, video2Name ]) |
e69cb173 C |
252 | expect(count).toEqual(1) |
253 | }) | |
254 | ||
255 | it('Should delete the first video', async () => { | |
256 | if (await skipIfUploadNotSupported()) return | |
257 | ||
bbe078ba | 258 | await myAccountPage.removeVideo(videoName) |
e69cb173 | 259 | await myAccountPage.validRemove() |
e69cb173 | 260 | }) |
5f92c4dc | 261 | }) |