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