aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src/po')
-rw-r--r--client/e2e/src/po/admin-config.po.ts27
-rw-r--r--client/e2e/src/po/admin-registration.po.ts35
-rw-r--r--client/e2e/src/po/login.po.ts36
-rw-r--r--client/e2e/src/po/signup.po.ts51
4 files changed, 111 insertions, 38 deletions
diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts
index 27957a71f..510037ddd 100644
--- a/client/e2e/src/po/admin-config.po.ts
+++ b/client/e2e/src/po/admin-config.po.ts
@@ -1,4 +1,4 @@
1import { getCheckbox, go } from '../utils' 1import { browserSleep, getCheckbox, go, isCheckboxSelected } from '../utils'
2 2
3export class AdminConfigPage { 3export class AdminConfigPage {
4 4
@@ -8,7 +8,6 @@ export class AdminConfigPage {
8 'basic-configuration': 'APPEARANCE', 8 'basic-configuration': 'APPEARANCE',
9 'instance-information': 'INSTANCE' 9 'instance-information': 'INSTANCE'
10 } 10 }
11
12 await go('/admin/config/edit-custom#' + tab) 11 await go('/admin/config/edit-custom#' + tab)
13 12
14 await $('.inner-form-title=' + waitTitles[tab]).waitForDisplayed() 13 await $('.inner-form-title=' + waitTitles[tab]).waitForDisplayed()
@@ -28,17 +27,39 @@ export class AdminConfigPage {
28 return $('#instanceCustomHomepageContent').setValue(newValue) 27 return $('#instanceCustomHomepageContent').setValue(newValue)
29 } 28 }
30 29
31 async toggleSignup () { 30 async toggleSignup (enabled: boolean) {
31 if (await isCheckboxSelected('signupEnabled') === enabled) return
32
32 const checkbox = await getCheckbox('signupEnabled') 33 const checkbox = await getCheckbox('signupEnabled')
33 34
34 await checkbox.waitForClickable() 35 await checkbox.waitForClickable()
35 await checkbox.click() 36 await checkbox.click()
36 } 37 }
37 38
39 async toggleSignupApproval (required: boolean) {
40 if (await isCheckboxSelected('signupRequiresApproval') === required) return
41
42 const checkbox = await getCheckbox('signupRequiresApproval')
43
44 await checkbox.waitForClickable()
45 await checkbox.click()
46 }
47
48 async toggleSignupEmailVerification (required: boolean) {
49 if (await isCheckboxSelected('signupRequiresEmailVerification') === required) return
50
51 const checkbox = await getCheckbox('signupRequiresEmailVerification')
52
53 await checkbox.waitForClickable()
54 await checkbox.click()
55 }
56
38 async save () { 57 async save () {
39 const button = $('input[type=submit]') 58 const button = $('input[type=submit]')
40 59
41 await button.waitForClickable() 60 await button.waitForClickable()
42 await button.click() 61 await button.click()
62
63 await browserSleep(1000)
43 } 64 }
44} 65}
diff --git a/client/e2e/src/po/admin-registration.po.ts b/client/e2e/src/po/admin-registration.po.ts
new file mode 100644
index 000000000..85234654d
--- /dev/null
+++ b/client/e2e/src/po/admin-registration.po.ts
@@ -0,0 +1,35 @@
1import { browserSleep, findParentElement, go } from '../utils'
2
3export class AdminRegistrationPage {
4
5 async navigateToRegistratonsList () {
6 await go('/admin/moderation/registrations/list')
7
8 await $('my-registration-list').waitForDisplayed()
9 }
10
11 async accept (username: string, moderationResponse: string) {
12 const usernameEl = await $('*=' + username)
13 await usernameEl.waitForDisplayed()
14
15 const tr = await findParentElement(usernameEl, async el => await el.getTagName() === 'tr')
16
17 await tr.$('.action-cell .dropdown-root').click()
18
19 const accept = await $('span*=Accept this registration')
20 await accept.waitForClickable()
21 await accept.click()
22
23 const moderationResponseTextarea = await $('#moderationResponse')
24 await moderationResponseTextarea.waitForDisplayed()
25
26 await moderationResponseTextarea.setValue(moderationResponse)
27
28 const submitButton = $('.modal-footer input[type=submit]')
29 await submitButton.waitForClickable()
30 await submitButton.click()
31
32 await browserSleep(1000)
33 }
34
35}
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts
index bc1854dbc..f1d13a2b0 100644
--- a/client/e2e/src/po/login.po.ts
+++ b/client/e2e/src/po/login.po.ts
@@ -6,7 +6,14 @@ export class LoginPage {
6 6
7 } 7 }
8 8
9 async login (username: string, password: string, url = '/login') { 9 async login (options: {
10 username: string
11 password: string
12 displayName?: string
13 url?: string
14 }) {
15 const { username, password, url = '/login', displayName = username } = options
16
10 await go(url) 17 await go(url)
11 18
12 await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`) 19 await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`)
@@ -27,27 +34,40 @@ export class LoginPage {
27 34
28 await menuToggle.click() 35 await menuToggle.click()
29 36
30 await this.ensureIsLoggedInAs(username) 37 await this.ensureIsLoggedInAs(displayName)
31 38
32 await menuToggle.click() 39 await menuToggle.click()
33 } else { 40 } else {
34 await this.ensureIsLoggedInAs(username) 41 await this.ensureIsLoggedInAs(displayName)
35 } 42 }
36 } 43 }
37 44
45 async getLoginError (username: string, password: string) {
46 await go('/login')
47
48 await $('input#username').setValue(username)
49 await $('input#password').setValue(password)
50
51 await browser.pause(1000)
52
53 await $('form input[type=submit]').click()
54
55 return $('.alert-danger').getText()
56 }
57
38 async loginAsRootUser () { 58 async loginAsRootUser () {
39 return this.login('root', 'test' + this.getSuffix()) 59 return this.login({ username: 'root', password: 'test' + this.getSuffix() })
40 } 60 }
41 61
42 loginOnPeerTube2 () { 62 loginOnPeerTube2 () {
43 return this.login('e2e', process.env.PEERTUBE2_E2E_PASSWORD, 'https://peertube2.cpy.re/login') 63 return this.login({ username: 'e2e', password: process.env.PEERTUBE2_E2E_PASSWORD, url: 'https://peertube2.cpy.re/login' })
44 } 64 }
45 65
46 async logout () { 66 async logout () {
47 const loggedInMore = $('.logged-in-more') 67 const loggedInDropdown = $('.logged-in-more .logged-in-info')
48 68
49 await loggedInMore.waitForClickable() 69 await loggedInDropdown.waitForClickable()
50 await loggedInMore.click() 70 await loggedInDropdown.click()
51 71
52 const logout = $('.dropdown-item*=Log out') 72 const logout = $('.dropdown-item*=Log out')
53 73
diff --git a/client/e2e/src/po/signup.po.ts b/client/e2e/src/po/signup.po.ts
index cc2ed7c5f..7917cdda7 100644
--- a/client/e2e/src/po/signup.po.ts
+++ b/client/e2e/src/po/signup.po.ts
@@ -27,42 +27,39 @@ export class SignupPage {
27 return terms.click() 27 return terms.click()
28 } 28 }
29 29
30 async getEndMessage () {
31 const alert = $('.pt-alert-primary')
32 await alert.waitForDisplayed()
33
34 return alert.getText()
35 }
36
37 async fillRegistrationReason (reason: string) {
38 await $('#registrationReason').setValue(reason)
39 }
40
30 async fillAccountStep (options: { 41 async fillAccountStep (options: {
31 displayName: string
32 username: string 42 username: string
33 email: string 43 password?: string
34 password: string 44 displayName?: string
45 email?: string
35 }) { 46 }) {
36 if (options.displayName) { 47 await $('#displayName').setValue(options.displayName || `${options.username} display name`)
37 await $('#displayName').setValue(options.displayName)
38 }
39
40 if (options.username) {
41 await $('#username').setValue(options.username)
42 }
43 48
44 if (options.email) { 49 await $('#username').setValue(options.username)
45 // Fix weird bug on firefox that "cannot scroll into view" when using just `setValue` 50 await $('#password').setValue(options.password || 'password')
46 await $('#email').scrollIntoView(false)
47 await $('#email').waitForClickable()
48 await $('#email').setValue(options.email)
49 }
50 51
51 if (options.password) { 52 // Fix weird bug on firefox that "cannot scroll into view" when using just `setValue`
52 await $('#password').setValue(options.password) 53 await $('#email').scrollIntoView(false)
53 } 54 await $('#email').waitForClickable()
55 await $('#email').setValue(options.email || `${options.username}@example.com`)
54 } 56 }
55 57
56 async fillChannelStep (options: { 58 async fillChannelStep (options: {
57 displayName: string
58 name: string 59 name: string
60 displayName?: string
59 }) { 61 }) {
60 if (options.displayName) { 62 await $('#displayName').setValue(options.displayName || `${options.name} channel display name`)
61 await $('#displayName').setValue(options.displayName) 63 await $('#name').setValue(options.name)
62 }
63
64 if (options.name) {
65 await $('#name').setValue(options.name)
66 }
67 } 64 }
68} 65}