From 68a8b4c7e24d6b051870f23e93510b081627e1a4 Mon Sep 17 00:00:00 2001 From: "z.zhang" Date: Tue, 8 Sep 2026 00:36:13 +0800 Subject: [PATCH] test: stabilize closed-loop browser E2E --- apps/web/e2e/closed-loop-scheduling.spec.ts | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/web/e2e/closed-loop-scheduling.spec.ts b/apps/web/e2e/closed-loop-scheduling.spec.ts index 788028f..44f04b8 100644 --- a/apps/web/e2e/closed-loop-scheduling.spec.ts +++ b/apps/web/e2e/closed-loop-scheduling.spec.ts @@ -42,9 +42,13 @@ async function loginThroughUi(page: Page, username = 'planner'): Promise { } async function openOrders(page: Page): Promise { + // A document reload briefly renders AuthGate, whose guest rail exposes the + // same data-tip. Wait for the authenticated shell and exclude that rail so + // the click cannot be consumed by the login dialog during bootstrap. + await expect(page.locator('.account-trigger:not(.guest-login-trigger)')).toBeVisible({ timeout: 60_000 }); const existing = page.getByTestId('closed-loop-aps-stages'); if (await existing.isVisible().catch(() => false)) return; - const trigger = page.locator('.right-rail button[data-tip="\u8ba2\u5355\u7ba1\u7406"]'); + const trigger = page.locator('.right-rail:not(.guest-right-rail) button[data-tip="\u8ba2\u5355\u7ba1\u7406"]'); await expect(trigger).toBeVisible({ timeout: 30_000 }); await trigger.click(); await expect(page.getByTestId('closed-loop-aps-stages')).toBeVisible({ timeout: 30_000 }); @@ -137,8 +141,8 @@ test.describe('Round 65 real browser closed-loop APS E2E (isolated backend)', () await expect(tagClass(page, 'netting')).toContainText('230'); await expect(tagClass(page, 'admission')).toContainText('0'); await expect(page.getByTestId('closed-loop-stage-draft')).toContainText(/VL\s*0\s*\/\s*WO\s*0/); - expect(await tagClass(page, 'publish').getAttribute('class')).not.toMatch(/ant-tag-(green|gold)/); - expect(await tagClass(page, 'mes').getAttribute('class')).not.toMatch(/ant-tag-(green|gold)/); + await expect(tagClass(page, 'publish')).toHaveText('\u672a\u5f00\u653e'); + await expect(tagClass(page, 'mes')).toHaveText('\u672a\u5f00\u653e'); await openMakeTab(page); await expect(page.getByTestId('closed-loop-manufacturing-demands')).toBeVisible(); @@ -198,8 +202,8 @@ test.describe('Round 65 real browser closed-loop APS E2E (isolated backend)', () await refreshOrders(page); await expect(page.getByTestId('closed-loop-stage-draft')).toContainText(versionNo); await expect(page.getByTestId('closed-loop-stage-draft')).toContainText(/VL\s*1\s*\/\s*WO\s*1/); - expect(await tagClass(page, 'draft').getAttribute('class')).toMatch(/ant-tag-green/); - expect(await tagClass(page, 'publish').getAttribute('class')).toMatch(/ant-tag-gold/); + await expect(tagClass(page, 'draft')).toHaveText('FEASIBLE'); + await expect(tagClass(page, 'publish')).toHaveText('\u5f85\u786e\u8ba4'); const stagedPublish = await browserApi(page, '/api/schedule/publish/stage', { method: 'POST', @@ -224,8 +228,8 @@ test.describe('Round 65 real browser closed-loop APS E2E (isolated backend)', () expect(status.closedLoopStatus.gate.publishReady).toBe(false); expect(status.closedLoopStatus.gate.dispatchReady).toBe(true); await refreshOrders(page); - expect(await tagClass(page, 'publish').getAttribute('class')).toMatch(/ant-tag-green/); - expect(await tagClass(page, 'mes').getAttribute('class')).toMatch(/ant-tag-gold/); + await expect(tagClass(page, 'publish')).toHaveText('\u5df2\u53d1\u5e03'); + await expect(tagClass(page, 'mes')).toHaveText('\u5f85\u53cc\u4eba\u786e\u8ba4'); const stagedMes = await browserApi(page, '/api/mes/dispatch/stage', { method: 'POST', @@ -269,8 +273,8 @@ test.describe('Round 65 real browser closed-loop APS E2E (isolated backend)', () expect(execution.rows[0].mesExternalId).toBeTruthy(); await refreshOrders(page); - expect(await tagClass(page, 'publish').getAttribute('class')).toMatch(/ant-tag-green/); - expect(await tagClass(page, 'mes').getAttribute('class')).toMatch(/ant-tag-green/); + await expect(tagClass(page, 'publish')).toHaveText('\u5df2\u53d1\u5e03'); + await expect(tagClass(page, 'mes')).toHaveText('\u5df2\u4e0b\u53d1'); const isolatedState = await request.get(`${API_TARGET}/__e2e__/state`); const isolatedBody = await isolatedState.json() as Json;