aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-15 15:58:10 +0100
committerChocobozzz <me@florianbigard.com>2021-12-16 10:08:55 +0100
commita9bfa85d2cdf13670aaced740da5b493fbeddfce (patch)
tree3781c9218d4cc7786b6589365c0efbed2151703d /client/e2e
parentc77fdc605b3ccc1ab6890f889d8200fbe9372949 (diff)
downloadPeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.gz
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.zst
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.zip
Add ability for admins to set default p2p policy
Diffstat (limited to 'client/e2e')
-rw-r--r--client/e2e/src/po/anonymous-settings.po.ts21
-rw-r--r--client/e2e/src/po/my-account.po.ts (renamed from client/e2e/src/po/my-account.ts)17
-rw-r--r--client/e2e/src/po/video-upload.po.ts8
-rw-r--r--client/e2e/src/po/video-watch.po.ts13
-rw-r--r--client/e2e/src/suites-all/videos.e2e-spec.ts2
-rw-r--r--client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts75
-rw-r--r--client/e2e/src/suites-local/user-settings.e2e-spec.ts82
-rw-r--r--client/e2e/src/suites-local/videos-list.e2e-spec.ts2
-rw-r--r--client/e2e/src/utils/elements.ts21
-rw-r--r--client/e2e/src/utils/hooks.ts3
10 files changed, 222 insertions, 22 deletions
diff --git a/client/e2e/src/po/anonymous-settings.po.ts b/client/e2e/src/po/anonymous-settings.po.ts
new file mode 100644
index 000000000..180d371fa
--- /dev/null
+++ b/client/e2e/src/po/anonymous-settings.po.ts
@@ -0,0 +1,21 @@
1import { getCheckbox } from '../utils'
2
3export class AnonymousSettingsPage {
4
5 async openSettings () {
6 const link = await $$('.menu-link').filter(async i => {
7 return await i.getText() === 'My settings'
8 }).then(links => links[0])
9
10 await link.click()
11
12 await $('my-user-video-settings').waitForDisplayed()
13 }
14
15 async clickOnP2PCheckbox () {
16 const p2p = getCheckbox('p2pEnabled')
17 await p2p.waitForClickable()
18
19 await p2p.click()
20 }
21}
diff --git a/client/e2e/src/po/my-account.ts b/client/e2e/src/po/my-account.po.ts
index b51614fd9..13a764e87 100644
--- a/client/e2e/src/po/my-account.ts
+++ b/client/e2e/src/po/my-account.po.ts
@@ -1,4 +1,4 @@
1import { go } from '../utils' 1import { getCheckbox, go } from '../utils'
2 2
3export class MyAccountPage { 3export class MyAccountPage {
4 4
@@ -27,6 +27,21 @@ export class MyAccountPage {
27 await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox 27 await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox
28 await nsfw.selectByAttribute('value', newValue) 28 await nsfw.selectByAttribute('value', newValue)
29 29
30 await this.submitVideoSettings()
31 }
32
33 async clickOnP2PCheckbox () {
34 const p2p = getCheckbox('p2pEnabled')
35
36 await p2p.waitForClickable()
37 await p2p.scrollIntoView(false) // Avoid issues with fixed header on firefox
38
39 await p2p.click()
40
41 await this.submitVideoSettings()
42 }
43
44 private async submitVideoSettings () {
30 const submit = $('my-user-video-settings input[type=submit]') 45 const submit = $('my-user-video-settings input[type=submit]')
31 await submit.scrollIntoView(false) 46 await submit.scrollIntoView(false)
32 await submit.click() 47 await submit.click()
diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts
index dd437c390..2206b56c3 100644
--- a/client/e2e/src/po/video-upload.po.ts
+++ b/client/e2e/src/po/video-upload.po.ts
@@ -1,5 +1,5 @@
1import { join } from 'path' 1import { join } from 'path'
2import { clickOnCheckbox } from '../utils' 2import { getCheckbox, selectCustomSelect } from '../utils'
3 3
4export class VideoUploadPage { 4export class VideoUploadPage {
5 async navigateTo () { 5 async navigateTo () {
@@ -32,7 +32,7 @@ export class VideoUploadPage {
32 } 32 }
33 33
34 setAsNSFW () { 34 setAsNSFW () {
35 return clickOnCheckbox('nsfw') 35 return getCheckbox('nsfw').click()
36 } 36 }
37 37
38 async validSecondUploadStep (videoName: string) { 38 async validSecondUploadStep (videoName: string) {
@@ -47,6 +47,10 @@ export class VideoUploadPage {
47 }) 47 })
48 } 48 }
49 49
50 setAsPublic () {
51 return selectCustomSelect('privacy', 'Public')
52 }
53
50 private getSecondStepSubmitButton () { 54 private getSecondStepSubmitButton () {
51 return $('.submit-container my-button') 55 return $('.submit-container my-button')
52 } 56 }
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 1406c971a..cecda3a8b 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -39,12 +39,23 @@ export class VideoWatchPage {
39 return $('my-video-comment-add').isExisting() 39 return $('my-video-comment-add').isExisting()
40 } 40 }
41 41
42 isPrivacyWarningDisplayed () {
43 return $('my-privacy-concerns').isDisplayed()
44 }
45
42 async goOnAssociatedEmbed () { 46 async goOnAssociatedEmbed () {
43 let url = await browser.getUrl() 47 let url = await browser.getUrl()
44 url = url.replace('/w/', '/videos/embed/') 48 url = url.replace('/w/', '/videos/embed/')
45 url = url.replace(':3333', ':9001') 49 url = url.replace(':3333', ':9001')
46 50
47 return go(url) 51 await go(url)
52 await $('.vjs-big-play-button').waitForDisplayed()
53 }
54
55 async isEmbedWarningDisplayed () {
56 const text = await $('.vjs-dock-description').getText()
57
58 return !!text.trim()
48 } 59 }
49 60
50 goOnP2PMediaLoaderEmbed () { 61 goOnP2PMediaLoaderEmbed () {
diff --git a/client/e2e/src/suites-all/videos.e2e-spec.ts b/client/e2e/src/suites-all/videos.e2e-spec.ts
index 3b8305a25..b3a87c8e2 100644
--- a/client/e2e/src/suites-all/videos.e2e-spec.ts
+++ b/client/e2e/src/suites-all/videos.e2e-spec.ts
@@ -1,5 +1,5 @@
1import { LoginPage } from '../po/login.po' 1import { LoginPage } from '../po/login.po'
2import { MyAccountPage } from '../po/my-account' 2import { MyAccountPage } from '../po/my-account.po'
3import { PlayerPage } from '../po/player.po' 3import { PlayerPage } from '../po/player.po'
4import { VideoListPage } from '../po/video-list.po' 4import { VideoListPage } from '../po/video-list.po'
5import { VideoUpdatePage } from '../po/video-update.po' 5import { VideoUpdatePage } from '../po/video-update.po'
diff --git a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
index c2c8edcc9..e060d382f 100644
--- a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
+++ b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
@@ -1,7 +1,7 @@
1import { LoginPage } from '../po/login.po' 1import { LoginPage } from '../po/login.po'
2import { VideoUploadPage } from '../po/video-upload.po' 2import { VideoUploadPage } from '../po/video-upload.po'
3import { VideoWatchPage } from '../po/video-watch.po' 3import { VideoWatchPage } from '../po/video-watch.po'
4import { isMobileDevice, isSafari, waitServerUp } from '../utils' 4import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'
5 5
6describe('Custom server defaults', () => { 6describe('Custom server defaults', () => {
7 let videoUploadPage: VideoUploadPage 7 let videoUploadPage: VideoUploadPage
@@ -10,9 +10,7 @@ describe('Custom server defaults', () => {
10 10
11 before(async () => { 11 before(async () => {
12 await waitServerUp() 12 await waitServerUp()
13 })
14 13
15 beforeEach(async () => {
16 loginPage = new LoginPage() 14 loginPage = new LoginPage()
17 videoUploadPage = new VideoUploadPage() 15 videoUploadPage = new VideoUploadPage()
18 videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari()) 16 videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
@@ -20,18 +18,69 @@ describe('Custom server defaults', () => {
20 await browser.maximizeWindow() 18 await browser.maximizeWindow()
21 }) 19 })
22 20
23 it('Should upload a video with custom default values', async function () { 21 describe('Publish default values', function () {
24 await loginPage.loginAsRootUser() 22 before(async function () {
25 await videoUploadPage.navigateTo() 23 await loginPage.loginAsRootUser()
26 await videoUploadPage.uploadVideo() 24 })
27 await videoUploadPage.validSecondUploadStep('video') 25
26 it('Should upload a video with custom default values', async function () {
27 await videoUploadPage.navigateTo()
28 await videoUploadPage.uploadVideo()
29 await videoUploadPage.validSecondUploadStep('video')
28 30
29 await videoWatchPage.waitWatchVideoName('video') 31 await videoWatchPage.waitWatchVideoName('video')
30 32
31 expect(await videoWatchPage.getPrivacy()).toBe('Internal') 33 expect(await videoWatchPage.getPrivacy()).toBe('Internal')
32 expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial') 34 expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial')
33 expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy() 35 expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy()
34 expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy() 36 expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy()
37 })
38
39 after(async function () {
40 await loginPage.logout()
41 })
35 }) 42 })
36 43
44 describe('P2P', function () {
45 let videoUrl: string
46
47 async function goOnVideoWatchPage () {
48 await go(videoUrl)
49 await videoWatchPage.waitWatchVideoName('video')
50 }
51
52 async function checkP2P (enabled: boolean) {
53 await goOnVideoWatchPage()
54 expect(await videoWatchPage.isPrivacyWarningDisplayed()).toEqual(enabled)
55
56 await videoWatchPage.goOnAssociatedEmbed()
57 expect(await videoWatchPage.isEmbedWarningDisplayed()).toEqual(enabled)
58 }
59
60 before(async () => {
61 await loginPage.loginAsRootUser()
62 await videoUploadPage.navigateTo()
63 await videoUploadPage.uploadVideo()
64 await videoUploadPage.setAsPublic()
65 await videoUploadPage.validSecondUploadStep('video')
66
67 await videoWatchPage.waitWatchVideoName('video')
68
69 videoUrl = await browser.getUrl()
70 })
71
72 beforeEach(async function () {
73 await goOnVideoWatchPage()
74 })
75
76 it('Should have P2P disabled for a logged in user', async function () {
77 await checkP2P(false)
78 })
79
80 it('Should have P2P disabled for anonymous users', async function () {
81 await loginPage.logout()
82
83 await checkP2P(false)
84 })
85 })
37}) 86})
diff --git a/client/e2e/src/suites-local/user-settings.e2e-spec.ts b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
new file mode 100644
index 000000000..b87501cd1
--- /dev/null
+++ b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
@@ -0,0 +1,82 @@
1import { AnonymousSettingsPage } from '../po/anonymous-settings.po'
2import { LoginPage } from '../po/login.po'
3import { MyAccountPage } from '../po/my-account.po'
4import { VideoUploadPage } from '../po/video-upload.po'
5import { VideoWatchPage } from '../po/video-watch.po'
6import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'
7
8describe('User settings', () => {
9 let videoUploadPage: VideoUploadPage
10 let loginPage: LoginPage
11 let videoWatchPage: VideoWatchPage
12 let myAccountPage: MyAccountPage
13 let anonymousSettingsPage: AnonymousSettingsPage
14
15 before(async () => {
16 await waitServerUp()
17
18 loginPage = new LoginPage()
19 videoUploadPage = new VideoUploadPage()
20 videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
21 myAccountPage = new MyAccountPage()
22 anonymousSettingsPage = new AnonymousSettingsPage()
23
24 await browser.maximizeWindow()
25 })
26
27 describe('P2P', function () {
28 let videoUrl: string
29
30 async function goOnVideoWatchPage () {
31 await go(videoUrl)
32 await videoWatchPage.waitWatchVideoName('video')
33 }
34
35 async function checkP2P (enabled: boolean) {
36 await goOnVideoWatchPage()
37 expect(await videoWatchPage.isPrivacyWarningDisplayed()).toEqual(enabled)
38
39 await videoWatchPage.goOnAssociatedEmbed()
40 expect(await videoWatchPage.isEmbedWarningDisplayed()).toEqual(enabled)
41 }
42
43 before(async () => {
44 await loginPage.loginAsRootUser()
45 await videoUploadPage.navigateTo()
46 await videoUploadPage.uploadVideo()
47 await videoUploadPage.validSecondUploadStep('video')
48
49 await videoWatchPage.waitWatchVideoName('video')
50
51 videoUrl = await browser.getUrl()
52 })
53
54 beforeEach(async function () {
55 await goOnVideoWatchPage()
56 })
57
58 it('Should have P2P enabled for a logged in user', async function () {
59 await checkP2P(true)
60 })
61
62 it('Should disable P2P for a logged in user', async function () {
63 await myAccountPage.navigateToMySettings()
64 await myAccountPage.clickOnP2PCheckbox()
65
66 await checkP2P(false)
67 })
68
69 it('Should have P2P enabled for anonymous users', async function () {
70 await loginPage.logout()
71
72 await checkP2P(true)
73 })
74
75 it('Should disable P2P for an anonymous user', async function () {
76 await anonymousSettingsPage.openSettings()
77 await anonymousSettingsPage.clickOnP2PCheckbox()
78
79 await checkP2P(false)
80 })
81 })
82})
diff --git a/client/e2e/src/suites-local/videos-list.e2e-spec.ts b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
index bca6018b9..ce57261b9 100644
--- a/client/e2e/src/suites-local/videos-list.e2e-spec.ts
+++ b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
@@ -1,6 +1,6 @@
1import { AdminConfigPage } from '../po/admin-config.po' 1import { AdminConfigPage } from '../po/admin-config.po'
2import { LoginPage } from '../po/login.po' 2import { LoginPage } from '../po/login.po'
3import { MyAccountPage } from '../po/my-account' 3import { MyAccountPage } from '../po/my-account.po'
4import { VideoListPage } from '../po/video-list.po' 4import { VideoListPage } from '../po/video-list.po'
5import { VideoSearchPage } from '../po/video-search.po' 5import { VideoSearchPage } from '../po/video-search.po'
6import { VideoUploadPage } from '../po/video-upload.po' 6import { VideoUploadPage } from '../po/video-upload.po'
diff --git a/client/e2e/src/utils/elements.ts b/client/e2e/src/utils/elements.ts
index cadc46cce..315718879 100644
--- a/client/e2e/src/utils/elements.ts
+++ b/client/e2e/src/utils/elements.ts
@@ -1,7 +1,22 @@
1function clickOnCheckbox (name: string) { 1function getCheckbox (name: string) {
2 return $(`my-peertube-checkbox[inputname=${name}] label`).click() 2 return $(`my-peertube-checkbox[inputname=${name}] label`)
3}
4
5async function selectCustomSelect (id: string, valueLabel: string) {
6 await $(`[formcontrolname=${id}] .ng-arrow-wrapper`).click()
7
8 const option = await $$(`[formcontrolname=${id}] .ng-option`).filter(async o => {
9 const text = await o.getText()
10
11 return text.trimStart().startsWith(valueLabel)
12 }).then(options => options[0])
13
14 await option.waitForDisplayed()
15
16 return option.click()
3} 17}
4 18
5export { 19export {
6 clickOnCheckbox 20 getCheckbox,
21 selectCustomSelect
7} 22}
diff --git a/client/e2e/src/utils/hooks.ts b/client/e2e/src/utils/hooks.ts
index e42c6a5d8..2f3d10fe3 100644
--- a/client/e2e/src/utils/hooks.ts
+++ b/client/e2e/src/utils/hooks.ts
@@ -55,6 +55,9 @@ function buildConfig (suiteFile: string = undefined) {
55 comments_enabled: false, 55 comments_enabled: false,
56 privacy: 4, 56 privacy: 4,
57 licence: 4 57 licence: 4
58 },
59 p2p: {
60 enabled: false
58 } 61 }
59 } 62 }
60 } 63 }