The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix Guest embed options staying disabled until SSO terms are accepted (#75794)
Sébastiene860f98a4348
diff --git a/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts b/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.tsindex ee3c6454fac..9b51d0ae6c9 100644--- a/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts+++ b/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts@@ -9,6 +9,13 @@ const { H } = cy;const suiteTitle = "scenarios > sharing > embed flow pre-selection";+// The Behavior/Parameters/Appearance cards share a wrapper that is dimmed and+// made non-interactive (`pointer-events: none`) while the selected auth type+// isn't ready. The wrapper always carries an inline `opacity` style, so it can+// be selected in either state.+const optionCardsWrapper = () =>+ getEmbedSidebar().findByText("Behavior").closest("[style*='opacity']");+describe(suiteTitle, () => {beforeEach(() => {H.restore();@@ -50,6 +57,41 @@ describe(suiteTitle, () => {});});+ it("lets Guest embedding proceed after accepting only the Guest terms, without requiring the SSO terms (EMB-1884)", () => {+ // Reproduce a fresh Pro instance where neither auth type's terms have+ // been accepted yet, so the option cards start dimmed.+ H.updateSetting("show-simple-embed-terms", true);+ H.updateSetting("show-static-embed-terms", true);+ H.updateSetting("enable-embedding-static", false);++ H.visitDashboard(ORDERS_DASHBOARD_ID);+ H.openSharingMenu("Embed");++ cy.log("switch to Guest authentication");+ getEmbedSidebar().findByLabelText("Guest").click();++ cy.log(+ "the Behavior options aren't interactive until the Guest terms are accepted",+ );+ optionCardsWrapper().should("have.css", "pointer-events", "none");++ cy.log("accept the Guest terms only — never the SSO terms");+ H.embedModalEnableEmbedding();++ cy.log(+ "the Behavior options become interactive without accepting the SSO terms",+ );+ optionCardsWrapper().should("have.css", "pointer-events", "all");+ getEmbedSidebar()+ .findByLabelText("Allow downloads")+ .click()+ .should("be.checked");++ getEmbedSidebar().findByText("Get code").click();+ getEmbedSidebar().findByText("publish this dashboard").click();+ H.codeMirrorValue().should("contain", 'with-downloads="true"');+ });+it("pre-selects question in embed flow when opened from question sharing modal", () => {H.visitQuestion(ORDERS_QUESTION_ID);H.openSharingMenu("Embed");diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsxindex 88c46822886..b5d99252675 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx@@ -17,16 +17,17 @@ export const AppearanceStep = () => {const {isFirstStep,isSimpleEmbedFeatureAvailable,- isSimpleEmbeddingTermsAccepted,+ allowPreviewAndNavigation,} = useSdkIframeEmbedSetupContext();// When the wizard lands directly on this step (initialState) on a Pro// instance, the user needs to configure auth first — dim the option cards- // so the AuthenticationCard above takes focus.+ // so the AuthenticationCard above takes focus. `allowPreviewAndNavigation`+ // tracks the terms/enablement state of whichever auth type (SSO or Guest) is+ // currently selected, so accepting the Guest terms un-dims the cards without+ // forcing the user through the SSO flow.const isDimmed =- isFirstStep &&- isSimpleEmbedFeatureAvailable &&- !isSimpleEmbeddingTermsAccepted;+ isFirstStep && isSimpleEmbedFeatureAvailable && !allowPreviewAndNavigation;const dimmedProps = {opacity: isDimmed ? 0.5 : 1,className: cx(isDimmed && CS.pointerEventsNone),diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsxindex 944fcb298cb..898f214d1e6 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx@@ -73,5 +73,45 @@ describe("AppearanceStep > option cards dim state when landing on this step direexpect(getOptionCardsWrapper()).toHaveStyle({ opacity: "1" });});++ it("dims the option cards when Guest is selected but the guest-embed terms have not been accepted", async () => {+ landOnAppearanceStep({+ initialState: {+ resourceId: 1,+ resourceType: "dashboard",+ isGuest: true,+ },+ simpleEmbeddingEnabled: true,+ showSimpleEmbedTerms: true,+ guestEmbeddingEnabled: false,+ showStaticEmbedTerms: true,+ });++ await waitFor(() => {+ expect(screen.getByText("Behavior")).toBeVisible();+ });++ expect(getOptionCardsWrapper()).toHaveStyle({ opacity: "0.5" });+ });++ it("does not dim the option cards when Guest is selected and the guest-embed terms are accepted, even if the simple-embedding terms are not", async () => {+ landOnAppearanceStep({+ initialState: {+ resourceId: 1,+ resourceType: "dashboard",+ isGuest: true,+ },+ simpleEmbeddingEnabled: true,+ showSimpleEmbedTerms: true,+ guestEmbeddingEnabled: true,+ showStaticEmbedTerms: false,+ });++ await waitFor(() => {+ expect(screen.getByText("Behavior")).toBeVisible();+ });++ expect(getOptionCardsWrapper()).toHaveStyle({ opacity: "1" });+ });});});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsxindex 1a7b23b5949..1abeed21a2a 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx@@ -32,6 +32,8 @@ export const setup = (options?: {enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];simpleEmbeddingEnabled?: boolean;showSimpleEmbedTerms?: boolean;+ guestEmbeddingEnabled?: boolean;+ showStaticEmbedTerms?: boolean;jwtReady?: boolean;initialState?: SdkIframeEmbedSetupModalInitialState;hasEmailSetup?: boolean;@@ -58,6 +60,8 @@ export const setup = (options?: {"token-features": tokenFeatures,"show-simple-embed-terms": options?.showSimpleEmbedTerms ?? false,"enable-embedding-simple": options?.simpleEmbeddingEnabled ?? false,+ "show-static-embed-terms": options?.showStaticEmbedTerms ?? false,+ "enable-embedding-static": options?.guestEmbeddingEnabled ?? false,"jwt-enabled": options?.jwtReady ?? false,"jwt-configured": options?.jwtReady ?? false,"jwt-enabled-and-configured": options?.jwtReady ?? false,