Add E2E tests for signup
This commit is contained in:
parent
2b621ac0eb
commit
1db86422eb
|
@ -1,4 +1,4 @@
|
||||||
import { browserSleep, go } from '../utils'
|
import { getCheckbox, go } from '../utils'
|
||||||
|
|
||||||
export class AdminConfigPage {
|
export class AdminConfigPage {
|
||||||
|
|
||||||
|
@ -22,8 +22,13 @@ export class AdminConfigPage {
|
||||||
return $('#instanceCustomHomepageContent').setValue(newValue)
|
return $('#instanceCustomHomepageContent').setValue(newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toggleSignup () {
|
||||||
|
const checkbox = await getCheckbox('signupEnabled')
|
||||||
|
await checkbox.click()
|
||||||
|
}
|
||||||
|
|
||||||
async save () {
|
async save () {
|
||||||
await $('input[type=submit]').click()
|
const button = $('input[type=submit]')
|
||||||
await browserSleep(200)
|
await button.click()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { browserSleep, go } from '../utils'
|
||||||
|
|
||||||
export class AdminPluginPage {
|
export class AdminPluginPage {
|
||||||
|
|
||||||
async navigateToSearch () {
|
async navigateToPluginSearch () {
|
||||||
await go('/admin/plugins/search')
|
await go('/admin/plugins/search')
|
||||||
|
|
||||||
await $('my-plugin-search').waitForDisplayed()
|
await $('my-plugin-search').waitForDisplayed()
|
||||||
|
|
|
@ -15,9 +15,7 @@ export class LoginPage {
|
||||||
|
|
||||||
await $('form input[type=submit]').click()
|
await $('form input[type=submit]').click()
|
||||||
|
|
||||||
await this.getLoggedInInfoElem().waitForExist()
|
await this.ensureIsLoggedInAs('root')
|
||||||
|
|
||||||
await expect(this.getLoggedInInfoElem()).toHaveText('root')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async logout () {
|
async logout () {
|
||||||
|
@ -31,6 +29,12 @@ export class LoginPage {
|
||||||
await $('.login-buttons-block').waitForDisplayed()
|
await $('.login-buttons-block').waitForDisplayed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async ensureIsLoggedInAs (displayName: string) {
|
||||||
|
await this.getLoggedInInfoElem().waitForExist()
|
||||||
|
|
||||||
|
await expect(this.getLoggedInInfoElem()).toHaveText(displayName)
|
||||||
|
}
|
||||||
|
|
||||||
private getLoggedInInfoElem () {
|
private getLoggedInInfoElem () {
|
||||||
return $('.logged-in-display-name')
|
return $('.logged-in-display-name')
|
||||||
}
|
}
|
||||||
|
|
64
client/e2e/src/po/signup.po.ts
Normal file
64
client/e2e/src/po/signup.po.ts
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import { getCheckbox } from '../utils'
|
||||||
|
|
||||||
|
export class SignupPage {
|
||||||
|
|
||||||
|
getRegisterMenuButton () {
|
||||||
|
return $('.create-account-button')
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickOnRegisterInMenu () {
|
||||||
|
const button = this.getRegisterMenuButton()
|
||||||
|
|
||||||
|
await button.waitForDisplayed()
|
||||||
|
await button.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateStep () {
|
||||||
|
const next = $('button[type=submit]')
|
||||||
|
|
||||||
|
await next.waitForClickable()
|
||||||
|
await next.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkTerms () {
|
||||||
|
const terms = await getCheckbox('terms')
|
||||||
|
|
||||||
|
return terms.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fillAccountStep (options: {
|
||||||
|
displayName: string
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
password: string
|
||||||
|
}) {
|
||||||
|
if (options.displayName) {
|
||||||
|
await $('#displayName').setValue(options.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.username) {
|
||||||
|
await $('#username').setValue(options.username)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.email) {
|
||||||
|
await $('#email').setValue(options.email)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.password) {
|
||||||
|
await $('#password').setValue(options.password)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fillChannelStep (options: {
|
||||||
|
displayName: string
|
||||||
|
name: string
|
||||||
|
}) {
|
||||||
|
if (options.displayName) {
|
||||||
|
await $('#displayName').setValue(options.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.name) {
|
||||||
|
await $('#name').setValue(options.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,7 +34,7 @@ describe('Plugins', () => {
|
||||||
it('Should install hello world plugin', async () => {
|
it('Should install hello world plugin', async () => {
|
||||||
await loginPage.loginAsRootUser()
|
await loginPage.loginAsRootUser()
|
||||||
|
|
||||||
await adminPluginPage.navigateToSearch()
|
await adminPluginPage.navigateToPluginSearch()
|
||||||
await adminPluginPage.search('hello-world')
|
await adminPluginPage.search('hello-world')
|
||||||
await adminPluginPage.installHelloWorld()
|
await adminPluginPage.installHelloWorld()
|
||||||
await browser.refresh()
|
await browser.refresh()
|
||||||
|
|
87
client/e2e/src/suites-local/signup.e2e-spec.ts
Normal file
87
client/e2e/src/suites-local/signup.e2e-spec.ts
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
import { AdminConfigPage } from '../po/admin-config.po'
|
||||||
|
import { LoginPage } from '../po/login.po'
|
||||||
|
import { SignupPage } from '../po/signup.po'
|
||||||
|
import { waitServerUp } from '../utils'
|
||||||
|
|
||||||
|
describe('Signup', () => {
|
||||||
|
let loginPage: LoginPage
|
||||||
|
let adminConfigPage: AdminConfigPage
|
||||||
|
let signupPage: SignupPage
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
await waitServerUp()
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
loginPage = new LoginPage()
|
||||||
|
adminConfigPage = new AdminConfigPage()
|
||||||
|
signupPage = new SignupPage()
|
||||||
|
|
||||||
|
await browser.maximizeWindow()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should disable signup', async () => {
|
||||||
|
await loginPage.loginAsRootUser()
|
||||||
|
|
||||||
|
await adminConfigPage.navigateTo('basic-configuration')
|
||||||
|
await adminConfigPage.toggleSignup()
|
||||||
|
|
||||||
|
await adminConfigPage.save()
|
||||||
|
|
||||||
|
await loginPage.logout()
|
||||||
|
await browser.refresh()
|
||||||
|
|
||||||
|
expect(signupPage.getRegisterMenuButton()).not.toBeDisplayed()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should enable signup', async () => {
|
||||||
|
await loginPage.loginAsRootUser()
|
||||||
|
|
||||||
|
await adminConfigPage.navigateTo('basic-configuration')
|
||||||
|
await adminConfigPage.toggleSignup()
|
||||||
|
|
||||||
|
await adminConfigPage.save()
|
||||||
|
|
||||||
|
await loginPage.logout()
|
||||||
|
await browser.refresh()
|
||||||
|
|
||||||
|
expect(signupPage.getRegisterMenuButton()).toBeDisplayed()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should go on signup page', async function () {
|
||||||
|
await signupPage.clickOnRegisterInMenu()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should validate the first step (about page)', async function () {
|
||||||
|
await signupPage.validateStep()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should validate the second step (terms)', async function () {
|
||||||
|
await signupPage.checkTerms()
|
||||||
|
await signupPage.validateStep()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should validate the third step (account)', async function () {
|
||||||
|
await signupPage.fillAccountStep({
|
||||||
|
displayName: 'user 1',
|
||||||
|
username: 'user_1',
|
||||||
|
email: 'user_1@example.com',
|
||||||
|
password: 'my_super_password'
|
||||||
|
})
|
||||||
|
|
||||||
|
await signupPage.validateStep()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should validate the third step (channel)', async function () {
|
||||||
|
await signupPage.fillChannelStep({
|
||||||
|
displayName: 'user 1 channel',
|
||||||
|
name: 'user_1_channel'
|
||||||
|
})
|
||||||
|
|
||||||
|
await signupPage.validateStep()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should be logged in', async function () {
|
||||||
|
await loginPage.ensureIsLoggedInAs('user 1')
|
||||||
|
})
|
||||||
|
})
|
|
@ -1,5 +1,8 @@
|
||||||
function getCheckbox (name: string) {
|
async function getCheckbox (name: string) {
|
||||||
return $(`my-peertube-checkbox input[id=${name}]`).parentElement()
|
const input = $(`my-peertube-checkbox input[id=${name}]`)
|
||||||
|
await input.waitForExist()
|
||||||
|
|
||||||
|
return input.parentElement()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectCustomSelect (id: string, valueLabel: string) {
|
async function selectCustomSelect (id: string, valueLabel: string) {
|
||||||
|
|
|
@ -18,9 +18,6 @@ function runServer (appInstance: string, config: any = {}) {
|
||||||
log: {
|
log: {
|
||||||
level: 'warn'
|
level: 'warn'
|
||||||
},
|
},
|
||||||
signup: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
transcoding: {
|
transcoding: {
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user