Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix flaky JWT user-session e2e in sdk iframe embed setup get-code (#80642)

Sébastien5ae667c0b095
diff --git a/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts b/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
index 514d98bdca8..b273c847914 100644
--- a/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
+++ b/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
@@ -4,6 +4,9 @@ export const embedModalContent = () =>
export const embedModalEnableEmbeddingCard = () =>
cy.findByTestId("enable-embedding-card");
+const ACCEPT_TERMS_BUTTON_NAME =
+ /(Agree and (continue|enable)|Enable and continue)/;
+
export const embedModalEnableEmbedding = () => {
// Wait for the modal before reading the DOM below. That read is a snapshot
// and does not retry, so on an empty body it takes the early return and the
@@ -19,19 +22,18 @@ export const embedModalEnableEmbedding = () => {
return;
}
- // Wait for the actionable Agree/Enable button on the freshly mounted
- // section for the currently-selected auth mode, then click it.
- //
- // We intentionally do NOT treat the disabled "Enabled" label as a
- // terminal no-op: it appears legitimately after this helper clicks
- // Agree (the section freezes via `useState`), but it ALSO appears
- // transiently on the *stale* section from a previous auth-mode
- // selection before React commits the unmount. Bailing on it was the
- // original bug. Matching the actionable label scopes us to the new
- // section automatically, since the stale one shows only "Enabled".
+ // Match the actionable label, not the disabled "Enabled" one — the latter
+ // also shows transiently on the stale section after an auth-mode switch.
+ cy.findByRole("button", { name: ACCEPT_TERMS_BUTTON_NAME }).click();
+
+ // Once the acceptance registers, the section freezes and relabels its
+ // button to a disabled "Enabled", so the actionable label going away is
+ // the signal. Asserting it here makes a lost click fail on the spot
+ // instead of on a misleading iframe timeout downstream (EMB-2292).
cy.findByRole("button", {
- name: /(Agree and (continue|enable)|Enable and continue)/,
- }).click();
+ name: ACCEPT_TERMS_BUTTON_NAME,
+ timeout: 10_000,
+ }).should("not.exist");
});
};
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts
index c262abc599b..4f803407865 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts
@@ -19,7 +19,12 @@ describe("scenarios > embedding > sdk iframe embed setup > get code step", () =>
cy.signInAsAdmin();
H.activateToken("pro-self-hosted");
H.enableTracking();
+ // Accept the embedding terms up front so the wizard never shows the
+ // Agree CTA — its flow is covered by embed-flow-enable-embed-js-*.
H.updateSetting("enable-embedding-simple", true);
+ H.updateSetting("show-simple-embed-terms", false);
+ H.updateSetting("enable-embedding-static", true);
+ H.updateSetting("show-static-embed-terms", false);
cy.intercept("GET", "/api/dashboard/**").as("dashboard");
cy.intercept("POST", "/api/card/*/query").as("cardQuery");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
index dc9788058bc..b0f78d9ba36 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
@@ -43,7 +43,8 @@ export const visitNewEmbedPage = (
cy.wait("@dashboard");
- cy.get("[data-iframe-loaded]", { timeout: 20000 }).should(
+ // Same 40s margin as waitForSimpleEmbedIframesToLoad (metabase#66954).
+ cy.get("[data-iframe-loaded]", { timeout: 40_000 }).should(
"have.length",
1,
);