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