sync from local backup
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('语言切换功能测试', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.reload();
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
});
|
||||
|
||||
test('页面加载成功并显示导航菜单', async ({ page }) => {
|
||||
const navItems = page.locator('.ant-menu-item');
|
||||
await expect(navItems.first()).toBeVisible();
|
||||
const count = await navItems.count();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('语言切换器显示6种语言选项', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const items = page.locator('.language-switcher-item');
|
||||
await expect(items).toHaveCount(6);
|
||||
});
|
||||
|
||||
test('切换到英文', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const englishOption = page.locator('.language-switcher-item:has-text("English")');
|
||||
await englishOption.click();
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('Home');
|
||||
});
|
||||
|
||||
test('切换到日语', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const japaneseOption = page.locator('.language-switcher-item:has-text("日本語")');
|
||||
await japaneseOption.click();
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('ホーム');
|
||||
});
|
||||
|
||||
test('切换到韩语', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const koreanOption = page.locator('.language-switcher-item:has-text("한국어")');
|
||||
await koreanOption.click();
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('홈');
|
||||
});
|
||||
|
||||
test('切换到繁体中文', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const zhTWOption = page.locator('.language-switcher-item:has-text("繁體中文")');
|
||||
await zhTWOption.click();
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('首頁');
|
||||
});
|
||||
|
||||
test('切换到俄语', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const russianOption = page.locator('.language-switcher-item:has-text("Русский")');
|
||||
await russianOption.click();
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('Главная');
|
||||
});
|
||||
|
||||
test('语言选择持久化', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const englishOption = page.locator('.language-switcher-item:has-text("English")');
|
||||
await englishOption.click();
|
||||
|
||||
await page.reload();
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
const navHome = page.locator('.ant-menu-item').first();
|
||||
await expect(navHome).toContainText('Home');
|
||||
});
|
||||
|
||||
test('搜索框占位符随语言切换', async ({ page }) => {
|
||||
const switcher = page.locator('.language-switcher-trigger');
|
||||
await switcher.click();
|
||||
|
||||
const englishOption = page.locator('.language-switcher-item:has-text("English")');
|
||||
await englishOption.click();
|
||||
|
||||
const searchInput = page.locator('.navbar-search-input input');
|
||||
await expect(searchInput).toHaveAttribute('placeholder', 'Search...');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user