Files
makelore/tests/e2e/language-russian.spec.ts
brother7 724290e864 实现 Makelore 一键提交审核
需求:让非专业用户在项目操作区一次提交,运营审核通过后直接发布。

实现:由 Electron Main 完成安全打包、自动版本、幂等重试和状态脱敏;补齐友好失败反馈、唯一提交入口及隔离 Electron E2E fixture。
2026-08-08 14:44:08 +08:00

117 lines
4.5 KiB
TypeScript

import type { Page } from '@playwright/test';
import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron';
async function openSettingsFromSidebarAccountMenu(page: Page): Promise<void> {
await page.getByTestId('sidebar-member-menu-trigger').click();
await page.getByTestId('sidebar-nav-settings').click();
}
async function expectSidebarSettingsLabel(page: Page, label: string): Promise<void> {
await page.getByTestId('sidebar-member-menu-trigger').click();
await expect(page.getByTestId('sidebar-nav-settings')).toContainText(label);
await page.keyboard.press('Escape');
}
test.describe('Russian language localization', () => {
test('shows Russian language option in setup wizard', async ({ launchElectronApp }) => {
const app = await launchElectronApp();
try {
const page = await getStableWindow(app);
// Should see the setup wizard
await expect(page.getByTestId('setup-page')).toBeVisible();
// Should have Russian language button visible
const russianButton = page.locator('button', { hasText: 'Русский' });
await expect(russianButton).toBeVisible();
} finally {
await closeElectronApp(app);
}
});
test('can switch to Russian language in setup wizard', async ({ launchElectronApp }) => {
const app = await launchElectronApp();
try {
const page = await getStableWindow(app);
await expect(page.getByTestId('setup-page')).toBeVisible();
// Click Russian language button
const russianButton = page.locator('button', { hasText: 'Русский' });
await russianButton.click();
// Verify UI renders in Russian by checking for Russian-only text
// "Добро пожаловать" is unique to Russian and won't appear in English
await expect(page.locator('h2')).toContainText('Добро пожаловать');
} finally {
await closeElectronApp(app);
}
});
test('Russian language persists after skipping setup', async ({ launchElectronApp }) => {
const app = await launchElectronApp();
let relaunchedApp: Awaited<ReturnType<typeof launchElectronApp>> | null = null;
let firstAppClosed = false;
try {
const page = await getStableWindow(app);
await expect(page.getByTestId('setup-page')).toBeVisible();
// Switch to Russian
const russianButton = page.locator('button', { hasText: 'Русский' });
await russianButton.click();
// Skip setup
await page.getByTestId('setup-skip-button').click();
await expect(page.getByRole('button', { name: 'Continue in browser' })).toBeVisible();
await closeElectronApp(app);
firstAppClosed = true;
relaunchedApp = await launchElectronApp({ skipSetup: true });
const relaunchedPage = await getStableWindow(relaunchedApp);
await expect(relaunchedPage.getByTestId('main-layout')).toBeVisible();
// Bypass authentication only for the relaunch so the persisted setting
// can be verified without weakening the production login gate.
await openSettingsFromSidebarAccountMenu(relaunchedPage);
await expect(relaunchedPage).toHaveURL(/\/settings$/);
await expect(relaunchedPage.getByRole('heading', { name: 'Настройки', exact: true })).toBeVisible();
// Verify sidebar shows Russian text (not English)
// "Настройки" is Russian-only, English is "Settings"
await expectSidebarSettingsLabel(relaunchedPage, 'Настройки');
} finally {
if (relaunchedApp) await closeElectronApp(relaunchedApp);
if (!firstAppClosed) await closeElectronApp(app);
}
});
test('can switch to Russian in Settings page', async ({ launchElectronApp }) => {
const app = await launchElectronApp({ skipSetup: true });
try {
const page = await getStableWindow(app);
await expect(page.getByTestId('main-layout')).toBeVisible();
// Navigate to Settings (in English by default after skipSetup)
await openSettingsFromSidebarAccountMenu(page);
await expect(page).toHaveURL(/\/settings$/);
// Select Russian from the current settings control.
await page.locator('#language').selectOption('ru');
await expect(page.getByRole('heading', { name: 'Настройки', exact: true })).toBeVisible();
// Verify sidebar switched to Russian
// "Настройки" is Russian-only, English is "Settings"
await expectSidebarSettingsLabel(page, 'Настройки');
} finally {
await closeElectronApp(app);
}
});
});