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