diff options
author | Wicklow <123956049+wickloww@users.noreply.github.com> | 2023-07-17 09:31:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 11:31:42 +0200 |
commit | cbe06f779f485935b227ccbb48a4493e4acda725 (patch) | |
tree | 93556507650a20ee544e1eb0a51588318156732f /client/e2e/src/suites-local | |
parent | 260242decdd740bfee8b9f7c9536d98a6a951bcf (diff) | |
download | PeerTube-cbe06f779f485935b227ccbb48a4493e4acda725.tar.gz PeerTube-cbe06f779f485935b227ccbb48a4493e4acda725.tar.zst PeerTube-cbe06f779f485935b227ccbb48a4493e4acda725.zip |
Add e2e tests for password protected videos (#5860)
Diffstat (limited to 'client/e2e/src/suites-local')
-rw-r--r-- | client/e2e/src/suites-local/video-password.e2e-spec.ts | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/client/e2e/src/suites-local/video-password.e2e-spec.ts b/client/e2e/src/suites-local/video-password.e2e-spec.ts new file mode 100644 index 000000000..f4d836c05 --- /dev/null +++ b/client/e2e/src/suites-local/video-password.e2e-spec.ts | |||
@@ -0,0 +1,226 @@ | |||
1 | import { LoginPage } from '../po/login.po' | ||
2 | import { SignupPage } from '../po/signup.po' | ||
3 | import { PlayerPage } from '../po/player.po' | ||
4 | import { VideoUploadPage } from '../po/video-upload.po' | ||
5 | import { VideoWatchPage } from '../po/video-watch.po' | ||
6 | import { go, isMobileDevice, isSafari, waitServerUp } from '../utils' | ||
7 | import { MyAccountPage } from '../po/my-account.po' | ||
8 | |||
9 | describe('Password protected videos', () => { | ||
10 | let videoUploadPage: VideoUploadPage | ||
11 | let loginPage: LoginPage | ||
12 | let videoWatchPage: VideoWatchPage | ||
13 | let signupPage: SignupPage | ||
14 | let playerPage: PlayerPage | ||
15 | let myAccountPage: MyAccountPage | ||
16 | let passwordProtectedVideoUrl: string | ||
17 | let playlistUrl: string | ||
18 | |||
19 | const seed = Math.random() | ||
20 | const passwordProtectedVideoName = seed + ' - password protected' | ||
21 | const publicVideoName1 = seed + ' - public 1' | ||
22 | const publicVideoName2 = seed + ' - public 2' | ||
23 | const videoPassword = 'password' | ||
24 | const regularUsername = 'user_1' | ||
25 | const regularUserPassword = 'user password' | ||
26 | const playlistName = seed + ' - playlist' | ||
27 | |||
28 | function testRateAndComment () { | ||
29 | it('Should add and remove like on video', async function () { | ||
30 | await videoWatchPage.like() | ||
31 | await videoWatchPage.like() | ||
32 | }) | ||
33 | |||
34 | it('Should create thread on video', async function () { | ||
35 | await videoWatchPage.createThread('My first comment') | ||
36 | }) | ||
37 | |||
38 | it('Should reply to thread on video', async function () { | ||
39 | await videoWatchPage.createReply('My first reply') | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | before(async () => { | ||
44 | await waitServerUp() | ||
45 | }) | ||
46 | |||
47 | beforeEach(async () => { | ||
48 | loginPage = new LoginPage(isMobileDevice()) | ||
49 | videoUploadPage = new VideoUploadPage() | ||
50 | videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari()) | ||
51 | signupPage = new SignupPage() | ||
52 | playerPage = new PlayerPage() | ||
53 | myAccountPage = new MyAccountPage() | ||
54 | |||
55 | await browser.maximizeWindow() | ||
56 | }) | ||
57 | |||
58 | describe('Owner', function () { | ||
59 | before(async () => { | ||
60 | await loginPage.loginAsRootUser() | ||
61 | }) | ||
62 | |||
63 | it('Should login, upload a public video and save it to a playlist', async () => { | ||
64 | await videoUploadPage.navigateTo() | ||
65 | await videoUploadPage.uploadVideo('video.mp4') | ||
66 | await videoUploadPage.validSecondUploadStep(publicVideoName1) | ||
67 | |||
68 | await videoWatchPage.clickOnSave() | ||
69 | |||
70 | await videoWatchPage.createPlaylist(playlistName) | ||
71 | |||
72 | await videoWatchPage.saveToPlaylist(playlistName) | ||
73 | await browser.pause(5000) | ||
74 | |||
75 | }) | ||
76 | |||
77 | it('Should upload a password protected video', async () => { | ||
78 | await videoUploadPage.navigateTo() | ||
79 | await videoUploadPage.uploadVideo('video2.mp4') | ||
80 | await videoUploadPage.setAsPasswordProtected(videoPassword) | ||
81 | await videoUploadPage.validSecondUploadStep(passwordProtectedVideoName) | ||
82 | |||
83 | await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName) | ||
84 | |||
85 | passwordProtectedVideoUrl = await browser.getUrl() | ||
86 | }) | ||
87 | |||
88 | it('Should save to playlist the password protected video', async () => { | ||
89 | await videoWatchPage.clickOnSave() | ||
90 | await videoWatchPage.saveToPlaylist(playlistName) | ||
91 | }) | ||
92 | |||
93 | it('Should upload a second public video and save it to playlist', async () => { | ||
94 | await videoUploadPage.navigateTo() | ||
95 | |||
96 | await videoUploadPage.uploadVideo('video3.mp4') | ||
97 | await videoUploadPage.validSecondUploadStep(publicVideoName2) | ||
98 | |||
99 | await videoWatchPage.clickOnSave() | ||
100 | await videoWatchPage.saveToPlaylist(playlistName) | ||
101 | }) | ||
102 | |||
103 | it('Should play video without password', async function () { | ||
104 | await go(passwordProtectedVideoUrl) | ||
105 | |||
106 | expect(!await videoWatchPage.isPasswordProtected()) | ||
107 | |||
108 | await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName) | ||
109 | |||
110 | expect(await videoWatchPage.getPrivacy()).toBe('Password protected') | ||
111 | await playerPage.playAndPauseVideo(false, 2) | ||
112 | }) | ||
113 | |||
114 | testRateAndComment() | ||
115 | |||
116 | it('Should play video on embed without password', async function () { | ||
117 | await videoWatchPage.goOnAssociatedEmbed() | ||
118 | await playerPage.playAndPauseVideo(false, 2) | ||
119 | }) | ||
120 | |||
121 | it('Should have the playlist in my account', async function () { | ||
122 | await go('/') | ||
123 | await myAccountPage.navigateToMyPlaylists() | ||
124 | const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName) | ||
125 | |||
126 | expect(videosNumberText).toEqual('3 videos') | ||
127 | await myAccountPage.clickOnPlaylist(playlistName) | ||
128 | |||
129 | const count = await myAccountPage.countTotalPlaylistElements() | ||
130 | expect(count).toEqual(3) | ||
131 | }) | ||
132 | |||
133 | it('Should update the playlist to public', async () => { | ||
134 | const url = await browser.getUrl() | ||
135 | const regex = /\/([a-f0-9-]+)$/i | ||
136 | const match = url.match(regex) | ||
137 | const uuid = match ? match[1] : null | ||
138 | |||
139 | await myAccountPage.updatePlaylistPrivacy(uuid, 'Public') | ||
140 | }) | ||
141 | |||
142 | it('Should watch the playlist', async () => { | ||
143 | await myAccountPage.clickOnPlaylist(playlistName) | ||
144 | await myAccountPage.playPlaylist() | ||
145 | playlistUrl = await browser.getUrl() | ||
146 | |||
147 | await videoWatchPage.waitUntilVideoName(publicVideoName1, 40 * 1000) | ||
148 | await videoWatchPage.waitUntilVideoName(passwordProtectedVideoName, 40 * 1000) | ||
149 | await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000) | ||
150 | }) | ||
151 | |||
152 | after(async () => { | ||
153 | await loginPage.logout() | ||
154 | }) | ||
155 | }) | ||
156 | |||
157 | describe('Regular users', function () { | ||
158 | before(async () => { | ||
159 | await signupPage.fullSignup({ | ||
160 | accountInfo: { | ||
161 | username: regularUsername, | ||
162 | password: regularUserPassword | ||
163 | }, | ||
164 | channelInfo: { | ||
165 | name: 'user_1_channel' | ||
166 | } | ||
167 | }) | ||
168 | }) | ||
169 | |||
170 | it('Should requires password to play video', async function () { | ||
171 | await go(passwordProtectedVideoUrl) | ||
172 | |||
173 | expect(await videoWatchPage.isPasswordProtected()) | ||
174 | |||
175 | await videoWatchPage.fillVideoPassword(videoPassword) | ||
176 | await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName) | ||
177 | |||
178 | expect(await videoWatchPage.getPrivacy()).toBe('Password protected') | ||
179 | await playerPage.playAndPauseVideo(true, 2) | ||
180 | }) | ||
181 | |||
182 | testRateAndComment() | ||
183 | |||
184 | it('Should requires password to play video on embed', async function () { | ||
185 | await videoWatchPage.goOnAssociatedEmbed(true) | ||
186 | await playerPage.fillEmbedVideoPassword(videoPassword) | ||
187 | await playerPage.playAndPauseVideo(false, 2) | ||
188 | }) | ||
189 | |||
190 | it('Should watch the playlist without password protected video', async () => { | ||
191 | await go(playlistUrl) | ||
192 | await playerPage.playVideo() | ||
193 | await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000) | ||
194 | }) | ||
195 | |||
196 | after(async () => { | ||
197 | await loginPage.logout() | ||
198 | }) | ||
199 | }) | ||
200 | |||
201 | describe('Anonymous users', function () { | ||
202 | it('Should requires password to play video', async function () { | ||
203 | await go(passwordProtectedVideoUrl) | ||
204 | |||
205 | expect(await videoWatchPage.isPasswordProtected()) | ||
206 | |||
207 | await videoWatchPage.fillVideoPassword(videoPassword) | ||
208 | await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName) | ||
209 | |||
210 | expect(await videoWatchPage.getPrivacy()).toBe('Password protected') | ||
211 | await playerPage.playAndPauseVideo(true, 2) | ||
212 | }) | ||
213 | |||
214 | it('Should requires password to play video on embed', async function () { | ||
215 | await videoWatchPage.goOnAssociatedEmbed(true) | ||
216 | await playerPage.fillEmbedVideoPassword(videoPassword) | ||
217 | await playerPage.playAndPauseVideo(false, 2) | ||
218 | }) | ||
219 | |||
220 | it('Should watch the playlist without password protected video', async () => { | ||
221 | await go(playlistUrl) | ||
222 | await playerPage.playVideo() | ||
223 | await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000) | ||
224 | }) | ||
225 | }) | ||
226 | }) | ||