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