From aaae2910e73466d2e35c88ad15f059f91c8bae87 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Aug 2025 08:56:49 +0200 Subject: [PATCH] Save --- client/e2e/src/po/admin-config.po.ts | 25 ++-- .../src/suites-local/page-crash.e2e-spec.ts | 121 ++++++++++++++++++ 2 files changed, 130 insertions(+), 16 deletions(-) create mode 100644 client/e2e/src/suites-local/page-crash.e2e-spec.ts diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts index d04e38ec8..c04d6c138 100644 --- a/client/e2e/src/po/admin-config.po.ts +++ b/client/e2e/src/po/admin-config.po.ts @@ -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) } diff --git a/client/e2e/src/suites-local/page-crash.e2e-spec.ts b/client/e2e/src/suites-local/page-crash.e2e-spec.ts new file mode 100644 index 000000000..437513a5b --- /dev/null +++ b/client/e2e/src/suites-local/page-crash.e2e-spec.ts @@ -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) { + 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`)) + }) +})