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