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