1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 01:39:37 +02:00
This commit is contained in:
Chocobozzz 2025-08-20 08:56:49 +02:00
parent 507cedca1c
commit aaae2910e7
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 130 additions and 16 deletions

View file

@ -2,25 +2,18 @@ import { NSFWPolicyType } from '@peertube/peertube-models'
import { browserSleep, go, setCheckboxEnabled } from '../utils'
export class AdminConfigPage {
async navigateTo (tab: 'instance-homepage' | 'basic-configuration' | 'instance-information' | 'live') {
const waitTitles = {
'instance-homepage': 'INSTANCE HOMEPAGE',
'basic-configuration': 'APPEARANCE',
'instance-information': 'INSTANCE',
'live': 'LIVE'
}
const url = '/admin/settings/config/edit-custom#' + tab
async navigateTo (page: 'information' | 'live' | 'general' | 'homepage') {
const url = '/admin/settings/config/' + page
if (await browser.getUrl() !== url) {
await go('/admin/settings/config/edit-custom#' + tab)
await go(url)
}
await $('h2=' + waitTitles[tab]).waitForDisplayed()
await $('a.active[href=' + url + ']').waitForDisplayed()
}
async updateNSFWSetting (newValue: NSFWPolicyType) {
await this.navigateTo('instance-information')
await this.navigateTo('information')
const elem = $(`#instanceDefaultNSFWPolicy-${newValue} + label`)
@ -32,25 +25,25 @@ export class AdminConfigPage {
}
async updateHomepage (newValue: string) {
await this.navigateTo('instance-homepage')
await this.navigateTo('homepage')
return $('#instanceCustomHomepageContent').setValue(newValue)
}
async toggleSignup (enabled: boolean) {
await this.navigateTo('basic-configuration')
await this.navigateTo('general')
return setCheckboxEnabled('signupEnabled', enabled)
}
async toggleSignupApproval (required: boolean) {
await this.navigateTo('basic-configuration')
await this.navigateTo('general')
return setCheckboxEnabled('signupRequiresApproval', required)
}
async toggleSignupEmailVerification (required: boolean) {
await this.navigateTo('basic-configuration')
await this.navigateTo('general')
return setCheckboxEnabled('signupRequiresEmailVerification', required)
}

View file

@ -0,0 +1,121 @@
import { AdminConfigPage } from '../po/admin-config.po'
import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
import { SignupPage } from '../po/signup.po'
import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { getScreenshotPath, go, isMobileDevice, isSafari, selectCustomSelect, waitServerUp } from '../utils'
// These tests help to notice crash with invalid translated strings
describe('Page crash', () => {
let videoPublishPage: VideoPublishPage
let loginPage: LoginPage
let videoWatchPage: VideoWatchPage
let adminConfigPage: AdminConfigPage
let myAccountPage: MyAccountPage
let lastLanguage = ''
const languages = [
'العربية',
'Català',
'Čeština',
'Deutsch',
'ελληνικά',
'Esperanto',
'Español',
'Euskara',
'فارسی',
'Suomi',
'Français',
'Gàidhlig',
'Galego',
'Hrvatski',
'Magyar',
'Íslenska',
'Italiano',
'日本語',
'Taqbaylit',
'Norsk bokmål',
'Nederlands',
'Norsk nynorsk',
'Occitan',
'Polski',
'Português (Brasil)',
'Português (Portugal)',
'Pусский',
'Slovenčina',
'Shqip',
'Svenska',
'ไทย',
'Toki Pona',
'Türkçe',
'украї́нська мо́ва',
'Tiếng Việt',
'简体中文(中国)',
'繁體中文(台灣)'
]
async function testForAllLanguages (action: () => Promise<void>) {
for (const language of languages) {
lastLanguage = language
await go('/')
await $('.settings-button').waitForClickable()
await $('.settings-button').click()
await selectCustomSelect('language', language)
await action()
}
}
before(async () => {
await waitServerUp()
myAccountPage = new MyAccountPage()
adminConfigPage = new AdminConfigPage()
loginPage = new LoginPage(isMobileDevice())
videoPublishPage = new VideoPublishPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
await browser.maximizeWindow()
await loginPage.loginAsRootUser()
})
it('Should set a homepage', async function () {
await testForAllLanguages(async () => {
await adminConfigPage.updateHomepage('My custom homepage content')
// All tests
await go('/home')
await $('*=My custom homepage content').waitForDisplayed()
})
})
it('Should upload and watch a video', async function () {
await testForAllLanguages(async () => {
await videoPublishPage.navigateTo()
await videoPublishPage.uploadVideo('video3.mp4')
await videoPublishPage.validSecondStep('video')
await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName('video')
})
})
it('Should go on client pages and not crash', async function () {
await testForAllLanguages(async () => {
await go('/videos/overview')
await $('h1*=Home').waitForDisplayed()
})
})
after(async () => {
await browser.saveScreenshot(getScreenshotPath(`after-page-crash-test-${lastLanguage}.png`))
})
})