test(e2e): wait for admin console binding

This commit is contained in:
rookiestar28
2026-05-31 08:24:59 +08:00
parent e03c4d527e
commit ab4449f6de
3 changed files with 24 additions and 5 deletions
+9 -3
View File
@@ -1,5 +1,10 @@
import { expect, test } from '@playwright/test';
import { clickTab, mockComfyUiCore, waitForOpenClawReady } from '../utils/helpers.js';
import {
clickTab,
mockComfyUiCore,
waitForAdminConsoleReady,
waitForOpenClawReady,
} from '../utils/helpers.js';
const pendingApproval = {
approval_id: 'apr-001',
@@ -177,9 +182,10 @@ test.describe('Approvals surfaces', () => {
await expect(page.locator('#apr-list .openclaw-list-item').first()).toContainText('apr-001');
await page.goto(new URL('/web/admin_console.html', baseURL).toString());
await waitForAdminConsoleReady(page);
await page.locator('#refreshApprovals').click();
await expect(page.locator('#approvalsList')).toContainText('apr-001');
await expect(page.locator('#approvalsList')).toContainText('render_portrait');
await expect(page.locator('#approvalsList')).toContainText('apr-001', { timeout: 15000 });
await expect(page.locator('#approvalsList')).toContainText('render_portrait', { timeout: 15000 });
});
});
+4 -2
View File
@@ -4,6 +4,7 @@ import {
mockCompatApprovalsList,
mockComfyUiCore,
mockRemoteAdminBaseline,
waitForAdminConsoleReady,
waitForOpenClawReady,
} from '../utils/helpers.js';
@@ -63,8 +64,9 @@ test.describe('Desktop host parity lane', () => {
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-embedded-frontend', '1.43.18');
await expect(page.locator('body')).toHaveAttribute('data-openclaw-desktop-frontend-parity', 'lagging');
await waitForAdminConsoleReady(page);
await page.locator('#refreshApprovals').click();
await expect(page.locator('#approvalsList')).toContainText('apr-r166-001');
await expect(page.locator('#approvalsList')).toContainText('desktop_host_smoke');
await expect(page.locator('#approvalsList')).toContainText('apr-r166-001', { timeout: 15000 });
await expect(page.locator('#approvalsList')).toContainText('desktop_host_smoke', { timeout: 15000 });
});
});
+11
View File
@@ -627,6 +627,17 @@ export async function waitForOpenClawReady(page) {
}
}
export async function waitForAdminConsoleReady(page) {
const timeoutMs = resolveUiTimeoutMs();
// IMPORTANT: admin_console.html exposes static buttons before its module
// binds handlers; waiting here prevents Windows CI from losing early clicks.
await page.waitForFunction(
() => typeof document.getElementById('refreshApprovals')?.onclick === 'function',
null,
{ timeout: timeoutMs },
);
}
export async function clickTab(page, title) {
const tab = page.locator('.openclaw-tab', { hasText: title });
const timeoutMs = resolveUiTimeoutMs();