diff --git a/packages/webui/test/browser/fixture.mjs b/packages/webui/test/browser/fixture.mjs index 17f77760..cb6ec35d 100644 --- a/packages/webui/test/browser/fixture.mjs +++ b/packages/webui/test/browser/fixture.mjs @@ -960,7 +960,7 @@ export function installFixtureTransport() { replies, pending, setResponse(operation, value) { responses.set(operation, clone(value)); }, - refuseOperation(operation, code, message) { refusals.set(operation, { code, message }); }, + refuseOperation(operation, code, message, reasonCode) { refusals.set(operation, { code, message, reasonCode }); }, /** * Answers an operation again after `refuseOperation`. * diff --git a/packages/webui/test/browser/miniapp-standalone-tab.spec.mjs b/packages/webui/test/browser/miniapp-standalone-tab.spec.mjs index a59464dc..720d3e0c 100644 --- a/packages/webui/test/browser/miniapp-standalone-tab.spec.mjs +++ b/packages/webui/test/browser/miniapp-standalone-tab.spec.mjs @@ -43,7 +43,7 @@ async function configureDocuments(page, refusal) { content: ` window.__WEBUI_FIXTURE_SETUP__ ??= []; window.__WEBUI_FIXTURE_SETUP__.push(() => { - ${refusal ? `window.__fixture.refuseOperation("openMiniApp", ${JSON.stringify(refusal.code)}, ${JSON.stringify(refusal.message)});` : ""} + ${refusal ? `window.__fixture.refuseOperation("openMiniApp", ${JSON.stringify(refusal.code)}, ${JSON.stringify(refusal.message)}, ${JSON.stringify(refusal.reasonCode)});` : ""} window.__fixture.setResponse("listMiniApps", { miniApps: [${JSON.stringify(catalogueRow(false, 0))}], }); @@ -193,17 +193,18 @@ test("a deep link naming a session that has ended still shows the Mini App", asy await expect(page.getByTestId("miniapp-switch-standalone")).toHaveCount(0); }); -for (const [code, message] of [ +for (const [code, message, reasonCode] of [ ["MINIAPP_PREPARATION_FAILED", "Mini App publication preparation failed"], ["OWNED_ELSEWHERE", "Mini App is running in another client"], + ["MINIAPP_PREPARATION_FAILED", "Mini App publication preparation failed", "OWNED_ELSEWHERE"], ]) { - test(`a standalone start refusal stays actionable and an explicit retry recovers (${code})`, async ({ page }) => { - await configureDocuments(page, { code, message }); + test(`a standalone start refusal stays actionable and an explicit retry recovers (${code}${reasonCode ? "/" + reasonCode : ""})`, async ({ page }) => { + await configureDocuments(page, { code, message, reasonCode }); await page.goto(`/miniapp?token=synthetic-token&plugin=${PLUGIN}`); const failed = page.getByTestId("miniapp-view-start-failed"); await expect(failed).toBeVisible(); await expect(failed).toContainText("应用尚未打开"); - if (code === "OWNED_ELSEWHERE") { + if (code === "OWNED_ELSEWHERE" || reasonCode === "OWNED_ELSEWHERE") { await expect(failed).toContainText("请先在其他客户端关闭该应用,再重试。"); } else { await expect(failed).toContainText(message);