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