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
Sign out before loading EAJS e2e test pages by default (#84867)
Nicolò Prettocbbb097e7e4b
diff --git a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.tsindex a625134861b..cf5ad882b22 100644--- a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts+++ b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts@@ -51,6 +51,9 @@ export interface BaseEmbedTestPageOptions {};onVisitPage?(win: Cypress.AUTWindow): void;++ // The embed must not see the Cypress session cookie unless the test needs it+ signOut?: boolean;}export interface MetabaseElement {@@ -114,6 +117,7 @@ export function loadSdkIframeEmbedTestPage({origin = "",selector,onVisitPage,+ signOut = true,...options}: BaseEmbedTestPageOptions & { selector?: string }) {const testPageSource = getSdkIframeEmbedHtml(options);@@ -125,6 +129,10 @@ export function loadSdkIframeEmbedTestPage({headers: { "content-type": "text/html" },}).as("dynamicPage");+ if (signOut) {+ cy.signOut();+ }+cy.visit(testPageUrl, { onLoad: onVisitPage });cy.title().should("include", "Metabase Embed Test");@@ -203,11 +211,9 @@ const convertPropertiesToEmbedTagAttributes = (export function prepareSdkIframeEmbedTest({withToken = "bleeding-edge",enabledAuthMethods = ["jwt"],- signOut = false,}: {withToken?: false | "starter" | "bleeding-edge";enabledAuthMethods?: EnabledAuthMethods[];- signOut?: boolean;} = {}) {restore();cy.signInAsAdmin();@@ -227,10 +233,6 @@ export function prepareSdkIframeEmbedTest({setupMockAuthProviders(enabledAuthMethods);mockEmbedJsToDevServer();-- if (signOut) {- cy.signOut();- }}/**@@ -352,9 +354,11 @@ export const visitCustomHtmlPage = ({origin = "",onVisitPage,+ signOut = true,}: {origin?: string;onVisitPage?: () => void;+ signOut?: boolean;} = {},) => {const testPageUrl = `${origin}/custom-html-page`;@@ -363,6 +367,10 @@ export const visitCustomHtmlPage = (headers: { "content-type": "text/html" },}).as("dynamicPage");+ if (signOut) {+ cy.signOut();+ }+cy.visit(testPageUrl, { onLoad: onVisitPage });return cy;diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.tsindex 23eee6b2b31..82dbf0cd6ce 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts@@ -100,7 +100,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>});it("shows auth errors when no auth methods are enabled and there is no session", () => {- H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [], signOut: true });+ H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [] });cy.log("no auth method is available");H.loadSdkIframeEmbedTestPage({@@ -154,7 +154,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>});it("uses the existing user session only when useExistingUserSession is true", () => {- H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [], signOut: false });+ H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [] });cy.log("when no auth methods are enabled and the existing user session is not used, it should fail to login",@@ -164,6 +164,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>metabaseConfig: {useExistingUserSession: false,},+ signOut: false,}).within(() => {cy.findByTestId("sdk-error-container").should("be.visible")@@ -176,13 +177,14 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>metabaseConfig: {useExistingUserSession: true,},+ signOut: false,});assertDashboardLoaded(frame);});it("can login via JWT with a custom fetch request token function, and shows an error if it fails", () => {- H.prepareSdkIframeEmbedTest({ enabledAuthMethods: ["jwt"], signOut: true });+ H.prepareSdkIframeEmbedTest({ enabledAuthMethods: ["jwt"] });cy.log("fetchRequestToken returns an empty token");H.loadSdkIframeEmbedTestPage({@@ -225,7 +227,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>it("can login via SAML, and shows an error if the SAML login results in an invalid user", () => {mockAuthSsoEndpointForSamlAuthProvider();- H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [], signOut: true });+ H.prepareSdkIframeEmbedTest({ enabledAuthMethods: [] });cy.log("SAML login results in an invalid user");H.loadSdkIframeEmbedTestPage({@@ -252,7 +254,6 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>it("allows an API key in development but not in production", () => {H.prepareSdkIframeEmbedTest({enabledAuthMethods: ["api-key"],- signOut: true,});cy.get<string>("@apiKey").then((apiKey) => {@@ -296,7 +297,6 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>H.prepareSdkIframeEmbedTest({enabledAuthMethods: ["jwt", "saml"],- signOut: true,});cy.log("preferredAuthMethod is saml");diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/content-translations.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/content-translations.cy.spec.tsindex 4c60ed9ef2d..21b62365936 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/content-translations.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/content-translations.cy.spec.ts@@ -68,7 +68,6 @@ describe("scenarios > embedding > sdk iframe embedding > content-translations",it("should translate content with read-only='true'", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});setupContentTranslations();@@ -104,7 +103,6 @@ describe("scenarios > embedding > sdk iframe embedding > content-translations",it("should translate content with read-only='false'", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});setupContentTranslations();diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.tsindex 32851379297..7a885169675 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts@@ -550,6 +550,7 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (const questionId = response.id;cy.log("Open the question");+ cy.signInAsAdmin();H.visitQuestion(questionId)?.then(() => {// Name of the collection should be visible at the top of the page// findAllBy because there are two "first_collection", one in the sidebar and one at the topdiff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.tsindex 05aa7155145..7850ba3a0cd 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts@@ -141,7 +141,7 @@ function dashboardSidebar() {describe("scenarios > embedding > sdk iframe embed options passthrough", () => {beforeEach(() => {- H.prepareSdkIframeEmbedTest({ signOut: true });+ H.prepareSdkIframeEmbedTest();});it("renders the exploration template with isSaveEnabled=true, targetCollection, entityTypes", () => {diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.tsindex 64e60a5b0d5..4ae3ef12f03 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts@@ -24,7 +24,6 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =it("should show an error when initial-collection points to a collection the user has no access to", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});H.createCollection({@@ -59,7 +58,6 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =it("should not show Save button when opening an existing question from a read-only collection", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});H.createCollection({@@ -134,7 +132,7 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =});const setUpTenantsInstance = () => {- H.prepareSdkIframeEmbedTest({ signOut: false });+ H.prepareSdkIframeEmbedTest();H.updateSetting("use-tenants", true);createSharedCollection("Shared Reports").then(({ body: collection }) => {@@ -152,7 +150,7 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =describe("for a normal user", () => {beforeEach(() => {- H.prepareSdkIframeEmbedTest({ signOut: false });+ H.prepareSdkIframeEmbedTest();cy.signOut();mockAuthProviderAndJwtSignIn(USERS.normal);@@ -251,7 +249,7 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =describe("for a user with no access to the root", () => {it("should promote the collections below the root, drill into one and come back", () => {- H.prepareSdkIframeEmbedTest({ signOut: false });+ H.prepareSdkIframeEmbedTest();H.createCollection({ name: "Accessible Collection" }).then(({ body: collection }) => {@@ -314,7 +312,6 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =it("should reset `New question` editor state when clicking 'New question' breadcrumb after selecting a filter", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});setupEmbed(`@@ -349,7 +346,6 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =it("should reset `New question` editor state when clicking 'New question' breadcrumb after Visualize", () => {H.prepareSdkIframeEmbedTest({withToken: "bleeding-edge",- signOut: false,});setupEmbed(`diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.tsindex 2f5f55a5568..4050cb158e6 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts@@ -7,8 +7,6 @@ describe("scenarios > embedding > sdk iframe embedding > without token features"// JWT requires a valid license to use, so we expect customers to use API keys when testing.enabledAuthMethods: ["api-key"],-- signOut: true,});});diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-csv-downloads.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-csv-downloads.cy.spec.tsindex 087252e1814..659022a000a 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-csv-downloads.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-csv-downloads.cy.spec.ts@@ -5,7 +5,7 @@ const { H } = cy;describe("scenarios > embedding > sdk iframe embedding > csv downloads", () => {beforeEach(() => {cy.deleteDownloadsFolder();- H.prepareSdkIframeEmbedTest({ signOut: true });+ H.prepareSdkIframeEmbedTest();});const addGroupBy = (column: string) => {diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.tsindex 0fbd3d7e935..7423864809b 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts@@ -12,7 +12,7 @@ const { ORDERS_ID: ORDERS_TABLE_ID, ORDERS } = SAMPLE_DATABASE;describe("scenarios > embedding > modular embedding", () => {beforeEach(() => {- H.prepareSdkIframeEmbedTest({ signOut: true });+ H.prepareSdkIframeEmbedTest();});it("can find the embed.js file", () => {@@ -495,7 +495,6 @@ describe("scenarios > embedding > modular embedding", () => {H.resetSnowplow();H.prepareSdkIframeEmbedTest({enabledAuthMethods: ["jwt"],- signOut: false,});H.enableTracking();});diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-pdf-downloads.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-pdf-downloads.cy.spec.tsindex db9ce519da9..547fa533763 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-pdf-downloads.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-pdf-downloads.cy.spec.ts@@ -40,7 +40,7 @@ describe("scenarios > embedding > sdk iframe embedding > pdf downloads", () => {describe("Dashboard PDF downloads", () => {beforeEach(() => {- H.prepareSdkIframeEmbedTest({ signOut: true });+ H.prepareSdkIframeEmbedTest();});it("should download dashboard as PDF with analytics tracking", () => {diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/theming.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/theming.cy.spec.tsindex e3b2829e145..6fcfb88c367 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/theming.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/theming.cy.spec.ts@@ -31,7 +31,7 @@ const DARK_THEME = {describe("scenarios > embedding > sdk iframe embedding > theming", () => {beforeEach(() => {- H.prepareSdkIframeEmbedTest({ signOut: true });+ H.prepareSdkIframeEmbedTest();});it("should measure table column widths based on themed font size", () => {