Skip to content

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

Consolidate embedding theme e2e tests (#83908)

Chris Vandoodewaard0bb55adc93f7
diff --git a/e2e/test/scenarios/embedding/embedding-theme-editor/helpers/index.ts b/e2e/test/scenarios/embedding/embedding-theme-editor/helpers/index.ts
index 8bbb53b1fc6..711bc796e2b 100644
--- a/e2e/test/scenarios/embedding/embedding-theme-editor/helpers/index.ts
+++ b/e2e/test/scenarios/embedding/embedding-theme-editor/helpers/index.ts
@@ -15,10 +15,10 @@ export function deleteAllThemes() {
});
}
-export const getThemeCard = (themeName: string) =>
+const getThemeCard = (themeName: string) =>
main().findByText(themeName).parent();
-export function openThemeActionMenu(themeName: string) {
+function openThemeActionMenu(themeName: string) {
getThemeCard(themeName).findByLabelText("Duplicate and delete").click();
}
diff --git a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-editor.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-editor.cy.spec.ts
index 7d465d70545..5dc45722246 100644
--- a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-editor.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-editor.cy.spec.ts
@@ -63,6 +63,8 @@ describe(
});
it("loads the theme editor page and shows the theme name", () => {
+ H.updateSetting("enable-embedding-modular", false);
+
createThemeViaApi("My custom theme").then((theme) => {
visitThemeEditor(theme.id);
});
@@ -75,58 +77,47 @@ describe(
cy.log("save button should be disabled when no changes");
cy.findByRole("button", { name: /Save theme/ }).should("be.disabled");
- });
-
- it("can edit and save a theme name", () => {
- createThemeViaApi("Original name").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- cy.log("change the theme name");
- cy.findByLabelText("Theme name").clear().type("Updated name");
-
- cy.log("save button should be enabled");
- cy.findByRole("button", { name: /Save theme/ }).should("be.enabled");
-
- cy.log("save the theme");
- cy.findByRole("button", { name: /Save theme/ }).click();
-
- // An earlier undo toast may still be on screen, so use the toast list
- // (plural) and filter by text — `undoToast()` (singular) yields
- // undefined when multiple toasts match.
- H.undoToastList().contains("Theme saved").should("be.visible");
- });
- it("can cancel and navigate back to listing", () => {
- createThemeViaApi("A theme").then((theme) => {
- visitThemeEditor(theme.id);
- });
+ cy.log("should show prompt to enable embedding");
+ H.main().findByText("Theme preview").should("be.visible");
+ H.main()
+ .findByText(
+ "Enable modular embedding to see a live preview of your theme.",
+ )
+ .should("be.visible");
+ H.main()
+ .findByRole("button", { name: /Enable modular embedding/ })
+ .should("be.visible");
+ cy.log("cancel should navigate back to the themes listing");
cy.findByRole("button", { name: /Cancel/ }).click();
-
- cy.log("should navigate back to the themes listing");
- cy.url().should("include", "/embedding/appearance");
- cy.url().should("not.match", /\/theme\/\d+/);
+ cy.url().should("match", /\/embedding\/appearance$/);
+ H.main().findByText("My custom theme").should("be.visible");
});
- it("shows not found for invalid theme id", () => {
+ it("can delete a theme that has unsaved changes without getting stuck on a 404", () => {
+ cy.log("an unknown theme id shows the not found page");
cy.visit("/embedding/appearance/theme/99999");
-
H.main().findByText("We're a little lost...").should("be.visible");
- });
- it("can delete the theme from the editor with confirmation", () => {
- createThemeViaApi("Theme to delete").then((theme) => {
+ // Repro of a bug where deleting a dirty theme would trigger the
+ // unsaved-changes guard. The redirect to the theme list got blocked,
+ // leaving the user on the now-deleted theme's URL — which 404s once
+ // the GET cache is invalidated.
+ createThemeViaApi("Dirty delete").then((theme) => {
visitThemeEditor(theme.id);
});
- cy.log("delete button should be visible");
- cy.findByRole("button", { name: /Delete theme/ })
- .scrollIntoView()
- .should("be.visible");
+ cy.log("dirty the editor by renaming the theme");
+ cy.findByLabelText("Theme name").clear().type("Renamed but unsaved");
+
+ cy.findByRole("button", { name: /Save theme/ }).should("be.enabled");
cy.log("open the delete confirmation modal");
- cy.findByRole("button", { name: /Delete theme/ }).click();
+ cy.findByRole("button", { name: /Delete theme/ })
+ .scrollIntoView()
+ .should("be.visible")
+ .click();
cy.findByRole("dialog").within(() => {
cy.findByText("Delete theme").should("be.visible");
@@ -138,39 +129,12 @@ describe(
cy.findByRole("button", { name: /Cancel/ }).click();
});
- cy.log("should remain on the editor page after cancelling");
- cy.url().should("match", /\/theme\/\d+/);
-
- cy.log("confirm deletion");
- cy.findByRole("button", { name: /Delete theme/ }).click();
- cy.findByRole("dialog").within(() => {
- cy.findByRole("button", { name: /Delete/ }).click();
- });
-
- H.undoToast().findByText("Theme deleted successfully").should("exist");
-
- cy.log("should navigate back to the themes listing");
- cy.url().should("include", "/embedding/appearance");
- cy.url().should("not.match", /\/theme\/\d+/);
-
- H.main().within(() => {
- cy.findByText("Theme to delete").should("not.exist");
- });
- });
-
- it("can delete a theme that has unsaved changes without getting stuck on a 404", () => {
- // Repro of a bug where deleting a dirty theme would trigger the
- // unsaved-changes guard. The redirect to the theme list got blocked,
- // leaving the user on the now-deleted theme's URL — which 404s once
- // the GET cache is invalidated.
- createThemeViaApi("Dirty delete").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- cy.log("dirty the editor by renaming the theme");
- cy.findByLabelText("Theme name").clear().type("Renamed but unsaved");
-
- cy.findByRole("button", { name: /Save theme/ }).should("be.enabled");
+ cy.log("should remain on the editor with the unsaved changes");
+ cy.findByRole("dialog").should("not.exist");
+ cy.findByLabelText("Theme name").should(
+ "have.value",
+ "Renamed but unsaved",
+ );
cy.log("delete the theme");
cy.findByRole("button", { name: /Delete theme/ }).click();
@@ -181,18 +145,14 @@ describe(
H.undoToast().findByText("Theme deleted successfully").should("exist");
cy.log("should land on the themes listing — not 404 or leave-prompt");
- cy.url().should("include", "/embedding/appearance");
- cy.url().should("not.match", /\/theme\/\d+/);
+ cy.url().should("match", /\/embedding\/appearance$/);
+ H.main()
+ .findByRole("button", { name: /New theme/ })
+ .should("be.visible");
+ H.main().findByText("Dirty delete").should("not.exist");
H.main().findByText("We're a little lost...").should("not.exist");
});
- it("does not show the delete button when creating a new theme", () => {
- cy.visit("/embedding/appearance/theme/new");
-
- cy.findByLabelText("Theme name").should("be.visible");
- cy.findByRole("button", { name: /Delete theme/ }).should("not.exist");
- });
-
describe("font settings", () => {
it("can edit font settings and save them", () => {
cy.intercept("PUT", "/api/embed-theme/*").as("updateTheme");
@@ -207,6 +167,12 @@ describe(
cy.findByLabelText("Base font size").should("be.visible");
});
+ cy.log("change the theme name");
+ cy.findByLabelText("Theme name").clear().type("Updated name");
+
+ cy.log("save button should be enabled");
+ cy.findByRole("button", { name: /Save theme/ }).should("be.enabled");
+
cy.log("select a font family");
H.main().findByLabelText("Font").click();
cy.findByRole("option", { name: "Lato" }).click();
@@ -220,7 +186,8 @@ describe(
});
cy.wait("@updateTheme").then((interception) => {
- const { settings } = interception.request.body;
+ const { name, settings } = interception.request.body;
+ expect(name).to.eq("Updated name");
expect(settings.fontFamily).to.eq("Lato");
expect(settings.fontSize).to.eq("16px");
});
@@ -229,6 +196,10 @@ describe(
// screen, so use the toast list (plural) and filter by text — using
// `undoToast()` (singular) yields undefined when multiple toasts match.
H.undoToastList().contains("Theme saved").should("be.visible");
+
+ cy.log("saving navigates back to the listing with the new name");
+ cy.url().should("match", /\/embedding\/appearance$/);
+ H.main().findByText("Updated name").should("be.visible");
});
});
@@ -283,7 +254,9 @@ describe(
});
describe("additional colors", () => {
- it("shows additional colors section when expanded", () => {
+ it("shows, reverts, edits, and saves additional colors", () => {
+ cy.intercept("PUT", "/api/embed-theme/*").as("updateTheme");
+
createThemeViaApi("Colors test").then((theme) => {
visitThemeEditor(theme.id);
});
@@ -304,15 +277,7 @@ describe(
cy.log("collapse additional colors");
cy.findByText("Show fewer colors").click();
cy.findByText("Secondary text").should("not.be.visible");
- });
- });
- it("can revert additional colors back to defaults", () => {
- createThemeViaApi("Revert colors").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- H.main().within(() => {
cy.findByText("Show more colors").click();
cy.log(
@@ -328,18 +293,6 @@ describe(
cy.log("revert button should disappear after resetting");
cy.findByLabelText("Regenerate from brand color").should("not.exist");
});
- });
-
- it("can edit additional colors and save them", () => {
- cy.intercept("PUT", "/api/embed-theme/*").as("updateTheme");
-
- createThemeViaApi("Edit colors").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- H.main().within(() => {
- cy.findByText("Show more colors").click();
- });
cy.log("edit the border color via its inline input");
changeColor("Border", "FF5733");
@@ -363,39 +316,6 @@ describe(
});
});
- describe("preview panel", () => {
- it("shows enable embedding prompt when embedding is not enabled", () => {
- H.updateSetting("enable-embedding-modular", false);
-
- createThemeViaApi("Preview test").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- cy.log("should show prompt to enable embedding");
- H.main()
- .findByText(
- "Enable modular embedding to see a live preview of your theme.",
- )
- .should("be.visible");
-
- H.main()
- .findByRole("button", { name: /Enable modular embedding/ })
- .should("be.visible");
- });
-
- it("shows theme preview when embedding is enabled", () => {
- H.updateSetting("enable-embedding-modular", true);
- H.updateSetting("show-modular-embed-terms", false);
-
- createThemeViaApi("Preview test").then((theme) => {
- visitThemeEditor(theme.id);
- });
-
- cy.log("should show the theme preview heading");
- H.main().findByText("Theme preview").should("be.visible");
- });
- });
-
describe("preview picker", () => {
beforeEach(() => {
H.updateSetting("enable-embedding-modular", true);
diff --git a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-listing.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-listing.cy.spec.ts
index 105293b3d6a..1702b046bcf 100644
--- a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-listing.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-listing.cy.spec.ts
@@ -6,7 +6,6 @@ import {
clickThemeMenuItem,
createThemeViaApi,
deleteAllThemes,
- openThemeActionMenu,
} from "./helpers";
describe(
@@ -49,56 +48,56 @@ describe(
cy.url().should("match", /\/embedding\/appearance\/theme\/new$/);
});
- it("does not create a theme when cancelling from the draft editor", () => {
+ it("uses white-labeled colors as a base for creating themes", () => {
+ const whitelabelColors = {
+ brand: "#8e44ad",
+ filter: "#16a085",
+ summarize: "#d35400",
+ accent0: "#e74c3c",
+ accent7: "#34495e",
+ };
+
+ // @ts-expect-error -- the utility is not aware of enterprise settings
+ H.updateSetting("application-colors", whitelabelColors);
+
cy.intercept("POST", "/api/embed-theme").as("createTheme");
cy.visit("/embedding/appearance");
- H.main()
- .findByRole("button", { name: /New theme/ })
- .click();
+ cy.log("nav label has no upsell gem");
+ cy.findByRole("navigation", { name: "Embedding hub" })
+ .findByRole("link", { name: "Appearance" })
+ .findByTestId("upsell-gem")
+ .should("not.exist");
+
+ H.main().within(() => {
+ cy.log("theme listing is rendered");
+ cy.findByRole("heading", { name: "Themes" }).should("be.visible");
+
+ cy.log("upsell copy is absent");
+ cy.findByText("Metabase Pro").should("not.exist");
+ cy.findByRole("heading", { name: "Create custom themes" }).should(
+ "not.exist",
+ );
+
+ cy.findByRole("button", { name: /New theme/ }).click();
+ });
cy.url().should("match", /\/embedding\/appearance\/theme\/new$/);
+ cy.log("the draft editor has no delete button");
+ cy.findByLabelText("Theme name").should("be.visible");
+ cy.findByRole("button", { name: /Delete theme/ }).should("not.exist");
+
cy.findByRole("button", { name: /Cancel/ }).click();
cy.log("navigates back to the listing");
cy.url().should("match", /\/embedding\/appearance$/);
- cy.log("new theme card is still visible");
+ cy.log("cancelling does not create a theme");
H.main()
.findByRole("button", { name: /New theme/ })
.should("be.visible");
-
- cy.log("no POST was issued");
cy.get("@createTheme.all").should("have.length", 0);
- });
-
- it("navigates to theme editor when clicking an existing theme card", () => {
- createThemeViaApi("My theme");
- cy.visit("/embedding/appearance");
-
- H.main().within(() => {
- cy.findByText("My theme").click();
- });
-
- cy.log("navigates to the theme editor page");
- cy.url().should("match", /\/embedding\/appearance\/theme\/\d+/);
- });
-
- it("uses white-labeled colors as a base for creating themes", () => {
- const whitelabelColors = {
- brand: "#8e44ad",
- filter: "#16a085",
- summarize: "#d35400",
- accent0: "#e74c3c",
- accent7: "#34495e",
- };
-
- // @ts-expect-error -- the utility is not aware of enterprise settings
- H.updateSetting("application-colors", whitelabelColors);
-
- cy.intercept("POST", "/api/embed-theme").as("createTheme");
- cy.visit("/embedding/appearance");
H.main()
.findByRole("button", { name: /New theme/ })
@@ -124,13 +123,17 @@ describe(
);
});
- it("can duplicate a theme", () => {
+ it("can duplicate and delete themes, and open a theme from its card", () => {
createThemeViaApi("Untitled theme");
cy.visit("/embedding/appearance");
- H.main().within(() => {
- cy.findByText("Untitled theme").should("be.visible");
- });
+ cy.log("clicking a theme card opens the theme editor");
+ H.main().findByText("Untitled theme").click();
+ cy.url().should("match", /\/embedding\/appearance\/theme\/\d+$/);
+ cy.findByLabelText("Theme name").should("have.value", "Untitled theme");
+
+ cy.findByRole("button", { name: /Cancel/ }).click();
+ cy.url().should("match", /\/embedding\/appearance$/);
cy.log("duplicate a theme");
clickThemeMenuItem("Untitled theme", "Duplicate");
@@ -142,16 +145,9 @@ describe(
cy.findByText("Untitled theme").scrollIntoView().should("be.visible");
cy.findByText("Copy of Untitled theme").should("be.visible");
});
- });
-
- it("can delete a theme with confirmation", () => {
- createThemeViaApi("Untitled theme");
- cy.visit("/embedding/appearance");
- H.main().findByText("Untitled theme").should("be.visible");
-
- cy.log("delete a theme");
- clickThemeMenuItem("Untitled theme", "Delete");
+ cy.log("delete the copy");
+ clickThemeMenuItem("Copy of Untitled theme", "Delete");
cy.log("delete confirmation modal should appear");
cy.findByRole("dialog").within(() => {
@@ -166,26 +162,31 @@ describe(
});
cy.log("theme should still exist");
- H.main().findByText("Untitled theme").should("be.visible");
-
- openThemeActionMenu("Untitled theme");
+ H.main()
+ .findByText("Copy of Untitled theme")
+ .scrollIntoView()
+ .should("be.visible");
cy.log("confirm deletion");
- cy.findByRole("menuitem", { name: /Delete/ }).click();
+ clickThemeMenuItem("Copy of Untitled theme", "Delete");
cy.findByRole("dialog").within(() => {
cy.findByRole("button", { name: /Delete/ }).click();
});
- H.undoToast().findByText("Theme deleted successfully").should("exist");
+ // The duplicate toast may still be on screen, so use the toast list
+ // (plural) and filter by text — `undoToast()` (singular) yields
+ // undefined when multiple toasts match.
+ H.undoToastList().contains("Theme deleted successfully").should("exist");
H.main().within(() => {
- cy.log(
- "deleted theme is gone; default themes and new theme card remain",
- );
- cy.findByText("Untitled theme").should("not.exist");
- cy.findByText("Light").should("be.visible");
- cy.findByText("Dark").should("be.visible");
- cy.findByRole("button", { name: /New theme/ }).should("be.visible");
+ cy.log("deleted theme is gone; other themes and new theme card remain");
+ cy.findByText("Copy of Untitled theme").should("not.exist");
+ cy.findByText("Untitled theme").scrollIntoView().should("be.visible");
+ cy.findByRole("button", { name: /New theme/ })
+ .scrollIntoView()
+ .should("be.visible");
+ cy.findByText("Light").scrollIntoView().should("be.visible");
+ cy.findByText("Dark").scrollIntoView().should("be.visible");
});
});
},
diff --git a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-upsell.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-upsell.cy.spec.ts
index 1c971ed7dfe..ec9eae30588 100644
--- a/e2e/test/scenarios/embedding/embedding-theme-editor/theme-upsell.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-theme-editor/theme-upsell.cy.spec.ts
@@ -46,15 +46,14 @@ describe("scenarios > embedding > themes > upsell", () => {
H.activateToken("starter");
});
- it("shows the Upgrade to Pro CTA when the current admin is not a Metabase Store Admin", () => {
- cy.log(
- "keep the trial check deterministic — no trial, so CTA stays 'Upgrade to Pro'",
- );
+ it("shows the Upgrade to Pro CTA, or Try for free when a trial is available", () => {
+ cy.log("no trial → CTA stays 'Upgrade to Pro'");
cy.intercept("POST", "/api/ee/cloud-proxy/mb-plan-trial-up-available", {
body: { available: false, plan_alias: "pro-cloud" },
- });
+ }).as("trialUnavailable");
cy.visit("/embedding/appearance");
+ cy.wait("@trialUnavailable");
cy.log("nav label has an upsell gem");
cy.findByRole("navigation", { name: "Embedding hub" })
@@ -71,69 +70,16 @@ describe("scenarios > embedding > themes > upsell", () => {
"Fine-tune the appearance of your embedded content with colors and fonts.",
).should("be.visible");
- cy.log(
- "hosted starter admins can upgrade even when they are not Store Admins",
- );
+ cy.log("hosted starter admins can upgrade (opens the upgrade modal)");
cy.findByRole("button", { name: "Upgrade to Pro" }).should(
"be.visible",
);
- });
- });
-
- it("shows the Upgrade to Pro CTA when the current admin is a Metabase Store Admin", () => {
- cy.log(
- "inject the current admin into token-status.store-users so isStoreUser becomes true",
- );
- cy.intercept("GET", "/api/session/properties", (req) => {
- req.continue((res) => {
- res.body["token-status"] = {
- ...(res.body["token-status"] ?? {}),
- "store-users": [{ email: "[email protected]" }],
- };
- res.send();
- });
- });
- cy.log(
- "keep the trial check deterministic — no trial, so CTA stays 'Upgrade to Pro'",
- );
- cy.intercept("POST", "/api/ee/cloud-proxy/mb-plan-trial-up-available", {
- body: { available: false, plan_alias: "pro-cloud" },
- });
-
- cy.visit("/embedding/appearance");
-
- H.main().within(() => {
- cy.findByText("Metabase Pro").should("be.visible");
- cy.findByRole("heading", { name: "Create custom themes" }).should(
- "be.visible",
- );
-
- cy.log("contact-admin fallback is not rendered");
+ cy.log("contact-admin fallback is not rendered for admins");
cy.findByText(/Please ask a Metabase Store Admin/).should("not.exist");
cy.log("no trial → no trial line");
cy.findByText(/14 day trial/).should("not.exist");
-
- cy.log(
- "CTA is rendered (hosted starter as store admin → opens the upgrade modal)",
- );
- cy.findByRole("button", { name: "Upgrade to Pro" }).should(
- "be.visible",
- );
- });
- });
-
- it("shows the Try for free CTA and trial copy when a trial is available", () => {
- cy.log("admin is a Store Admin, so the CTA branch is taken");
- cy.intercept("GET", "/api/session/properties", (req) => {
- req.continue((res) => {
- res.body["token-status"] = {
- ...(res.body["token-status"] ?? {}),
- "store-users": [{ email: "[email protected]" }],
- };
- res.send();
- });
});
cy.log(
@@ -141,12 +87,12 @@ describe("scenarios > embedding > themes > upsell", () => {
);
cy.intercept("POST", "/api/ee/cloud-proxy/mb-plan-trial-up-available", {
body: { available: true, plan_alias: "pro-cloud" },
- });
+ }).as("trialAvailable");
- cy.visit("/embedding/appearance");
+ cy.reload();
+ cy.wait("@trialAvailable");
H.main().within(() => {
- cy.findByText("Metabase Pro").should("be.visible");
cy.findByRole("heading", { name: "Create custom themes" }).should(
"be.visible",
);
@@ -162,34 +108,4 @@ describe("scenarios > embedding > themes > upsell", () => {
});
});
});
-
- describe("Pro", { tags: "@EE" }, () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- });
-
- it("does not show the upsell and renders the themes listing", () => {
- cy.visit("/embedding/appearance");
-
- cy.log("nav label has no upsell gem");
- cy.findByRole("navigation", { name: "Embedding hub" })
- .findByRole("link", { name: "Appearance" })
- .findByTestId("upsell-gem")
- .should("not.exist");
-
- H.main().within(() => {
- cy.log("upsell copy is absent");
- cy.findByText("Metabase Pro").should("not.exist");
- cy.findByRole("heading", { name: "Create custom themes" }).should(
- "not.exist",
- );
-
- cy.log("theme listing is rendered");
- cy.findByRole("heading", { name: "Themes" }).should("be.visible");
- cy.findByRole("button", { name: /New theme/ }).should("be.visible");
- });
- });
- });
});
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.ts
index 318262f4d97..e3b2829e145 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
@@ -34,44 +34,6 @@ describe("scenarios > embedding > sdk iframe embedding > theming", () => {
H.prepareSdkIframeEmbedTest({ signOut: true });
});
- it("should apply custom themes", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-dashboard",
- attributes: {
- dashboardId: ORDERS_DASHBOARD_ID,
- },
- },
- ],
- metabaseConfig: {
- theme: DARK_THEME,
- },
- });
-
- cy.wait("@getDashboard");
-
- frame.within(() => {
- cy.findByTestId("dashboard").should(
- "have.css",
- "background-color",
- DARK_THEME.colors.background,
- );
-
- cy.findByText("Showing first 2,000 rows").should(
- "have.css",
- "color",
- DARK_THEME.colors["text-primary"],
- );
-
- cy.findByText("Product ID").should(
- "have.css",
- "color",
- DARK_THEME.colors.brand,
- );
- });
- });
-
it("should measure table column widths based on themed font size", () => {
const SMALL_FONT_THEME = {
components: {
@@ -162,74 +124,18 @@ describe("scenarios > embedding > sdk iframe embedding > theming", () => {
},
],
metabaseConfig: {
- theme: LIGHT_THEME,
+ theme: DARK_THEME,
},
insertHtml: { beforeEmbed: THEME_SWITCHER_HTML },
});
cy.wait("@getDashboard");
- cy.log("1. verify colors in light theme");
+ cy.log("1. verify colors in the initial dark theme");
- frame.within(() => {
- cy.findByTestId("dashboard").should(
- "have.css",
- "background-color",
- "rgb(255, 255, 255)",
- );
+ assertDarkTheme(frame);
- cy.findByTestId("dashboard-header-container").should(
- "have.css",
- "background-color",
- "rgb(255, 255, 255)",
- );
-
- cy.findByText("Product ID").should(
- "have.css",
- "color",
- LIGHT_THEME.colors.brand,
- );
-
- cy.findByText("Showing first 2,000 rows").should(
- "have.css",
- "color",
- LIGHT_THEME.colors["text-primary"],
- );
- });
-
- cy.log("2. switch to dark theme and verify colors");
-
- cy.get("body").within(() => {
- cy.findByText("Dark").click();
- });
-
- frame.within(() => {
- cy.findByTestId("dashboard").should(
- "have.css",
- "background-color",
- DARK_THEME.colors.background,
- );
-
- cy.findByTestId("dashboard-header-container").should(
- "have.css",
- "background-color",
- DARK_THEME.colors.background,
- );
-
- cy.findByText("Product ID").should(
- "have.css",
- "color",
- DARK_THEME.colors.brand,
- );
-
- cy.findByText("Showing first 2,000 rows").should(
- "have.css",
- "color",
- DARK_THEME.colors["text-primary"],
- );
- });
-
- cy.log("3. switch to light theme and verify colors");
+ cy.log("2. switch to light theme and verify colors");
cy.get("body").within(() => {
cy.findByText("Light").click();
@@ -260,5 +166,41 @@ describe("scenarios > embedding > sdk iframe embedding > theming", () => {
LIGHT_THEME.colors["text-primary"],
);
});
+
+ cy.log("3. switch back to dark theme and verify colors");
+
+ cy.get("body").within(() => {
+ cy.findByText("Dark").click();
+ });
+
+ assertDarkTheme(frame);
});
});
+
+function assertDarkTheme(frame: Cypress.Chainable<JQuery<HTMLElement>>) {
+ frame.within(() => {
+ cy.findByTestId("dashboard").should(
+ "have.css",
+ "background-color",
+ DARK_THEME.colors.background,
+ );
+
+ cy.findByTestId("dashboard-header-container").should(
+ "have.css",
+ "background-color",
+ DARK_THEME.colors.background,
+ );
+
+ cy.findByText("Product ID").should(
+ "have.css",
+ "color",
+ DARK_THEME.colors.brand,
+ );
+
+ cy.findByText("Showing first 2,000 rows").should(
+ "have.css",
+ "color",
+ DARK_THEME.colors["text-primary"],
+ );
+ });
+}