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