]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/videos.e2e-spec.ts
Fix browserstack badge
[github/Chocobozzz/PeerTube.git] / client / e2e / src / videos.e2e-spec.ts
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 if (!await isMobileDevice()) {
58 await browser.driver.manage().window().maximize()
59 }
60 })
61
62 it('Should log in', async () => {
63 if (await isMobileDevice() || await isSafari()) {
64 console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.')
65 return
66 }
67
68 return loginPage.loginAsRootUser()
69 })
70
71 it('Should close the welcome modal', async () => {
72 if (await skipIfUploadNotSupported()) return
73
74 await appPage.closeWelcomeModal()
75 })
76
77 it('Should upload a video', async () => {
78 if (await skipIfUploadNotSupported()) return
79
80 await videoUploadPage.navigateTo()
81
82 await videoUploadPage.uploadVideo()
83 return videoUploadPage.validSecondUploadStep(videoName)
84 })
85
86 it('Should list videos', async () => {
87 await videoWatchPage.goOnVideosList(await isMobileDevice(), await isSafari())
88
89 if (await skipIfUploadNotSupported()) return
90
91 const videoNames = videoWatchPage.getVideosListName()
92 expect(videoNames).toContain(videoName)
93 })
94
95 it('Should go on video watch page', async () => {
96 let videoNameToExcept = videoName
97
98 if (await isMobileDevice() || await isSafari()) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
99 else await videoWatchPage.clickOnVideo(videoName)
100
101 return videoWatchPage.waitWatchVideoName(videoNameToExcept, await isMobileDevice(), await isSafari())
102 })
103
104 it('Should play the video', async () => {
105 videoWatchUrl = await browser.getCurrentUrl()
106
107 await videoWatchPage.playAndPauseVideo(true, await isMobileDevice())
108 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
109 })
110
111 it('Should watch the associated embed video', async () => {
112 await browser.waitForAngularEnabled(false)
113
114 await videoWatchPage.goOnAssociatedEmbed()
115
116 await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
117 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
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
127 await videoWatchPage.playAndPauseVideo(false, await isMobileDevice())
128 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
129
130 await browser.waitForAngularEnabled(true)
131 })
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
140 videoName += ' updated'
141 await videoUpdatePage.updateName(videoName)
142
143 await videoUpdatePage.validUpdate()
144
145 const name = await videoWatchPage.getVideoName()
146 expect(name).toEqual(videoName)
147 })
148
149 it('Should add the video in my playlist', async () => {
150 if (await skipIfUploadNotSupported()) return
151
152 await videoWatchPage.clickOnSave()
153
154 await videoWatchPage.createPlaylist(playlistName)
155
156 await videoWatchPage.saveToPlaylist(playlistName)
157
158 await videoUploadPage.navigateTo()
159
160 await videoUploadPage.uploadVideo()
161 await videoUploadPage.validSecondUploadStep(video2Name)
162
163 await videoWatchPage.clickOnSave()
164 await videoWatchPage.saveToPlaylist(playlistName)
165 })
166
167 it('Should have the playlist in my account', async () => {
168 if (await skipIfUploadNotSupported()) return
169
170 await myAccountPage.navigateToMyPlaylists()
171
172 const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
173 expect(videosNumberText).toEqual('2 videos')
174
175 await myAccountPage.clickOnPlaylist(playlistName)
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
186 await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
187 })
188
189 it('Should delete the video 2', async () => {
190 if (await skipIfUploadNotSupported()) return
191
192 await myAccountPage.navigateToMyVideos()
193
194 await myAccountPage.removeVideo(video2Name)
195 await myAccountPage.validRemove()
196
197 const count = await myAccountPage.countVideos([ videoName, video2Name ])
198 expect(count).toEqual(1)
199 })
200
201 it('Should delete the first video', async () => {
202 if (await skipIfUploadNotSupported()) return
203
204 await myAccountPage.removeVideo(videoName)
205 await myAccountPage.validRemove()
206 })
207 })