dev #5

Merged
zhangxiang merged 159 commits from dev into main 2026-04-12 17:39:08 +08:00
Showing only changes of commit b150ad346b - Show all commits
+15 -5
View File
@@ -66,7 +66,7 @@ export class AdminContentPage {
await this.page.click('button:has-text("发布")'); await this.page.click('button:has-text("发布")');
try { try {
await this.page.waitForURL(/\/admin\/content\/[a-zA-Z0-9]+/, { timeout: 15000 }); await this.page.waitForURL(/\/admin\/content\/[a-zA-Z0-9_-]+/, { timeout: 15000 });
} catch { } catch {
console.log('等待URL跳转失败,当前URL:', this.page.url()); console.log('等待URL跳转失败,当前URL:', this.page.url());
@@ -86,7 +86,7 @@ export class AdminContentPage {
const url = this.page.url(); const url = this.page.url();
console.log('最终URL:', url); console.log('最终URL:', url);
const match = url.match(/\/admin\/content\/([a-zA-Z0-9]+)/); const match = url.match(/\/admin\/content\/([a-zA-Z0-9_-]+)/);
const contentId = match ? match[1] : null; const contentId = match ? match[1] : null;
if (!contentId) { if (!contentId) {
@@ -152,7 +152,7 @@ export class AdminContentPage {
await this.goto(); await this.goto();
await this.page.waitForLoadState('domcontentloaded'); await this.page.waitForLoadState('domcontentloaded');
await this.page.waitForTimeout(2000); await this.page.waitForTimeout(3000);
let row = this.page.locator(`tr:has-text("${title}")`); let row = this.page.locator(`tr:has-text("${title}")`);
let isVisible = await row.count() > 0; let isVisible = await row.count() > 0;
@@ -164,18 +164,28 @@ export class AdminContentPage {
if (await searchInput.count() > 0) { if (await searchInput.count() > 0) {
await searchInput.fill(title); await searchInput.fill(title);
await this.page.keyboard.press('Enter'); await this.page.keyboard.press('Enter');
await this.page.waitForTimeout(3000);
row = this.page.locator(`tr:has-text("${title}")`);
isVisible = await row.count() > 0;
if (!isVisible) {
console.log('搜索无结果,清空搜索框');
await searchInput.fill('');
await this.page.keyboard.press('Enter');
await this.page.waitForTimeout(2000); await this.page.waitForTimeout(2000);
row = this.page.locator(`tr:has-text("${title}")`); row = this.page.locator(`tr:has-text("${title}")`);
isVisible = await row.count() > 0; isVisible = await row.count() > 0;
} }
} }
}
if (!isVisible) { if (!isVisible) {
console.log('搜索后仍未找到,尝试刷新页面'); console.log('搜索后仍未找到,尝试刷新页面');
await this.page.reload({ waitUntil: 'domcontentloaded' }); await this.page.reload({ waitUntil: 'domcontentloaded' });
await this.page.waitForSelector('table', { timeout: 10000, state: 'visible' }); await this.page.waitForSelector('table', { timeout: 10000, state: 'visible' });
await this.page.waitForTimeout(2000); await this.page.waitForTimeout(3000);
row = this.page.locator(`tr:has-text("${title}")`); row = this.page.locator(`tr:has-text("${title}")`);
isVisible = await row.count() > 0; isVisible = await row.count() > 0;
@@ -192,7 +202,7 @@ export class AdminContentPage {
} }
} }
await expect(row.first()).toBeVisible({ timeout: 15000 }); await expect(row.first()).toBeVisible({ timeout: 20000 });
console.log(`✅ 找到内容: ${title}`); console.log(`✅ 找到内容: ${title}`);
} }