]>
Commit | Line | Data |
---|---|---|
5f92c4dc C |
1 | import { VideoWatchPage } from './po/video-watch.po' |
2 | import { VideoUploadPage } from './po/video-upload.po' | |
3 | import { LoginPage } from './po/login.po' | |
4 | import { browser } from 'protractor' | |
e69cb173 C |
5 | import { VideoUpdatePage } from './po/video-update.po' |
6 | import { MyAccountPage } from './po/my-account' | |
7 | ||
8 | async function skipIfUploadNotSupported () { | |
9 | if (await isMobileDevice() || await isSafari()) { | |
10 | console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') | |
11 | return true | |
12 | } | |
13 | ||
14 | return false | |
15 | } | |
16 | ||
17 | async function isMobileDevice () { | |
18 | const caps = await browser.getCapabilities() | |
19 | return caps.get('realMobile') === 'true' || caps.get('realMobile') === true | |
20 | } | |
21 | ||
22 | async function isSafari () { | |
23 | const caps = await browser.getCapabilities() | |
24 | return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari' | |
25 | } | |
5f92c4dc C |
26 | |
27 | describe('Videos workflow', () => { | |
28 | let videoWatchPage: VideoWatchPage | |
e69cb173 C |
29 | let videoUploadPage: VideoUploadPage |
30 | let videoUpdatePage: VideoUpdatePage | |
31 | let myAccountPage: MyAccountPage | |
5f92c4dc | 32 | let loginPage: LoginPage |
e69cb173 | 33 | |
5f92c4dc | 34 | const videoName = new Date().getTime() + ' video' |
e69cb173 | 35 | let videoWatchUrl: string |
0b33c520 C |
36 | |
37 | beforeEach(async () => { | |
5f92c4dc | 38 | videoWatchPage = new VideoWatchPage() |
e69cb173 C |
39 | videoUploadPage = new VideoUploadPage() |
40 | videoUpdatePage = new VideoUpdatePage() | |
41 | myAccountPage = new MyAccountPage() | |
5f92c4dc | 42 | loginPage = new LoginPage() |
0b33c520 | 43 | |
e69cb173 | 44 | if (await isMobileDevice()) { |
84c7cde6 C |
45 | console.log('Mobile device detected.') |
46 | } | |
47 | ||
e69cb173 | 48 | if (await isSafari()) { |
84c7cde6 C |
49 | console.log('Safari detected.') |
50 | } | |
5f92c4dc C |
51 | }) |
52 | ||
e69cb173 C |
53 | it('Should log in', async () => { |
54 | if (await isMobileDevice() || await isSafari()) { | |
1fad099d | 55 | console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') |
0b33c520 C |
56 | return |
57 | } | |
58 | ||
5f92c4dc C |
59 | return loginPage.loginAsRootUser() |
60 | }) | |
61 | ||
62 | it('Should upload a video', async () => { | |
e69cb173 | 63 | if (await skipIfUploadNotSupported()) return |
0b33c520 | 64 | |
e69cb173 | 65 | await videoUploadPage.navigateTo() |
5f92c4dc | 66 | |
e69cb173 C |
67 | await videoUploadPage.uploadVideo() |
68 | return videoUploadPage.validSecondUploadStep(videoName) | |
5f92c4dc C |
69 | }) |
70 | ||
ac043122 | 71 | it('Should list videos', async () => { |
e69cb173 | 72 | await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari()) |
0b33c520 | 73 | |
e69cb173 | 74 | if (await skipIfUploadNotSupported()) return |
5f92c4dc C |
75 | |
76 | const videoNames = videoWatchPage.getVideosListName() | |
77 | expect(videoNames).toContain(videoName) | |
78 | }) | |
79 | ||
80 | it('Should go on video watch page', async () => { | |
0b33c520 C |
81 | let videoNameToExcept = videoName |
82 | ||
e69cb173 | 83 | if (await isMobileDevice() || await isSafari()) videoNameToExcept = await videoWatchPage.clickOnFirstVideo() |
0b33c520 | 84 | else await videoWatchPage.clickOnVideo(videoName) |
5f92c4dc | 85 | |
e69cb173 | 86 | return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari()) |
5f92c4dc C |
87 | }) |
88 | ||
89 | it('Should play the video', async () => { | |
e69cb173 C |
90 | videoWatchUrl = await browser.getCurrentUrl() |
91 | ||
92 | await videoWatchPage.playAndPauseVideo(true, await isMobileDevice()) | |
d1bd87e0 C |
93 | expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) |
94 | }) | |
95 | ||
96 | it('Should watch the associated embed video', async () => { | |
84c7cde6 C |
97 | await browser.waitForAngularEnabled(false) |
98 | ||
d1bd87e0 C |
99 | await videoWatchPage.goOnAssociatedEmbed() |
100 | ||
e69cb173 | 101 | await videoWatchPage.playAndPauseVideo(false, await isMobileDevice()) |
5f92c4dc | 102 | expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) |
84c7cde6 C |
103 | |
104 | await browser.waitForAngularEnabled(true) | |
105 | }) | |
106 | ||
107 | it('Should watch the p2p media loader embed video', async () => { | |
108 | await browser.waitForAngularEnabled(false) | |
109 | ||
110 | await videoWatchPage.goOnP2PMediaLoaderEmbed() | |
111 | ||
e69cb173 | 112 | await videoWatchPage.playAndPauseVideo(false, await isMobileDevice()) |
84c7cde6 C |
113 | expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) |
114 | ||
115 | await browser.waitForAngularEnabled(true) | |
5f92c4dc | 116 | }) |
e69cb173 C |
117 | |
118 | it('Should update the video', async () => { | |
119 | if (await skipIfUploadNotSupported()) return | |
120 | ||
121 | await browser.get(videoWatchUrl) | |
122 | ||
123 | await videoWatchPage.clickOnUpdate() | |
124 | ||
125 | await videoUpdatePage.updateName('my new name') | |
126 | ||
127 | await videoUpdatePage.validUpdate() | |
128 | ||
129 | const name = await videoWatchPage.getVideoName() | |
130 | expect(name).toEqual('my new name') | |
131 | }) | |
132 | ||
133 | it('Should add the video in my playlist', async () => { | |
134 | if (await skipIfUploadNotSupported()) return | |
135 | ||
136 | await videoWatchPage.clickOnSave() | |
137 | await videoWatchPage.saveToWatchLater() | |
138 | ||
139 | await videoUploadPage.navigateTo() | |
140 | ||
141 | await videoUploadPage.uploadVideo() | |
142 | await videoUploadPage.validSecondUploadStep('second video') | |
143 | ||
144 | await videoWatchPage.clickOnSave() | |
145 | await videoWatchPage.saveToWatchLater() | |
146 | }) | |
147 | ||
148 | it('Should have the watch later playlist in my account', async () => { | |
149 | if (await skipIfUploadNotSupported()) return | |
150 | ||
151 | await myAccountPage.navigateToMyPlaylists() | |
152 | ||
153 | const name = await myAccountPage.getLastUpdatedPlaylistName() | |
154 | expect(name).toEqual('Watch later') | |
155 | ||
156 | const videosNumberText = await myAccountPage.getLastUpdatedPlaylistVideosText() | |
157 | expect(videosNumberText).toEqual('2 videos') | |
158 | ||
159 | await myAccountPage.clickOnLastUpdatedPlaylist() | |
160 | ||
161 | const count = await myAccountPage.countTotalPlaylistElements() | |
162 | expect(count).toEqual(2) | |
163 | }) | |
164 | ||
165 | it('Should watch the playlist', async () => { | |
166 | if (await skipIfUploadNotSupported()) return | |
167 | ||
168 | await myAccountPage.playPlaylist() | |
169 | ||
170 | await videoWatchPage.waitUntilVideoName('second video', 20000 * 1000) | |
171 | }) | |
172 | ||
173 | it('Should have the video in my account', async () => { | |
174 | if (await skipIfUploadNotSupported()) return | |
175 | ||
176 | await myAccountPage.navigateToMyVideos() | |
177 | ||
178 | const lastVideoName = await myAccountPage.getLastVideoName() | |
179 | expect(lastVideoName).toEqual('second video') | |
180 | }) | |
181 | ||
182 | it('Should delete the last video', async () => { | |
183 | if (await skipIfUploadNotSupported()) return | |
184 | ||
185 | await myAccountPage.removeLastVideo() | |
186 | await myAccountPage.validRemove() | |
187 | ||
188 | const count = await myAccountPage.countVideos() | |
189 | expect(count).toEqual(1) | |
190 | }) | |
191 | ||
192 | it('Should delete the first video', async () => { | |
193 | if (await skipIfUploadNotSupported()) return | |
194 | ||
195 | await myAccountPage.removeLastVideo() | |
196 | await myAccountPage.validRemove() | |
197 | ||
198 | const count = await myAccountPage.countVideos() | |
199 | expect(count).toEqual(0) | |
200 | }) | |
5f92c4dc | 201 | }) |