diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-03 10:27:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-03 16:35:18 +0200 |
commit | 6d210220be0875d63461829d83c6e3a59d05cf7a (patch) | |
tree | 60ec5b596ef06295b70ebb553920a39b549e0f13 /client/e2e/src/po | |
parent | 2ede07153ce0282b116345dfee09bff902355a75 (diff) | |
download | PeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.tar.gz PeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.tar.zst PeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.zip |
Fix NSFW filter and add tests
Diffstat (limited to 'client/e2e/src/po')
-rw-r--r-- | client/e2e/src/po/admin-config.po.ts | 29 | ||||
-rw-r--r-- | client/e2e/src/po/login.po.ts | 20 | ||||
-rw-r--r-- | client/e2e/src/po/my-account.ts | 18 | ||||
-rw-r--r-- | client/e2e/src/po/player.po.ts | 5 | ||||
-rw-r--r-- | client/e2e/src/po/video-list.po.ts | 128 | ||||
-rw-r--r-- | client/e2e/src/po/video-search.po.ts | 11 | ||||
-rw-r--r-- | client/e2e/src/po/video-upload.po.ts | 5 | ||||
-rw-r--r-- | client/e2e/src/po/video-watch.po.ts | 67 |
8 files changed, 219 insertions, 64 deletions
diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts new file mode 100644 index 000000000..a15184781 --- /dev/null +++ b/client/e2e/src/po/admin-config.po.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { browserSleep, go } from '../utils' | ||
2 | |||
3 | export class AdminConfigPage { | ||
4 | |||
5 | async navigateTo (tab: 'instance-homepage' | 'basic-configuration' | 'instance-information') { | ||
6 | const waitTitles = { | ||
7 | 'instance-homepage': 'INSTANCE HOMEPAGE', | ||
8 | 'basic-configuration': 'APPEARANCE', | ||
9 | 'instance-information': 'INSTANCE' | ||
10 | } | ||
11 | |||
12 | await go('/admin/config/edit-custom#' + tab) | ||
13 | |||
14 | await $('.inner-form-title=' + waitTitles[tab]).waitForDisplayed() | ||
15 | } | ||
16 | |||
17 | updateNSFWSetting (newValue: 'do_not_list' | 'blur' | 'display') { | ||
18 | return $('#instanceDefaultNSFWPolicy').selectByAttribute('value', newValue) | ||
19 | } | ||
20 | |||
21 | updateHomepage (newValue: string) { | ||
22 | return $('#instanceCustomHomepageContent').setValue(newValue) | ||
23 | } | ||
24 | |||
25 | async save () { | ||
26 | await $('input[type=submit]').click() | ||
27 | await browserSleep(200) | ||
28 | } | ||
29 | } | ||
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts index 8e3030e43..486b9a6d8 100644 --- a/client/e2e/src/po/login.po.ts +++ b/client/e2e/src/po/login.po.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { go } from '../utils' | 1 | import { go } from '../utils' |
2 | 2 | ||
3 | export class LoginPage { | 3 | export class LoginPage { |
4 | |||
4 | async loginAsRootUser () { | 5 | async loginAsRootUser () { |
5 | await go('/login') | 6 | await go('/login') |
6 | 7 | ||
@@ -8,7 +9,7 @@ export class LoginPage { | |||
8 | await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`) | 9 | await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`) |
9 | 10 | ||
10 | await $('input#username').setValue('root') | 11 | await $('input#username').setValue('root') |
11 | await $('input#password').setValue('test1') | 12 | await $('input#password').setValue('test' + this.getSuffix()) |
12 | 13 | ||
13 | await browser.pause(1000) | 14 | await browser.pause(1000) |
14 | 15 | ||
@@ -19,7 +20,24 @@ export class LoginPage { | |||
19 | await expect(this.getLoggedInInfoElem()).toHaveText('root') | 20 | await expect(this.getLoggedInInfoElem()).toHaveText('root') |
20 | } | 21 | } |
21 | 22 | ||
23 | async logout () { | ||
24 | await $('.logged-in-more').click() | ||
25 | |||
26 | const logout = () => $('.dropdown-item*=Log out') | ||
27 | |||
28 | await logout().waitForDisplayed() | ||
29 | await logout().click() | ||
30 | |||
31 | await $('.login-buttons-block').waitForDisplayed() | ||
32 | } | ||
33 | |||
22 | private getLoggedInInfoElem () { | 34 | private getLoggedInInfoElem () { |
23 | return $('.logged-in-display-name') | 35 | return $('.logged-in-display-name') |
24 | } | 36 | } |
37 | |||
38 | private getSuffix () { | ||
39 | return browser.config.baseUrl | ||
40 | ? browser.config.baseUrl.slice(-1) | ||
41 | : '1' | ||
42 | } | ||
25 | } | 43 | } |
diff --git a/client/e2e/src/po/my-account.ts b/client/e2e/src/po/my-account.ts index 85dc02805..8b5e79b5e 100644 --- a/client/e2e/src/po/my-account.ts +++ b/client/e2e/src/po/my-account.ts | |||
@@ -14,6 +14,24 @@ export class MyAccountPage { | |||
14 | return $('a[href="/my-library/history/videos"]').click() | 14 | return $('a[href="/my-library/history/videos"]').click() |
15 | } | 15 | } |
16 | 16 | ||
17 | // Settings | ||
18 | |||
19 | navigateToMySettings () { | ||
20 | return $('a[href="/my-account"]').click() | ||
21 | } | ||
22 | |||
23 | async updateNSFW (newValue: 'do_not_list' | 'blur' | 'display') { | ||
24 | const nsfw = $('#nsfwPolicy') | ||
25 | |||
26 | await nsfw.waitForDisplayed() | ||
27 | await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox | ||
28 | await nsfw.selectByAttribute('value', newValue) | ||
29 | |||
30 | const submit = $('my-user-video-settings input[type=submit]') | ||
31 | await submit.scrollIntoView(false) | ||
32 | await submit.click() | ||
33 | } | ||
34 | |||
17 | // My account Videos | 35 | // My account Videos |
18 | 36 | ||
19 | async removeVideo (name: string) { | 37 | async removeVideo (name: string) { |
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.ts index 372e8ab20..fca3bcdba 100644 --- a/client/e2e/src/po/player.po.ts +++ b/client/e2e/src/po/player.po.ts | |||
@@ -15,6 +15,9 @@ export class PlayerPage { | |||
15 | 15 | ||
16 | waitUntilPlaylistInfo (text: string, maxTime: number) { | 16 | waitUntilPlaylistInfo (text: string, maxTime: number) { |
17 | return browser.waitUntil(async () => { | 17 | return browser.waitUntil(async () => { |
18 | // Without this we have issues on iphone | ||
19 | await $('.video-js').click() | ||
20 | |||
18 | return (await $('.video-js .vjs-playlist-info').getText()).includes(text) | 21 | return (await $('.video-js .vjs-playlist-info').getText()).includes(text) |
19 | }, { timeout: maxTime }) | 22 | }, { timeout: maxTime }) |
20 | } | 23 | } |
@@ -42,7 +45,7 @@ export class PlayerPage { | |||
42 | await browserSleep(2000) | 45 | await browserSleep(2000) |
43 | 46 | ||
44 | await browser.waitUntil(async () => { | 47 | await browser.waitUntil(async () => { |
45 | return (await this.getWatchVideoPlayerCurrentTime()) >= 2 | 48 | return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec |
46 | }) | 49 | }) |
47 | 50 | ||
48 | await videojsElem().click() | 51 | await videojsElem().click() |
diff --git a/client/e2e/src/po/video-list.po.ts b/client/e2e/src/po/video-list.po.ts new file mode 100644 index 000000000..f62c79adc --- /dev/null +++ b/client/e2e/src/po/video-list.po.ts | |||
@@ -0,0 +1,128 @@ | |||
1 | import { browserSleep, go } from '../utils' | ||
2 | |||
3 | export class VideoListPage { | ||
4 | |||
5 | constructor (private isMobileDevice: boolean, private isSafari: boolean) { | ||
6 | |||
7 | } | ||
8 | |||
9 | async goOnVideosList () { | ||
10 | let url: string | ||
11 | |||
12 | // We did not upload a file on a mobile device | ||
13 | if (this.isMobileDevice === true || this.isSafari === true) { | ||
14 | url = 'https://peertube2.cpy.re/videos/local' | ||
15 | } else { | ||
16 | url = '/videos/recently-added' | ||
17 | } | ||
18 | |||
19 | await go(url) | ||
20 | |||
21 | // Waiting the following element does not work on Safari... | ||
22 | if (this.isSafari) return browserSleep(3000) | ||
23 | |||
24 | await this.waitForList() | ||
25 | } | ||
26 | |||
27 | async goOnLocal () { | ||
28 | await $('.menu-link[href="/videos/local"]').click() | ||
29 | await this.waitForTitle('Local videos') | ||
30 | } | ||
31 | |||
32 | async goOnRecentlyAdded () { | ||
33 | await $('.menu-link[href="/videos/recently-added"]').click() | ||
34 | await this.waitForTitle('Recently added') | ||
35 | } | ||
36 | |||
37 | async goOnTrending () { | ||
38 | await $('.menu-link[href="/videos/trending"]').click() | ||
39 | await this.waitForTitle('Trending') | ||
40 | } | ||
41 | |||
42 | async goOnHomepage () { | ||
43 | await go('/home') | ||
44 | await this.waitForList() | ||
45 | } | ||
46 | |||
47 | async goOnRootChannel () { | ||
48 | await go('/c/root_channel/videos') | ||
49 | await this.waitForList() | ||
50 | } | ||
51 | |||
52 | async goOnRootAccount () { | ||
53 | await go('/a/root/videos') | ||
54 | await this.waitForList() | ||
55 | } | ||
56 | |||
57 | async goOnRootAccountChannels () { | ||
58 | await go('/a/root/video-channels') | ||
59 | await this.waitForList() | ||
60 | } | ||
61 | |||
62 | getNSFWFilter () { | ||
63 | return $$('.active-filter').filter(async a => { | ||
64 | return (await a.getText()).includes('Sensitive') | ||
65 | }).then(f => f[0]) | ||
66 | } | ||
67 | |||
68 | async getVideosListName () { | ||
69 | const elems = await $$('.videos .video-miniature .video-miniature-name') | ||
70 | const texts = await Promise.all(elems.map(e => e.getText())) | ||
71 | |||
72 | return texts.map(t => t.trim()) | ||
73 | } | ||
74 | |||
75 | videoExists (name: string) { | ||
76 | return $('.video-miniature-name=' + name).isDisplayed() | ||
77 | } | ||
78 | |||
79 | async videoIsBlurred (name: string) { | ||
80 | const filter = await $('.video-miniature-name=' + name).getCSSProperty('filter') | ||
81 | |||
82 | return filter.value !== 'none' | ||
83 | } | ||
84 | |||
85 | async clickOnVideo (videoName: string) { | ||
86 | const video = async () => { | ||
87 | const videos = await $$('.videos .video-miniature .video-miniature-name').filter(async e => { | ||
88 | const t = await e.getText() | ||
89 | |||
90 | return t === videoName | ||
91 | }) | ||
92 | |||
93 | return videos[0] | ||
94 | } | ||
95 | |||
96 | await browser.waitUntil(async () => { | ||
97 | const elem = await video() | ||
98 | |||
99 | return elem?.isClickable() | ||
100 | }); | ||
101 | |||
102 | (await video()).click() | ||
103 | |||
104 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | ||
105 | } | ||
106 | |||
107 | async clickOnFirstVideo () { | ||
108 | const video = () => $('.videos .video-miniature .video-thumbnail') | ||
109 | const videoName = () => $('.videos .video-miniature .video-miniature-name') | ||
110 | |||
111 | await video().waitForClickable() | ||
112 | |||
113 | const textToReturn = await videoName().getText() | ||
114 | await video().click() | ||
115 | |||
116 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | ||
117 | |||
118 | return textToReturn | ||
119 | } | ||
120 | |||
121 | private waitForList () { | ||
122 | return $('.videos .video-miniature .video-miniature-name').waitForDisplayed() | ||
123 | } | ||
124 | |||
125 | private waitForTitle (title: string) { | ||
126 | return $('h1=' + title).waitForDisplayed() | ||
127 | } | ||
128 | } | ||
diff --git a/client/e2e/src/po/video-search.po.ts b/client/e2e/src/po/video-search.po.ts new file mode 100644 index 000000000..5446718d1 --- /dev/null +++ b/client/e2e/src/po/video-search.po.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export class VideoSearchPage { | ||
2 | |||
3 | async search (search: string) { | ||
4 | await $('#search-video').setValue(search) | ||
5 | await $('my-header .icon-search').click() | ||
6 | |||
7 | await browser.waitUntil(() => { | ||
8 | return $('my-video-miniature').isDisplayed() | ||
9 | }) | ||
10 | } | ||
11 | } | ||
diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts index 34f916b55..dd437c390 100644 --- a/client/e2e/src/po/video-upload.po.ts +++ b/client/e2e/src/po/video-upload.po.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { clickOnCheckbox } from '../utils' | ||
2 | 3 | ||
3 | export class VideoUploadPage { | 4 | export class VideoUploadPage { |
4 | async navigateTo () { | 5 | async navigateTo () { |
@@ -30,6 +31,10 @@ export class VideoUploadPage { | |||
30 | }) | 31 | }) |
31 | } | 32 | } |
32 | 33 | ||
34 | setAsNSFW () { | ||
35 | return clickOnCheckbox('nsfw') | ||
36 | } | ||
37 | |||
33 | async validSecondUploadStep (videoName: string) { | 38 | async validSecondUploadStep (videoName: string) { |
34 | const nameInput = $('input#name') | 39 | const nameInput = $('input#name') |
35 | await nameInput.clearValue() | 40 | await nameInput.clearValue() |
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index c07f4b25f..41425f4d7 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts | |||
@@ -1,37 +1,16 @@ | |||
1 | import { FIXTURE_URLS } from '../urls' | 1 | import { browserSleep, FIXTURE_URLS, go } from '../utils' |
2 | import { browserSleep, go } from '../utils' | ||
3 | 2 | ||
4 | export class VideoWatchPage { | 3 | export class VideoWatchPage { |
5 | async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { | ||
6 | let url: string | ||
7 | |||
8 | // We did not upload a file on a mobile device | ||
9 | if (isMobileDevice === true || isSafari === true) { | ||
10 | url = 'https://peertube2.cpy.re/videos/local' | ||
11 | } else { | ||
12 | url = '/videos/recently-added' | ||
13 | } | ||
14 | |||
15 | await go(url) | ||
16 | |||
17 | // Waiting the following element does not work on Safari... | ||
18 | if (isSafari) return browserSleep(3000) | ||
19 | 4 | ||
20 | await $('.videos .video-miniature .video-miniature-name').waitForDisplayed() | 5 | constructor (private isMobileDevice: boolean, private isSafari: boolean) { |
21 | } | ||
22 | |||
23 | async getVideosListName () { | ||
24 | const elems = await $$('.videos .video-miniature .video-miniature-name') | ||
25 | const texts = await Promise.all(elems.map(e => e.getText())) | ||
26 | 6 | ||
27 | return texts.map(t => t.trim()) | ||
28 | } | 7 | } |
29 | 8 | ||
30 | waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) { | 9 | waitWatchVideoName (videoName: string) { |
31 | if (isSafari) return browserSleep(5000) | 10 | if (this.isSafari) return browserSleep(5000) |
32 | 11 | ||
33 | // On mobile we display the first node, on desktop the second | 12 | // On mobile we display the first node, on desktop the second |
34 | const index = isMobileDevice ? 0 : 1 | 13 | const index = this.isMobileDevice ? 0 : 1 |
35 | 14 | ||
36 | return browser.waitUntil(async () => { | 15 | return browser.waitUntil(async () => { |
37 | return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName) | 16 | return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName) |
@@ -58,42 +37,6 @@ export class VideoWatchPage { | |||
58 | return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) | 37 | return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) |
59 | } | 38 | } |
60 | 39 | ||
61 | async clickOnVideo (videoName: string) { | ||
62 | const video = async () => { | ||
63 | const videos = await $$('.videos .video-miniature .video-miniature-name').filter(async e => { | ||
64 | const t = await e.getText() | ||
65 | |||
66 | return t === videoName | ||
67 | }) | ||
68 | |||
69 | return videos[0] | ||
70 | } | ||
71 | |||
72 | await browser.waitUntil(async () => { | ||
73 | const elem = await video() | ||
74 | |||
75 | return elem?.isClickable() | ||
76 | }); | ||
77 | |||
78 | (await video()).click() | ||
79 | |||
80 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | ||
81 | } | ||
82 | |||
83 | async clickOnFirstVideo () { | ||
84 | const video = () => $('.videos .video-miniature .video-thumbnail') | ||
85 | const videoName = () => $('.videos .video-miniature .video-miniature-name') | ||
86 | |||
87 | await video().waitForClickable() | ||
88 | |||
89 | const textToReturn = await videoName().getText() | ||
90 | await video().click() | ||
91 | |||
92 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | ||
93 | |||
94 | return textToReturn | ||
95 | } | ||
96 | |||
97 | async clickOnUpdate () { | 40 | async clickOnUpdate () { |
98 | const dropdown = $('my-video-actions-dropdown .action-button') | 41 | const dropdown = $('my-video-actions-dropdown .action-button') |
99 | await dropdown.click() | 42 | await dropdown.click() |