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