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