]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/videos.e2e-spec.ts
75fa89e28854cbd9e6924a371a41d93827384e10
[github/Chocobozzz/PeerTube.git] / client / e2e / src / videos.e2e-spec.ts
1 import { browser } from 'protractor'
2 import { AppPage } from './po/app.po'
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'
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
19 describe('Videos workflow', () => {
20 let videoWatchPage: VideoWatchPage
21 let videoUploadPage: VideoUploadPage
22 let videoUpdatePage: VideoUpdatePage
23 let myAccountPage: MyAccountPage
24 let loginPage: LoginPage
25 let appPage: AppPage
26
27 let videoName = new Date().getTime() + ' video'
28 const video2Name = new Date().getTime() + ' second video'
29 const playlistName = new Date().getTime() + ' playlist'
30 let videoWatchUrl: string
31
32 beforeEach(async () => {
33 videoWatchPage = new VideoWatchPage()
34 videoUploadPage = new VideoUploadPage()
35 videoUpdatePage = new VideoUpdatePage()
36 myAccountPage = new MyAccountPage()
37 loginPage = new LoginPage()
38 appPage = new AppPage()
39
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
44
45 console.log('iOS detected')
46 } else if (await isMobileDevice()) {
47 console.log('Android detected.')
48 } else if (await isSafari()) {
49 console.log('Safari detected.')
50 }
51
52 if (!await isMobileDevice()) {
53 await browser.driver.manage().window().maximize()
54 }
55 })
56
57 it('Should log in', async () => {
58 if (await isMobileDevice() || await isSafari()) {
59 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
60 return
61 }
62
63 return loginPage.loginAsRootUser()
64 })
65
66 it('Should close the welcome modal', async () => {
67 if (await skipIfUploadNotSupported()) return
68
69 await appPage.closeWelcomeModal()
70 })
71
72 it('Should upload a video', async () => {
73 if (await skipIfUploadNotSupported()) return
74
75 await videoUploadPage.navigateTo()
76
77 await videoUploadPage.uploadVideo()
78 return videoUploadPage.validSecondUploadStep(videoName)
79 })
80
81 it('Should list videos', async () => {
82 await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari())
83
84 if (await skipIfUploadNotSupported()) return
85
86 const videoNames = videoWatchPage.getVideosListName()
87 expect(videoNames).toContain(videoName)
88 })
89
90 it('Should go on video watch page', async () => {
91 let videoNameToExcept = videoName
92
93 if (await isMobileDevice() || await isSafari()) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
94 else await videoWatchPage.clickOnVideo(videoName)
95
96 return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari())
97 })
98
99 it('Should play the video', async () => {
100 videoWatchUrl = await browser.getCurrentUrl()
101
102 await videoWatchPage.playAndPauseVideo(true)
103 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
104 })
105
106 it('Should watch the associated embed video', async () => {
107 await browser.waitForAngularEnabled(false)
108
109 await videoWatchPage.goOnAssociatedEmbed()
110
111 await videoWatchPage.playAndPauseVideo(false)
112 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
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
122 await videoWatchPage.playAndPauseVideo(false)
123 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
124
125 await browser.waitForAngularEnabled(true)
126 })
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
135 videoName += ' updated'
136 await videoUpdatePage.updateName(videoName)
137
138 await videoUpdatePage.validUpdate()
139
140 const name = await videoWatchPage.getVideoName()
141 expect(name).toEqual(videoName)
142 })
143
144 it('Should add the video in my playlist', async () => {
145 if (await skipIfUploadNotSupported()) return
146
147 await videoWatchPage.clickOnSave()
148
149 await videoWatchPage.createPlaylist(playlistName)
150
151 await videoWatchPage.saveToPlaylist(playlistName)
152
153 await videoUploadPage.navigateTo()
154
155 await videoUploadPage.uploadVideo()
156 await videoUploadPage.validSecondUploadStep(video2Name)
157
158 await videoWatchPage.clickOnSave()
159 await videoWatchPage.saveToPlaylist(playlistName)
160 })
161
162 it('Should have the playlist in my account', async () => {
163 if (await skipIfUploadNotSupported()) return
164
165 await myAccountPage.navigateToMyPlaylists()
166
167 const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
168 expect(videosNumberText).toEqual('2 videos')
169
170 await myAccountPage.clickOnPlaylist(playlistName)
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
181 await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
182 })
183
184 it('Should watch the webtorrent playlist in the embed', async () => {
185 if (await skipIfUploadNotSupported()) return
186
187 await browser.waitForAngularEnabled(false)
188
189 await myAccountPage.goOnAssociatedPlaylistEmbed()
190
191 await videoWatchPage.playAndPauseVideo(false)
192
193 await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
194
195 await browser.waitForAngularEnabled(true)
196 })
197
198 it('Should delete the video 2', async () => {
199 if (await skipIfUploadNotSupported()) return
200
201 await myAccountPage.navigateToMyVideos()
202
203 await myAccountPage.removeVideo(video2Name)
204 await myAccountPage.validRemove()
205
206 const count = await myAccountPage.countVideos([ videoName, video2Name ])
207 expect(count).toEqual(1)
208 })
209
210 it('Should delete the first video', async () => {
211 if (await skipIfUploadNotSupported()) return
212
213 await myAccountPage.removeVideo(videoName)
214 await myAccountPage.validRemove()
215 })
216 })