fix: update E2E test selectors and improve login stability
- Fix selectors to use config keys instead of Chinese labels - Add page load waiting and element visibility checks - Improve global setup with better error handling - Update all config-linkage tests with correct selectors
This commit is contained in:
@@ -17,7 +17,7 @@ test.describe('前后台配置参数测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const newsConfig = adminPage.locator('text=新闻模块配置').locator('..').locator('..');
|
||||
const newsConfig = adminPage.locator('text=feature_news').locator('..').locator('..');
|
||||
|
||||
await newsConfig.locator('input[type="number"]').fill('2');
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
@@ -60,7 +60,7 @@ test.describe('前后台配置参数测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const newsConfig = adminPage.locator('text=新闻模块配置').locator('..').locator('..');
|
||||
const newsConfig = adminPage.locator('text=feature_news').locator('..').locator('..');
|
||||
|
||||
const categoriesTextarea = newsConfig.locator('textarea');
|
||||
await categoriesTextarea.fill('公司新闻\n产品发布');
|
||||
@@ -99,7 +99,7 @@ test.describe('前后台配置参数测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const newsConfig = adminPage.locator('text=新闻模块配置').locator('..').locator('..');
|
||||
const newsConfig = adminPage.locator('text=feature_news').locator('..').locator('..');
|
||||
|
||||
await newsConfig.locator('select').selectOption('desc');
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
@@ -142,7 +142,7 @@ test.describe('前后台配置参数测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const productsConfig = adminPage.locator('text=产品模块配置').locator('..').locator('..');
|
||||
const productsConfig = adminPage.locator('text=feature_products').locator('..').locator('..');
|
||||
|
||||
await productsConfig.locator('text=showPricing').locator('..').locator('input[type="checkbox"]').check();
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
@@ -182,9 +182,9 @@ test.describe('前后台配置参数测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const productsConfig = adminPage.locator('text=产品模块配置').locator('..').locator('..');
|
||||
const productsConfig = adminPage.locator('text=feature_products').locator('..').locator('..');
|
||||
|
||||
const featuredProductsTextarea = productsConfig.locator('text=featuredProducts').locator('..').locator('textarea');
|
||||
const featuredProductsTextarea = productsConfig.locator('textarea');
|
||||
await featuredProductsTextarea.fill('erp');
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
@@ -17,7 +17,7 @@ test.describe('前后台配置联动测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const servicesConfig = adminPage.locator('text=服务模块配置').locator('..').locator('..');
|
||||
const servicesConfig = adminPage.locator('text=feature_services').locator('..').locator('..');
|
||||
await servicesConfig.locator('input[type="checkbox"]').first().check();
|
||||
await servicesConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
@@ -53,7 +53,7 @@ test.describe('前后台配置联动测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const productsConfig = adminPage.locator('text=产品模块配置').locator('..').locator('..');
|
||||
const productsConfig = adminPage.locator('text=feature_products').locator('..').locator('..');
|
||||
await productsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await productsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
@@ -89,7 +89,7 @@ test.describe('前后台配置联动测试', () => {
|
||||
await adminPage.goto('/admin/settings');
|
||||
await adminPage.waitForLoadState('networkidle');
|
||||
|
||||
const newsConfig = adminPage.locator('text=新闻模块配置').locator('..').locator('..');
|
||||
const newsConfig = adminPage.locator('text=feature_news').locator('..').locator('..');
|
||||
await newsConfig.locator('input[type="checkbox"]').first().check();
|
||||
await newsConfig.locator('button:has-text("保存")').click();
|
||||
await adminPage.waitForSelector('text=保存成功', { timeout: 5000 });
|
||||
|
||||
Reference in New Issue
Block a user