aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-21 09:09:46 +0200
committerChocobozzz <me@florianbigard.com>2022-06-21 10:49:54 +0200
commit1db86422eb516acd23550f30536de4ebd8f0daea (patch)
tree909c01cf3f5903ba5d44f182d4988586ad8650c1 /client/e2e/src
parent2b621ac0ebe83693bba6354b3482a03ba58143e7 (diff)
downloadPeerTube-1db86422eb516acd23550f30536de4ebd8f0daea.tar.gz
PeerTube-1db86422eb516acd23550f30536de4ebd8f0daea.tar.zst
PeerTube-1db86422eb516acd23550f30536de4ebd8f0daea.zip
Add E2E tests for signup
Diffstat (limited to 'client/e2e/src')
-rw-r--r--client/e2e/src/po/admin-config.po.ts11
-rw-r--r--client/e2e/src/po/admin-plugin.po.ts2
-rw-r--r--client/e2e/src/po/login.po.ts10
-rw-r--r--client/e2e/src/po/signup.po.ts64
-rw-r--r--client/e2e/src/suites-local/plugins.e2e-spec.ts2
-rw-r--r--client/e2e/src/suites-local/signup.e2e-spec.ts87
-rw-r--r--client/e2e/src/utils/elements.ts7
-rw-r--r--client/e2e/src/utils/server.ts3
8 files changed, 173 insertions, 13 deletions
diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts
index a15184781..6d48a0fd7 100644
--- a/client/e2e/src/po/admin-config.po.ts
+++ b/client/e2e/src/po/admin-config.po.ts
@@ -1,4 +1,4 @@
1import { browserSleep, go } from '../utils' 1import { getCheckbox, go } from '../utils'
2 2
3export class AdminConfigPage { 3export class AdminConfigPage {
4 4
@@ -22,8 +22,13 @@ export class AdminConfigPage {
22 return $('#instanceCustomHomepageContent').setValue(newValue) 22 return $('#instanceCustomHomepageContent').setValue(newValue)
23 } 23 }
24 24
25 async toggleSignup () {
26 const checkbox = await getCheckbox('signupEnabled')
27 await checkbox.click()
28 }
29
25 async save () { 30 async save () {
26 await $('input[type=submit]').click() 31 const button = $('input[type=submit]')
27 await browserSleep(200) 32 await button.click()
28 } 33 }
29} 34}
diff --git a/client/e2e/src/po/admin-plugin.po.ts b/client/e2e/src/po/admin-plugin.po.ts
index 6a3f3cf28..0259f34d6 100644
--- a/client/e2e/src/po/admin-plugin.po.ts
+++ b/client/e2e/src/po/admin-plugin.po.ts
@@ -2,7 +2,7 @@ import { browserSleep, go } from '../utils'
2 2
3export class AdminPluginPage { 3export class AdminPluginPage {
4 4
5 async navigateToSearch () { 5 async navigateToPluginSearch () {
6 await go('/admin/plugins/search') 6 await go('/admin/plugins/search')
7 7
8 await $('my-plugin-search').waitForDisplayed() 8 await $('my-plugin-search').waitForDisplayed()
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts
index 486b9a6d8..2c4561b7d 100644
--- a/client/e2e/src/po/login.po.ts
+++ b/client/e2e/src/po/login.po.ts
@@ -15,9 +15,7 @@ export class LoginPage {
15 15
16 await $('form input[type=submit]').click() 16 await $('form input[type=submit]').click()
17 17
18 await this.getLoggedInInfoElem().waitForExist() 18 await this.ensureIsLoggedInAs('root')
19
20 await expect(this.getLoggedInInfoElem()).toHaveText('root')
21 } 19 }
22 20
23 async logout () { 21 async logout () {
@@ -31,6 +29,12 @@ export class LoginPage {
31 await $('.login-buttons-block').waitForDisplayed() 29 await $('.login-buttons-block').waitForDisplayed()
32 } 30 }
33 31
32 async ensureIsLoggedInAs (displayName: string) {
33 await this.getLoggedInInfoElem().waitForExist()
34
35 await expect(this.getLoggedInInfoElem()).toHaveText(displayName)
36 }
37
34 private getLoggedInInfoElem () { 38 private getLoggedInInfoElem () {
35 return $('.logged-in-display-name') 39 return $('.logged-in-display-name')
36 } 40 }
diff --git a/client/e2e/src/po/signup.po.ts b/client/e2e/src/po/signup.po.ts
new file mode 100644
index 000000000..ef36dbcc4
--- /dev/null
+++ b/client/e2e/src/po/signup.po.ts
@@ -0,0 +1,64 @@
1import { getCheckbox } from '../utils'
2
3export class SignupPage {
4
5 getRegisterMenuButton () {
6 return $('.create-account-button')
7 }
8
9 async clickOnRegisterInMenu () {
10 const button = this.getRegisterMenuButton()
11
12 await button.waitForDisplayed()
13 await button.click()
14 }
15
16 async validateStep () {
17 const next = $('button[type=submit]')
18
19 await next.waitForClickable()
20 await next.click()
21 }
22
23 async checkTerms () {
24 const terms = await getCheckbox('terms')
25
26 return terms.click()
27 }
28
29 async fillAccountStep (options: {
30 displayName: string
31 username: string
32 email: string
33 password: string
34 }) {
35 if (options.displayName) {
36 await $('#displayName').setValue(options.displayName)
37 }
38
39 if (options.username) {
40 await $('#username').setValue(options.username)
41 }
42
43 if (options.email) {
44 await $('#email').setValue(options.email)
45 }
46
47 if (options.password) {
48 await $('#password').setValue(options.password)
49 }
50 }
51
52 async fillChannelStep (options: {
53 displayName: string
54 name: string
55 }) {
56 if (options.displayName) {
57 await $('#displayName').setValue(options.displayName)
58 }
59
60 if (options.name) {
61 await $('#name').setValue(options.name)
62 }
63 }
64}
diff --git a/client/e2e/src/suites-local/plugins.e2e-spec.ts b/client/e2e/src/suites-local/plugins.e2e-spec.ts
index 411f1d217..a32ba1044 100644
--- a/client/e2e/src/suites-local/plugins.e2e-spec.ts
+++ b/client/e2e/src/suites-local/plugins.e2e-spec.ts
@@ -34,7 +34,7 @@ describe('Plugins', () => {
34 it('Should install hello world plugin', async () => { 34 it('Should install hello world plugin', async () => {
35 await loginPage.loginAsRootUser() 35 await loginPage.loginAsRootUser()
36 36
37 await adminPluginPage.navigateToSearch() 37 await adminPluginPage.navigateToPluginSearch()
38 await adminPluginPage.search('hello-world') 38 await adminPluginPage.search('hello-world')
39 await adminPluginPage.installHelloWorld() 39 await adminPluginPage.installHelloWorld()
40 await browser.refresh() 40 await browser.refresh()
diff --git a/client/e2e/src/suites-local/signup.e2e-spec.ts b/client/e2e/src/suites-local/signup.e2e-spec.ts
new file mode 100644
index 000000000..0f6d7a0e6
--- /dev/null
+++ b/client/e2e/src/suites-local/signup.e2e-spec.ts
@@ -0,0 +1,87 @@
1import { AdminConfigPage } from '../po/admin-config.po'
2import { LoginPage } from '../po/login.po'
3import { SignupPage } from '../po/signup.po'
4import { waitServerUp } from '../utils'
5
6describe('Signup', () => {
7 let loginPage: LoginPage
8 let adminConfigPage: AdminConfigPage
9 let signupPage: SignupPage
10
11 before(async () => {
12 await waitServerUp()
13 })
14
15 beforeEach(async () => {
16 loginPage = new LoginPage()
17 adminConfigPage = new AdminConfigPage()
18 signupPage = new SignupPage()
19
20 await browser.maximizeWindow()
21 })
22
23 it('Should disable signup', async () => {
24 await loginPage.loginAsRootUser()
25
26 await adminConfigPage.navigateTo('basic-configuration')
27 await adminConfigPage.toggleSignup()
28
29 await adminConfigPage.save()
30
31 await loginPage.logout()
32 await browser.refresh()
33
34 expect(signupPage.getRegisterMenuButton()).not.toBeDisplayed()
35 })
36
37 it('Should enable signup', async () => {
38 await loginPage.loginAsRootUser()
39
40 await adminConfigPage.navigateTo('basic-configuration')
41 await adminConfigPage.toggleSignup()
42
43 await adminConfigPage.save()
44
45 await loginPage.logout()
46 await browser.refresh()
47
48 expect(signupPage.getRegisterMenuButton()).toBeDisplayed()
49 })
50
51 it('Should go on signup page', async function () {
52 await signupPage.clickOnRegisterInMenu()
53 })
54
55 it('Should validate the first step (about page)', async function () {
56 await signupPage.validateStep()
57 })
58
59 it('Should validate the second step (terms)', async function () {
60 await signupPage.checkTerms()
61 await signupPage.validateStep()
62 })
63
64 it('Should validate the third step (account)', async function () {
65 await signupPage.fillAccountStep({
66 displayName: 'user 1',
67 username: 'user_1',
68 email: 'user_1@example.com',
69 password: 'my_super_password'
70 })
71
72 await signupPage.validateStep()
73 })
74
75 it('Should validate the third step (channel)', async function () {
76 await signupPage.fillChannelStep({
77 displayName: 'user 1 channel',
78 name: 'user_1_channel'
79 })
80
81 await signupPage.validateStep()
82 })
83
84 it('Should be logged in', async function () {
85 await loginPage.ensureIsLoggedInAs('user 1')
86 })
87})
diff --git a/client/e2e/src/utils/elements.ts b/client/e2e/src/utils/elements.ts
index 3ffa5defd..9d6cfe673 100644
--- a/client/e2e/src/utils/elements.ts
+++ b/client/e2e/src/utils/elements.ts
@@ -1,5 +1,8 @@
1function getCheckbox (name: string) { 1async function getCheckbox (name: string) {
2 return $(`my-peertube-checkbox input[id=${name}]`).parentElement() 2 const input = $(`my-peertube-checkbox input[id=${name}]`)
3 await input.waitForExist()
4
5 return input.parentElement()
3} 6}
4 7
5async function selectCustomSelect (id: string, valueLabel: string) { 8async function selectCustomSelect (id: string, valueLabel: string) {
diff --git a/client/e2e/src/utils/server.ts b/client/e2e/src/utils/server.ts
index a0c591630..140054794 100644
--- a/client/e2e/src/utils/server.ts
+++ b/client/e2e/src/utils/server.ts
@@ -18,9 +18,6 @@ function runServer (appInstance: string, config: any = {}) {
18 log: { 18 log: {
19 level: 'warn' 19 level: 'warn'
20 }, 20 },
21 signup: {
22 enabled: false
23 },
24 transcoding: { 21 transcoding: {
25 enabled: false 22 enabled: false
26 }, 23 },