Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webui/test/browser/fixture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*
Expand Down
11 changes: 6 additions & 5 deletions packages/webui/test/browser/miniapp-standalone-tab.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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))}],
});
Expand Down Expand Up @@ -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);
Expand Down
Loading