]>
Commit | Line | Data |
---|---|---|
6d210220 C |
1 | import { AdminConfigPage } from '../po/admin-config.po' |
2 | import { LoginPage } from '../po/login.po' | |
3 | import { MyAccountPage } from '../po/my-account' | |
4 | import { VideoListPage } from '../po/video-list.po' | |
5 | import { VideoSearchPage } from '../po/video-search.po' | |
6 | import { VideoUploadPage } from '../po/video-upload.po' | |
3cf68b86 | 7 | import { VideoWatchPage } from '../po/video-watch.po' |
6d210220 C |
8 | import { NSFWPolicy } from '../types/common' |
9 | import { isMobileDevice, isSafari, waitServerUp } from '../utils' | |
10 | ||
11 | describe('Videos list', () => { | |
12 | let videoListPage: VideoListPage | |
13 | let videoUploadPage: VideoUploadPage | |
14 | let adminConfigPage: AdminConfigPage | |
15 | let loginPage: LoginPage | |
16 | let myAccountPage: MyAccountPage | |
17 | let videoSearchPage: VideoSearchPage | |
3cf68b86 | 18 | let videoWatchPage: VideoWatchPage |
6d210220 C |
19 | |
20 | const seed = Math.random() | |
21 | const nsfwVideo = seed + ' - nsfw' | |
22 | const normalVideo = seed + ' - normal' | |
23 | ||
24 | async function checkNormalVideo () { | |
25 | expect(await videoListPage.videoExists(normalVideo)).toBeTruthy() | |
26 | expect(await videoListPage.videoIsBlurred(normalVideo)).toBeFalsy() | |
27 | } | |
28 | ||
29 | async function checkNSFWVideo (policy: NSFWPolicy, filterText?: string) { | |
30 | if (policy === 'do_not_list') { | |
31 | if (filterText) expect(filterText).toContain('hidden') | |
32 | ||
33 | expect(await videoListPage.videoExists(nsfwVideo)).toBeFalsy() | |
34 | return | |
35 | } | |
36 | ||
37 | if (policy === 'blur') { | |
38 | if (filterText) expect(filterText).toContain('blurred') | |
39 | ||
40 | expect(await videoListPage.videoExists(nsfwVideo)).toBeTruthy() | |
41 | expect(await videoListPage.videoIsBlurred(nsfwVideo)).toBeTruthy() | |
42 | return | |
43 | } | |
44 | ||
45 | // display | |
46 | if (filterText) expect(filterText).toContain('displayed') | |
47 | ||
48 | expect(await videoListPage.videoExists(nsfwVideo)).toBeTruthy() | |
49 | expect(await videoListPage.videoIsBlurred(nsfwVideo)).toBeFalsy() | |
50 | } | |
51 | ||
52 | async function checkCommonVideoListPages (policy: NSFWPolicy) { | |
53 | const promisesWithFilters = [ | |
54 | videoListPage.goOnRootAccount, | |
55 | videoListPage.goOnLocal, | |
56 | videoListPage.goOnRecentlyAdded, | |
57 | videoListPage.goOnTrending, | |
58 | videoListPage.goOnRootChannel | |
59 | ] | |
60 | ||
61 | for (const p of promisesWithFilters) { | |
62 | await p.call(videoListPage) | |
63 | ||
64 | const filter = await videoListPage.getNSFWFilter() | |
65 | const filterText = await filter.getText() | |
66 | ||
67 | await checkNormalVideo() | |
68 | await checkNSFWVideo(policy, filterText) | |
69 | } | |
70 | ||
71 | const promisesWithoutFilters = [ | |
72 | videoListPage.goOnRootAccountChannels, | |
73 | videoListPage.goOnHomepage | |
74 | ] | |
75 | for (const p of promisesWithoutFilters) { | |
76 | await p.call(videoListPage) | |
77 | ||
78 | await checkNormalVideo() | |
79 | await checkNSFWVideo(policy) | |
80 | } | |
81 | } | |
82 | ||
83 | async function checkSearchPage (policy: NSFWPolicy) { | |
84 | await videoSearchPage.search(normalVideo) | |
85 | await checkNormalVideo() | |
86 | ||
87 | await videoSearchPage.search(nsfwVideo) | |
88 | await checkNSFWVideo(policy) | |
89 | } | |
90 | ||
91 | async function updateAdminNSFW (nsfw: NSFWPolicy) { | |
92 | await adminConfigPage.navigateTo('instance-information') | |
93 | await adminConfigPage.updateNSFWSetting(nsfw) | |
94 | await adminConfigPage.save() | |
95 | } | |
96 | ||
97 | async function updateUserNSFW (nsfw: NSFWPolicy) { | |
98 | await myAccountPage.navigateToMySettings() | |
99 | await myAccountPage.updateNSFW(nsfw) | |
100 | } | |
101 | ||
102 | before(async () => { | |
103 | await waitServerUp() | |
104 | }) | |
105 | ||
106 | beforeEach(async () => { | |
107 | videoListPage = new VideoListPage(isMobileDevice(), isSafari()) | |
108 | adminConfigPage = new AdminConfigPage() | |
109 | loginPage = new LoginPage() | |
110 | videoUploadPage = new VideoUploadPage() | |
111 | myAccountPage = new MyAccountPage() | |
112 | videoSearchPage = new VideoSearchPage() | |
3cf68b86 | 113 | videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari()) |
6d210220 C |
114 | |
115 | await browser.maximizeWindow() | |
116 | }) | |
117 | ||
118 | it('Should login and disable NSFW', async () => { | |
119 | await loginPage.loginAsRootUser() | |
120 | await updateUserNSFW('display') | |
121 | }) | |
122 | ||
123 | it('Should set the homepage', async () => { | |
124 | await adminConfigPage.navigateTo('instance-homepage') | |
125 | await adminConfigPage.updateHomepage('<peertube-videos-list data-sort="-publishedAt"></peertube-videos-list>') | |
126 | await adminConfigPage.save() | |
127 | }) | |
128 | ||
129 | it('Should upload 2 videos (NSFW and classic videos)', async () => { | |
130 | await videoUploadPage.navigateTo() | |
131 | await videoUploadPage.uploadVideo() | |
132 | await videoUploadPage.setAsNSFW() | |
133 | await videoUploadPage.validSecondUploadStep(nsfwVideo) | |
134 | ||
135 | await videoUploadPage.navigateTo() | |
136 | await videoUploadPage.uploadVideo() | |
137 | await videoUploadPage.validSecondUploadStep(normalVideo) | |
138 | }) | |
139 | ||
140 | it('Should logout', async function () { | |
141 | await loginPage.logout() | |
142 | }) | |
143 | ||
144 | describe('Anonymous users', function () { | |
145 | ||
146 | it('Should correctly handle do not list', async () => { | |
147 | await loginPage.loginAsRootUser() | |
148 | await updateAdminNSFW('do_not_list') | |
149 | ||
150 | await loginPage.logout() | |
151 | await checkCommonVideoListPages('do_not_list') | |
152 | await checkSearchPage('do_not_list') | |
153 | }) | |
154 | ||
155 | it('Should correctly handle blur', async () => { | |
156 | await loginPage.loginAsRootUser() | |
157 | await updateAdminNSFW('blur') | |
158 | ||
159 | await loginPage.logout() | |
160 | await checkCommonVideoListPages('blur') | |
161 | await checkSearchPage('blur') | |
162 | }) | |
163 | ||
164 | it('Should correctly handle display', async () => { | |
165 | await loginPage.loginAsRootUser() | |
166 | await updateAdminNSFW('display') | |
167 | ||
168 | await loginPage.logout() | |
169 | await checkCommonVideoListPages('display') | |
170 | await checkSearchPage('display') | |
171 | }) | |
172 | }) | |
173 | ||
174 | describe('Logged in users', function () { | |
175 | ||
176 | before(async () => { | |
177 | await loginPage.loginAsRootUser() | |
178 | }) | |
179 | ||
180 | it('Should correctly handle do not list', async () => { | |
181 | await updateUserNSFW('do_not_list') | |
182 | await checkCommonVideoListPages('do_not_list') | |
183 | await checkSearchPage('do_not_list') | |
184 | }) | |
185 | ||
186 | it('Should correctly handle blur', async () => { | |
187 | await updateUserNSFW('blur') | |
188 | await checkCommonVideoListPages('blur') | |
189 | await checkSearchPage('blur') | |
190 | }) | |
191 | ||
192 | it('Should correctly handle display', async () => { | |
193 | await updateUserNSFW('display') | |
194 | await checkCommonVideoListPages('display') | |
195 | await checkSearchPage('display') | |
196 | }) | |
3cf68b86 C |
197 | |
198 | after(async () => { | |
199 | await loginPage.logout() | |
200 | }) | |
201 | }) | |
202 | ||
203 | describe('Default upload values', function () { | |
204 | ||
205 | it('Should have default video values', async function () { | |
206 | await loginPage.loginAsRootUser() | |
207 | await videoUploadPage.navigateTo() | |
208 | await videoUploadPage.uploadVideo() | |
209 | await videoUploadPage.validSecondUploadStep('video') | |
210 | ||
211 | await videoWatchPage.waitWatchVideoName('video') | |
212 | ||
213 | expect(await videoWatchPage.getPrivacy()).toBe('Public') | |
214 | expect(await videoWatchPage.getLicence()).toBe('Unknown') | |
215 | expect(await videoWatchPage.isDownloadEnabled()).toBeTruthy() | |
216 | expect(await videoWatchPage.areCommentsEnabled()).toBeTruthy() | |
217 | }) | |
6d210220 C |
218 | }) |
219 | }) |