test: add frontend-backend configuration linkage E2E tests
- Add config-toggle.spec.ts for module show/hide tests - Add config-params.spec.ts for configuration parameter tests - Test Services module toggle and items filtering - Test Products module toggle, pricing display, and featured products - Test News module toggle, display count, categories, and sort order - Verify real-time configuration updates between admin and frontend
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('前后台配置联动测试', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
});
|
||||
|
||||
test('配置开关 - 服务模块显示/隐藏', async ({ page, context }) => {
|
||||
const adminPage = await context.newPage();
|
||||
|
||||
await adminPage.goto('/admin/login');
|
||||
await adminPage.fill('input[type="email"]', 'admin@novalon.cn');
|
||||
await adminPage.fill('input[type="password"]', 'admin123456');
|
||||
await adminPage.click('button[type="submit"]');
|
||||
await adminPage.waitForURL('/admin');
|
||||
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const servicesConfig = adminPage.locator('text=服务模块配置').locator('..').locator('..');
|
||||
await servicesConfig.locator('input[type="checkbox"]').first().check();
|
||||
await servicesConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.goto('/');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#services')).toBeVisible();
|
||||
|
||||
await servicesConfig.locator('input[type="checkbox"]').first().uncheck();
|
||||
await servicesConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.reload();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#services')).not.toBeVisible();
|
||||
|
||||
await servicesConfig.locator('input[type="checkbox"]').first().check();
|
||||
await servicesConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await adminPage.close();
|
||||
});
|
||||
|
||||
test('配置开关 - 产品模块显示/隐藏', async ({ page, context }) => {
|
||||
const adminPage = await context.newPage();
|
||||
|
||||
await adminPage.goto('/admin/login');
|
||||
await adminPage.fill('input[type="email"]', 'admin@novalon.cn');
|
||||
await adminPage.fill('input[type="password"]', 'admin123456');
|
||||
await adminPage.click('button[type="submit"]');
|
||||
await adminPage.waitForURL('/admin');
|
||||
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const productsConfig = adminPage.locator('text=产品模块配置').locator('..').locator('..');
|
||||
await productsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.goto('/');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#products')).toBeVisible();
|
||||
|
||||
await productsConfig.locator('input[type="checkbox"]').first().uncheck();
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.reload();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#products')).not.toBeVisible();
|
||||
|
||||
await productsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await adminPage.close();
|
||||
});
|
||||
|
||||
test('配置开关 - 新闻模块显示/隐藏', async ({ page, context }) => {
|
||||
const adminPage = await context.newPage();
|
||||
|
||||
await adminPage.goto('/admin/login');
|
||||
await adminPage.fill('input[type="email"]', 'admin@novalon.cn');
|
||||
await adminPage.fill('input[type="password"]', 'admin123456');
|
||||
await adminPage.click('button[type="submit"]');
|
||||
await adminPage.waitForURL('/admin');
|
||||
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const newsConfig = adminPage.locator('text=新闻模块配置').locator('..').locator('..');
|
||||
await newsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.goto('/');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#news')).toBeVisible();
|
||||
|
||||
await newsConfig.locator('input[type="checkbox"]').first().uncheck();
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await page.reload();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('#news')).not.toBeVisible();
|
||||
|
||||
await newsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
await adminPage.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user