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