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