Skip to content

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

e2e2unit: admin > whitelabel (#85221)

Nemanja Glumac60e6d50742fc
diff --git a/e2e/test/scenarios/admin/whitelabel.cy.spec.js b/e2e/test/scenarios/admin/whitelabel.cy.spec.js
index c4291459ee0..bbf68072cd3 100644
--- a/e2e/test/scenarios/admin/whitelabel.cy.spec.js
+++ b/e2e/test/scenarios/admin/whitelabel.cy.spec.js
@@ -1,5 +1,4 @@
const { H } = cy;
-import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
function checkFavicon(url) {
cy.request("/api/setting/application-favicon-url")
@@ -34,13 +33,6 @@ function checkBackgroundIllustration({ testId, settingKey, imageBase64 }) {
});
}
-function checkNoResultsIllustration({ altText, settingKey, imageBase64 }) {
- cy.findByAltText(altText)
- .should("have.prop", "src")
- .and("match", illustrationUrlPattern(settingKey))
- .then((src) => checkIllustrationResponse({ url: src, imageBase64 }));
-}
-
const MB = 1024 * 1024;
describe("formatting > whitelabel", { tags: "@EE" }, () => {
@@ -50,75 +42,31 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
H.activateToken("pro-self-hosted");
});
- it("smoke UI test", () => {
- cy.log("Should show all whitelabel options with the feature enabled");
- cy.visit("/admin/settings/whitelabel");
-
- cy.log("Upsell icon should not be present in the sidebar link");
- cy.findAllByTestId("settings-sidebar-link")
- .filter(":contains(Appearance)")
- .should("have.text", "Appearance")
- .and("not.have.descendants", ".Icon-gem");
-
- cy.log("Should show the upsell if the feature is missing");
+ it("smoke UI test: should show the upsell without the whitelabel feature", () => {
H.deleteToken();
cy.visit("/admin/settings/appearance");
cy.findByRole("heading", { name: "Make Metabase look like you" }).should(
"be.visible",
);
- cy.findByRole("link", { name: "Learn more" })
- .should("have.attr", "href")
- .and(
- "include",
- "https://www.metabase.com/docs/latest/configuring-metabase/appearance",
- )
- .and("include", "utm_");
- cy.findByRole("button", { name: "Try for free" });
-
- cy.log("Upsell icon should now be visible in the sidebar link");
- cy.findAllByTestId("settings-sidebar-link")
- .filter(":contains(Appearance)")
- .should("have.text", "Appearance")
- .and("have.descendants", ".Icon-gem");
});
- describe("company name", () => {
+ it("should show the application name in the main app (metabase#17043)", () => {
const NEW_COMPANY_NAME = "New Test Co";
-
- beforeEach(() => {
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
- cy.findByLabelText("Application name")
- .clear()
- .type(NEW_COMPANY_NAME)
- .blur();
- H.undoToast().findByText("Changes saved").should("be.visible");
- cy.findByDisplayValue(NEW_COMPANY_NAME);
- });
-
- it("should not show the old name in the admin panel (metabase#17043) and should show the new name in the main app", () => {
- cy.log(
- "should not show the old name in the admin panel (metabase#17043)",
- );
- cy.visit("/admin/settings/general");
- cy.findByTestId("site-name-setting")
- .findByText(`The name used for this instance of ${NEW_COMPANY_NAME}.`)
- .should("be.visible");
-
- cy.log("should show the new name in the main app");
- cy.visit("/");
- H.getProfileLink().click();
- H.popover().findByText("Help").click();
- H.getHelpSubmenu().findByText(`About ${NEW_COMPANY_NAME}`).click();
- H.modal()
- .findByText(`Thanks for using ${NEW_COMPANY_NAME}!`)
- .should("be.visible");
- });
+ H.updateSetting("application-name", NEW_COMPANY_NAME);
+
+ cy.signInAsNormalUser();
+ cy.visit("/");
+ H.getProfileLink().click();
+ H.popover().findByText("Help").click();
+ H.getHelpSubmenu().findByText(`About ${NEW_COMPANY_NAME}`).click();
+ H.modal()
+ .findByText(`Thanks for using ${NEW_COMPANY_NAME}!`)
+ .should("be.visible");
});
describe("image uploads", () => {
describe("company logo", () => {
- beforeEach(() => {
- cy.log("Add a logo");
+ it("should show the logo while signed out", () => {
cy.readFile("e2e/support/assets/logo.jpeg", "base64").then(
(logo_data) => {
H.updateSetting(
@@ -127,19 +75,6 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
);
},
);
- });
-
- it("changes should reflect on admin's dashboard, on user's dashboard, and while signed out", () => {
- cy.log("changes should reflect on admin's dashboard");
- cy.visit("/");
- checkLogo();
-
- cy.log("changes should reflect on user's dashboard");
- cy.signInAsNormalUser();
- cy.visit("/");
- checkLogo();
-
- cy.log("changes should reflect while signed out");
cy.signOut();
cy.visit("/");
checkLogo();
@@ -190,309 +125,38 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
});
});
- describe("custom illustrations", () => {
- describe("login page illustration", () => {
- it(
- "should only allow uploading a valid image files (PNG, JPG, SVG) and display on login page",
- { tags: "@prerelease" },
- () => {
- /**
- * Unfortunately, we couldn't test the browser file selector with Cypress yet.
- * With `input.selectFile`, we still can select any files unlike the browser file selector
- * which would respect the `accept` attribute (which specifies the accepted MIME types).
- */
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.log("test error message for file size > 2MB");
- cy.findByRole("textbox", {
- name: "Login and unsubscribe pages",
- }).click();
- H.selectDropdown().findByText("Custom").click();
- /**
- * Clicking "Choose File" doesn't actually open the file browser on Cypress,
- * so I need to use `selectFile` with the file input instead.
- */
- cy.findByTestId("login-page-illustration-setting").within(() => {
- cy.findByTestId("file-input").selectFile(
- {
- contents: Cypress.Buffer.from("a".repeat(2 * MB + 1)),
- fileName: "big-file.jpg",
- mimeType: "image/jpeg",
- },
- { force: true },
- );
- cy.findByText(
- "The image you chose is larger than 2MB. Please choose another one.",
- ).should("be.visible");
- cy.findByText("big-file.jpg").should("not.exist");
- });
- cy.findByRole("textbox", {
- name: "Login and unsubscribe pages",
- }).click();
- H.selectDropdown().findByText("Custom").click();
- cy.log("test uploading a corrupted file");
- cy.findByTestId("login-page-illustration-setting").within(() => {
- cy.findByTestId("file-input").selectFile(
- {
- contents: Cypress.Buffer.from("a".repeat(2 * MB)),
- fileName: "corrupted-file.jpg",
- mimeType: "image/jpeg",
- },
- { force: true },
- );
- cy.findByText(
- "The image you chose is corrupted. Please choose another one.",
- )
- .scrollIntoView()
- .should("be.visible");
- cy.findByText("corrupted-file.jpg").should("not.exist");
- });
-
- cy.log('test replacing the "corrupted" file with a valid one');
- cy.findByTestId("login-page-illustration-setting").within(() => {
- cy.findByTestId("file-input").selectFile(
- {
- contents: "e2e/support/assets/logo.jpeg",
- mimeType: "image/jpeg",
- },
- { force: true },
- );
- cy.findByText("logo.jpeg").should("be.visible");
-
- cy.findByText(
- "The image you chose is corrupted. Please choose another one.",
- ).should("not.exist");
- });
- H.undoToast().findByText("Changes saved").should("be.visible");
- H.undoToast().icon("close").click();
-
- cy.log("test removing the custom illustration");
- cy.findByTestId("login-page-illustration-setting").within(() => {
- cy.button("Remove custom illustration").click();
- cy.log(
- "the default option should be selected once removing the custom illustration",
- );
- cy.findByDisplayValue("Lighthouse").should("be.visible");
- });
- H.undoToast().findByText("Changes saved").should("be.visible");
- H.undoToast().icon("close").click();
-
- cy.log("test uploading a valid image file");
- cy.findByTestId("login-page-illustration-setting")
- .findByRole("textbox", { name: "Login and unsubscribe pages" })
- .click();
- H.selectDropdown().findByText("Custom").click();
- cy.findByTestId("login-page-illustration-setting").within(() => {
- cy.findByTestId("file-input").selectFile(
- {
- contents: "e2e/support/assets/logo.jpeg",
- mimeType: "image/jpeg",
- },
- { force: true },
- );
- cy.findByText("logo.jpeg").should("be.visible");
- });
- H.undoToast().findByText("Changes saved").should("be.visible");
-
- cy.readFile("e2e/support/assets/logo.jpeg", "base64").then(
- (logo_data) => {
- cy.signOut();
- cy.log("the login page loads the image from its URL");
- cy.visit("/");
- checkBackgroundIllustration({
- testId: "login-page-illustration",
- settingKey: "login-page-illustration-custom",
- imageBase64: logo_data,
- });
-
- cy.log("the unsubscribe page loads the image from its URL");
- cy.visit(
- "/unsubscribe?hash=hash&email=email&pulse-id=pulse-id",
- );
- checkBackgroundIllustration({
- testId: "unsubscribe-page-illustration",
- settingKey: "login-page-illustration-custom",
- imageBase64: logo_data,
- });
- },
- );
-
- cy.log("test no illustration");
- cy.signInAsAdmin();
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByRole("textbox", {
- name: "Login and unsubscribe pages",
- }).click();
- H.selectDropdown().findByText("No illustration").click();
-
- cy.signOut();
- cy.visit("/");
- cy.findByTestId("login-page-illustration").should("not.exist");
-
- cy.visit("/unsubscribe?hash=hash&email=email&pulse-id=pulse-id");
- cy.findByTestId("unsubscribe-page-illustration").should(
- "not.exist",
- );
- },
- );
- });
-
- describe("landing page illustration", () => {
- it("should allow display the selected illustration on the landing page and toggle metabot visibility", () => {
+ describe("login page illustration", () => {
+ it(
+ "should reject a corrupted image, accept a valid one and display it on the login page",
+ { tags: "@prerelease" },
+ () => {
cy.visit("/admin/settings/whitelabel/conceal-metabase");
- cy.findByTestId("landing-page-illustration-setting")
- .findByDisplayValue("Lighthouse")
+ cy.findByTestId("login-page-illustration-setting")
+ .findByRole("textbox", { name: "Login and unsubscribe pages" })
.click();
-
H.selectDropdown().findByText("Custom").click();
- cy.findByTestId("file-input").selectFile(
- {
- contents: "e2e/support/assets/logo.jpeg",
- mimeType: "image/jpeg",
- },
- { force: true },
- );
- cy.findByTestId("landing-page-illustration-setting")
- .findByText("logo.jpeg")
- .should("be.visible");
-
- H.undoToast().findByText("Changes saved").should("be.visible");
- cy.readFile("e2e/support/assets/logo.jpeg", "base64").then(
- (logo_data) => {
- cy.visit("/");
- checkBackgroundIllustration({
- testId: "landing-page-illustration",
- settingKey: "landing-page-illustration-custom",
- imageBase64: logo_data,
- });
- },
- );
-
- cy.log("test no illustration");
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByTestId("landing-page-illustration-setting")
- .findByDisplayValue("Custom")
- .click();
- H.selectDropdown().findByText("No illustration").click();
-
- cy.visit("/");
- cy.findByTestId("landing-page-illustration").should("not.exist");
-
- // The Metabot greeting (show-metabot) renders independently of the landing page illustration
- cy.log("should toggle metabot visibility");
- cy.findAllByRole("img", { name: "Metabot" }).should("have.length", 2);
-
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
- cy.findByRole("main")
- .findByText("Display welcome message on the homepage")
- .click();
-
- H.undoToast().findByText("Changes saved").should("be.visible");
-
- cy.visit("/");
- cy.findByRole("link", { name: /home/ }).should("exist");
- cy.findByRole("img", { name: "Metabot" }).should("not.exist");
- });
- });
-
- describe("no data illustration", () => {
- it("should allow display the selected illustration at relevant places", () => {
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByRole("textbox", {
- name: "When calculations return no results",
- }).should("have.value", "Sailboat");
-
- cy.findByRole("textbox", {
- name: "When calculations return no results",
- }).click();
- H.selectDropdown().findByText("Custom").click();
-
- cy.findByTestId("no-data-illustration-setting").within(() => {
+ cy.log("the browser can not decode a corrupted image");
+ cy.findByTestId("login-page-illustration-setting").within(() => {
cy.findByTestId("file-input").selectFile(
{
- contents: "e2e/support/assets/logo.jpeg",
+ contents: Cypress.Buffer.from("a".repeat(2 * MB)),
+ fileName: "corrupted-file.jpg",
mimeType: "image/jpeg",
},
{ force: true },
);
- cy.findByText("logo.jpeg").should("be.visible");
- });
- H.undoToast().findByText("Changes saved").should("be.visible");
-
- H.createDashboardWithQuestions({
- dashboardName: "No results dashboard",
- questions: [
- {
- name: "No results question",
- native: {
- query: "select * from products where id = 999999999",
- },
- },
- ],
- }).then(({ dashboard, questions }) => {
- cy.wrap(dashboard.id).as("dashboardId");
- cy.wrap(questions[0].id).as("questionId");
- });
-
- cy.log("test custom illustration");
-
- cy.readFile("e2e/support/assets/logo.jpeg", "base64").as("logoData");
-
- H.visitDashboard("@dashboardId");
- cy.get("@logoData").then((logo_data) => {
- checkNoResultsIllustration({
- altText: "No results",
- settingKey: "no-data-illustration-custom",
- imageBase64: logo_data,
- });
+ cy.findByText(
+ "The image you chose is corrupted. Please choose another one.",
+ )
+ .scrollIntoView()
+ .should("be.visible");
+ cy.findByText("corrupted-file.jpg").should("not.exist");
});
- H.visitQuestion("@questionId");
- cy.get("@logoData").then((logo_data) => {
- checkNoResultsIllustration({
- altText: "No results",
- settingKey: "no-data-illustration-custom",
- imageBase64: logo_data,
- });
- });
-
- cy.log("test no illustration");
-
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
- cy.findByRole("textbox", {
- name: "When calculations return no results",
- }).click();
- H.selectDropdown().findByText("No illustration").click();
-
- H.visitDashboard("@dashboardId");
- cy.findByAltText("No results").should("not.exist");
-
- H.visitQuestion("@questionId");
- cy.findByAltText("No results").should("not.exist");
- });
- });
-
- describe("no object illustration", () => {
- it("should allow display the selected illustration at relevant places", () => {
- const emptyCollectionName = "Empty Collection";
- cy.request("POST", "/api/collection", { name: emptyCollectionName });
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByRole("textbox", {
- name: "When no objects can be found",
- }).should("have.value", "Sailboat");
-
- cy.findByRole("textbox", {
- name: "When no objects can be found",
- }).click();
- H.selectDropdown().findByText("Custom").click();
-
- cy.findByTestId("no-object-illustration-setting").within(() => {
+ cy.log("the browser decodes a valid image");
+ cy.findByTestId("login-page-illustration-setting").within(() => {
cy.findByTestId("file-input").selectFile(
{
contents: "e2e/support/assets/logo.jpeg",
@@ -501,88 +165,32 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
{ force: true },
);
cy.findByText("logo.jpeg").should("be.visible");
+ cy.findByText(
+ "The image you chose is corrupted. Please choose another one.",
+ ).should("not.exist");
});
H.undoToast().findByText("Changes saved").should("be.visible");
- cy.log("test custom illustration");
-
- H.goToMainApp();
- H.appBar().findByText("New").click();
- H.popover().findByText("Dashboard").click();
- H.modal().findByTestId("collection-picker-button").click();
- H.entityPickerModal().within(() => {
- cy.readFile("e2e/support/assets/logo.jpeg", "base64").as(
- "logoData",
- );
-
- cy.log("test search not found illustration");
- cy.findByPlaceholderText("Search…").type(
- "This aren't the objects you're looking for",
- );
- cy.get("@logoData").then((logo_data) => {
- checkNoResultsIllustration({
- altText: "Nothing found",
- settingKey: "no-object-illustration-custom",
+ cy.readFile("e2e/support/assets/logo.jpeg", "base64").then(
+ (logo_data) => {
+ cy.signOut();
+ cy.log("the login page loads the image from its URL");
+ cy.visit("/");
+ checkBackgroundIllustration({
+ testId: "login-page-illustration",
+ settingKey: "login-page-illustration-custom",
imageBase64: logo_data,
});
- });
- });
-
- cy.log("test no illustration");
-
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
- cy.findByRole("textbox", {
- name: "When no objects can be found",
- }).click();
- H.selectDropdown().findByText("No illustration").click();
-
- H.goToMainApp();
- H.appBar().findByText("New").click();
- H.popover().findByText("Dashboard").click();
- H.modal().findByTestId("collection-picker-button").click();
- H.entityPickerModal().within(() => {
- cy.findByText(emptyCollectionName).click();
- cy.findByAltText("Nothing found").should("not.exist");
-
- cy.log("test search not found illustration");
- cy.findByPlaceholderText("Search…").type(
- "This aren't the objects you're looking for",
- );
- cy.findByAltText("Nothing found").should("not.exist");
- });
- });
- });
- });
- });
-
- describe("loading message", () => {
- it("should update loading message", () => {
- cy.intercept("PUT", "/api/setting/loading-message").as(
- "putLoadingMessage",
+ },
+ );
+ },
);
- const messages = [
- "Loading results...",
- "Doing science...",
- "Running query...",
- ];
-
- messages.forEach((message) => {
- changeLoadingMessage(message);
- // can't use visitQuestion helper because it waits for loading to be finished
- cy.visit(`/question/${ORDERS_QUESTION_ID}`);
- cy.findByTestId("query-builder-main").findByText(message);
- });
});
});
describe("font", () => {
- beforeEach(() => {
- cy.log("Change Application Font");
- cy.signInAsAdmin();
- });
-
it("should be able to make multiple font changes (metabase#45486) and apply the correct font for other users", () => {
- cy.log("should be able to make multiple font changes (metabase#45486)");
+ cy.log("Reproduces metabase#45486");
cy.intercept("PUT", "/api/setting/application-font").as("saveFont");
const fontsWithExpectedFallback = [
["Lora", "serif"],
@@ -604,7 +212,7 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
});
cy.log("should apply correct font");
- setApplicationFontTo("Open Sans");
+ H.updateSetting("application-font", "Open Sans");
cy.signInAsNormalUser();
cy.visit("/");
cy.get("body").should(
@@ -616,122 +224,30 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
});
describe("Help link", () => {
- beforeEach(() => {
- cy.intercept("PUT", "/api/setting/help-link").as("putHelpLink");
+ it("should validate the custom URL on the server and link to metabase help when the whitelabel feature is disabled (eg OSS)", () => {
cy.intercept("PUT", "/api/setting/help-link-custom-destination").as(
"putHelpLinkUrl",
);
- });
-
- it("should allow customising the help link, validate the url, and link to metabase help when the whitelabel feature is disabled (eg OSS)", () => {
- cy.log("Hide Help link");
-
- cy.signInAsAdmin();
cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByLabelText("Link to Metabase help").should("be.checked");
-
- cy.findByTestId("help-link-setting").findByText("Hide it").click();
- cy.wait("@putHelpLink");
-
- cy.signInAsNormalUser();
-
- cy.visit("/");
- H.getProfileLink().click();
- H.popover().findByText("Help").click();
- helpLink().should("not.exist");
-
- cy.log("Set custom Help link");
-
- cy.signInAsAdmin();
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
cy.findByTestId("help-link-setting")
.findByText("Go to a custom destination...")
.click();
- getHelpLinkCustomDestinationInput().should("have.focus");
-
- cy.log("it should validate the url");
- getHelpLinkCustomDestinationInput()
- .clear()
- .type("ftp://something")
- .blur();
- H.main()
- .findByText(/This needs to be/i)
- .should("exist");
-
getHelpLinkCustomDestinationInput().clear().type("https://").blur();
- // Wait on each custom-destination PUT so the wait below matches the final save
cy.wait("@putHelpLinkUrl");
-
- H.main()
+ cy.findByTestId("help-link-setting")
.findByText("Please make sure this is a valid URL")
- .should("exist");
+ .should("be.visible");
getHelpLinkCustomDestinationInput().type("example").blur();
cy.wait("@putHelpLinkUrl");
-
- H.main()
+ cy.findByTestId("help-link-setting")
.findByText("Please make sure this is a valid URL")
.should("not.exist");
- getHelpLinkCustomDestinationInput()
- .clear()
- .type("https://example.org/custom-destination")
- .blur();
-
- cy.wait("@putHelpLinkUrl");
-
- cy.wait("@putHelpLink");
-
- cy.log("Check that on page load the text field is not focused");
- cy.reload();
-
- getHelpLinkCustomDestinationInput().should("not.have.focus");
-
- cy.signInAsNormalUser();
- cy.visit("/");
- H.getProfileLink().click();
- H.popover().findByText("Help").click();
- helpLink().should(
- "have.attr",
- "href",
- "https://example.org/custom-destination",
- );
-
- cy.log("Set default Help link");
-
- cy.signInAsAdmin();
- cy.visit("/admin/settings/whitelabel/conceal-metabase");
-
- cy.findByTestId("help-link-setting")
- .findByText("Link to Metabase help")
- .click();
-
- cy.wait("@putHelpLink");
-
- cy.visit("/");
- H.getProfileLink().click();
- H.popover().findByText("Help").click();
-
- helpLink()
- .should("have.attr", "href")
- .and("include", "https://www.metabase.com/help-premium?");
-
- cy.signInAsNormalUser();
- cy.visit("/");
- H.getProfileLink().click();
- H.popover().findByText("Help").click();
-
- helpLink()
- .should("have.attr", "href")
- .and("include", "https://www.metabase.com/help?");
-
cy.log(
"should link to metabase help when the whitelabel feature is disabled (eg OSS)",
);
- cy.signInAsAdmin();
// Point the help link at the custom destination first, so only the
// whitelabel feature gating can bring back the default Metabase help link
H.updateSetting("help-link", "custom");
@@ -741,92 +257,24 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {
cy.visit("/");
H.getProfileLink().click();
H.popover().findByText("Help").click();
- helpLink()
+ H.getHelpSubmenu()
+ .findByRole("menuitem", { name: "Get help" })
.should("have.attr", "href")
.and("include", "https://www.metabase.com/help?");
});
});
describe("Landing Page (now moved to general tab metabase#38699)", () => {
- beforeEach(() => {
- cy.intercept("PUT", "/api/setting/landing-page").as("putLandingPage");
- cy.intercept("GET", "/api/setting").as("getSettings");
- cy.signInAsAdmin();
+ it("should go to the custom landing page from the main app", () => {
+ H.updateSetting("landing-page", "/test-1");
cy.visit("/admin/settings/general");
- cy.wait("@getSettings");
- });
-
- const urlInput = () =>
- cy
- .findByTestId("homepage-setting")
- .findByLabelText("Landing page custom destination");
-
- it("should not offer the Custom URL option when the user does not have a valid license", () => {
- H.activateToken("starter");
- cy.reload();
- cy.wait("@getSettings");
- // Anchor on a positive signal so the negative assertion can't pass while
- // the page is still loading.
- cy.findByTestId("homepage-setting")
- .findByRole("radio", { name: "Default Metabase home" })
- .should("be.visible");
- cy.findByTestId("homepage-setting")
- .findByRole("radio", { name: "Custom URL" })
- .should("not.exist");
- });
-
- it("should validate the URL and persist only same-origin relative paths", () => {
- // Clicking "Custom URL" fires a PUT to /api/setting (custom-homepage =
- // false) AND mounts the URL field. On fetch (microtask resolution) the
- // mount's landing-page read + the PUT response can land while we're in
- // the middle of typing; LandingPageUrlField's useEffect would then
- // overwrite the typed value. Wait for the PUT to land first.
- cy.intercept("PUT", "/api/setting").as("modeChangePut");
- cy.findByTestId("homepage-setting")
- .findByRole("radio", { name: "Custom URL" })
- .click();
- cy.wait("@modeChangePut");
-
- urlInput()
- .click()
- .clear()
- .type("/test-1")
- .should("have.value", "/test-1")
- .blur();
- cy.wait("@putLandingPage");
- H.undoToast().findByText("Changes saved").should("be.visible");
-
- // External URLs are rejected and the previous value is preserved.
- urlInput()
- .click()
- .clear()
- .should("have.value", "")
- .type("https://google.com")
- .should("have.value", "https://google.com")
- .blur();
- cy.findByTestId("admin-layout-content")
- .findByText("This field must be a relative URL.")
- .should("be.visible");
-
H.goToMainApp();
cy.url().should("include", "/test-1");
});
});
});
-function changeLoadingMessage(message) {
- cy.visit("/admin/settings/whitelabel");
- cy.findByLabelText("Loading message").click();
- H.selectDropdown().findByText(message).click();
- cy.wait("@putLoadingMessage");
-}
-
-function setApplicationFontTo(font) {
- H.updateSetting("application-font", font);
-}
-
-const helpLink = () =>
- H.getHelpSubmenu().findByRole("menuitem", { name: "Get help" });
-
const getHelpLinkCustomDestinationInput = () =>
- cy.findByPlaceholderText("Enter a URL it should go to");
+ cy
+ .findByTestId("help-link-setting")
+ .findByPlaceholderText("Enter a URL it should go to");
diff --git a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/HelpLinkSettings/HelpLinkSettings.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/HelpLinkSettings/HelpLinkSettings.unit.spec.tsx
index 388b61e2c93..28a8dc78dba 100644
--- a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/HelpLinkSettings/HelpLinkSettings.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/HelpLinkSettings/HelpLinkSettings.unit.spec.tsx
@@ -4,10 +4,16 @@ import {
findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
+ setupStatefulSettingsEndpoints,
setupUpdateSettingEndpoint,
} from "__support__/server-mocks";
import { createMockSettingsState } from "__support__/state";
-import { fireEvent, renderWithProviders, screen } from "__support__/ui";
+import {
+ fireEvent,
+ renderWithProviders,
+ screen,
+ waitFor,
+} from "__support__/ui";
import type { EnterpriseSettings } from "metabase-types/api";
import { createMockSettings } from "metabase-types/api/mocks";
@@ -40,7 +46,9 @@ describe("HelpLinkSettings", () => {
it("should show radio options", async () => {
await setup();
- expect(screen.getByText("Link to Metabase help")).toBeInTheDocument();
+ expect(
+ screen.getByRole("radio", { name: "Link to Metabase help" }),
+ ).toBeChecked();
expect(screen.getByText("Hide it")).toBeInTheDocument();
expect(
screen.getByText("Go to a custom destination..."),
@@ -81,7 +89,7 @@ describe("HelpLinkSettings", () => {
await userEvent.click(screen.getByText("Hide it"));
const [{ url, body }] = await findRequests("PUT");
- expect(url).toMatch(/help-link/);
+ expect(url).toMatch(/\/api\/setting\/help-link$/);
expect(body).toEqual({
value: "hidden",
});
@@ -113,6 +121,16 @@ describe("HelpLinkSettings", () => {
),
).toBeInTheDocument();
+ // unsupported protocol
+ await userEvent.clear(input);
+ await userEvent.type(input, "ftp://something");
+ fireEvent.blur(input);
+ expect(
+ await screen.findByText(
+ 'This needs to be an "http://", "https://" or "mailto:" URL.',
+ ),
+ ).toBeInTheDocument();
+
// shouldn't fire any PUT request
const puts = await findRequests("PUT");
expect(puts).toHaveLength(0);
@@ -139,4 +157,70 @@ describe("HelpLinkSettings", () => {
value: "https://help.com/help",
});
});
+
+ it("should show the error from the API and clear it after a valid save", async () => {
+ await setup({
+ settings: {
+ "help-link": "custom",
+ "help-link-custom-destination": "https://example.com/help",
+ },
+ });
+ // The setting validation throws without a status code, so the API
+ // responds with a 500 and the message in the body.
+ setupUpdateSettingEndpoint({
+ status: 500,
+ body: { message: "Please make sure this is a valid URL" },
+ });
+
+ const input = await screen.findByDisplayValue("https://example.com/help");
+ await userEvent.clear(input);
+ await userEvent.type(input, "https://");
+ fireEvent.blur(input);
+ expect(
+ await screen.findByText("Please make sure this is a valid URL"),
+ ).toBeInTheDocument();
+
+ setupUpdateSettingEndpoint();
+ await userEvent.type(input, "example");
+ fireEvent.blur(input);
+ await waitFor(() =>
+ expect(
+ screen.queryByText("Please make sure this is a valid URL"),
+ ).not.toBeInTheDocument(),
+ );
+ const puts = await findRequests("PUT");
+ expect(puts.map(({ body }) => body)).toEqual([
+ { value: "https://" },
+ { value: "https://example" },
+ ]);
+ });
+
+ it("should focus the URL input after choosing a custom destination", async () => {
+ await setup();
+ setupStatefulSettingsEndpoints({
+ "help-link": "metabase",
+ "help-link-custom-destination": "https://example.com/help",
+ });
+
+ await userEvent.click(
+ screen.getByRole("radio", { name: "Go to a custom destination..." }),
+ );
+
+ expect(
+ await screen.findByPlaceholderText("Enter a URL it should go to"),
+ ).toHaveFocus();
+ });
+
+ it("should not focus the URL input on page load", async () => {
+ await setup({
+ settings: {
+ "help-link": "custom",
+ "help-link-custom-destination": "https://example.com/help",
+ },
+ });
+
+ expect(
+ await screen.findByPlaceholderText("Enter a URL it should go to"),
+ ).not.toHaveFocus();
+ });
});
diff --git a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/IllustrationWidget/IllustrationWidget.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/IllustrationWidget/IllustrationWidget.unit.spec.tsx
index 54d26a6d6c8..d6ce9c53200 100644
--- a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/IllustrationWidget/IllustrationWidget.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/IllustrationWidget/IllustrationWidget.unit.spec.tsx
@@ -2,9 +2,8 @@ import userEvent from "@testing-library/user-event";
import {
findRequests,
- setupPropertiesEndpoints,
setupSettingsEndpoints,
- setupUpdateSettingEndpoint,
+ setupStatefulSettingsEndpoints,
} from "__support__/server-mocks";
import { renderWithProviders, screen, waitFor } from "__support__/ui";
import type {
@@ -47,9 +46,8 @@ async function setup({
"no-object-illustration-custom": "",
...settingOverrides,
});
- setupPropertiesEndpoints(settings);
+ setupStatefulSettingsEndpoints(settings);
setupSettingsEndpoints([]);
- setupUpdateSettingEndpoint();
renderWithProviders(
<IllustrationWidget name={name} title={title} description={description} />,
@@ -58,6 +56,26 @@ async function setup({
await screen.findByText(title);
}
+const MB = 1024 * 1024;
+
+// jsdom does not decode images, so fire the load or error event that a
+// browser fires for an intact or a corrupted image.
+function mockImageDecoding({ isIntact }: { isIntact: boolean }) {
+ return jest
+ .spyOn(HTMLImageElement.prototype, "src", "set")
+ .mockImplementation(function (this: HTMLImageElement) {
+ setTimeout(() => {
+ this.dispatchEvent(new Event(isIntact ? "load" : "error"));
+ });
+ });
+}
+
+async function selectCustomAndUpload(file: File) {
+ await userEvent.click(screen.getByRole("textbox"));
+ await userEvent.click(screen.getByText("Custom"));
+ await userEvent.upload(screen.getByTestId("file-input"), file);
+}
+
describe("IllustrationWidget", () => {
describe("select options", () => {
it("should render default value", async () => {
@@ -69,6 +87,14 @@ describe("IllustrationWidget", () => {
expect(screen.getByText("Login page illustration")).toBeInTheDocument();
});
+ it.each(["no-data-illustration", "no-object-illustration"] as const)(
+ "should render the Sailboat default value for %s",
+ async (name) => {
+ await setup({ name, title: "Illustration" });
+ expect(await screen.findByDisplayValue("Sailboat")).toBeInTheDocument();
+ },
+ );
+
it("should render options", async () => {
await setup({
name: "login-page-illustration",
@@ -107,12 +133,6 @@ describe("IllustrationWidget", () => {
expect(puts).toHaveLength(0);
});
- /**
- * We couldn't test uploading an image because it relies on image.onerror and image.onload
- * which don't seem to be supported by jsdom. However the file upload test cases has already
- * been covered in E2E tests.
- */
-
it("should not remove the custom uploaded image after changing the option away from custom", async () => {
const fakeImage = new Blob(["fake-image"], {
type: "image/png",
@@ -154,7 +174,12 @@ describe("IllustrationWidget", () => {
},
});
- await userEvent.click(await screen.findByLabelText("close icon"));
+ await userEvent.click(
+ await screen.findByRole("button", {
+ name: "Remove custom illustration",
+ }),
+ );
+ expect(await screen.findByDisplayValue("Lighthouse")).toBeInTheDocument();
await waitFor(async () => {
const puts = await findRequests("PUT");
@@ -177,6 +202,107 @@ describe("IllustrationWidget", () => {
});
});
+ describe("file upload", () => {
+ afterEach(() => {
+ jest.restoreAllMocks();
+ });
+
+ it("should reject an image larger than 2MB", async () => {
+ mockImageDecoding({ isIntact: true });
+ await setup({
+ name: "login-page-illustration",
+ title: "Login page illustration",
+ });
+
+ await selectCustomAndUpload(
+ new File(["a".repeat(2 * MB + 1)], "big-file.jpg", {
+ type: "image/jpeg",
+ }),
+ );
+
+ expect(
+ await screen.findByText(
+ "The image you chose is larger than 2MB. Please choose another one.",
+ ),
+ ).toBeInTheDocument();
+ expect(screen.queryByText("big-file.jpg")).not.toBeInTheDocument();
+ expect(await findRequests("PUT")).toHaveLength(0);
+ });
+
+ it("should reject a corrupted image", async () => {
+ mockImageDecoding({ isIntact: false });
+ await setup({
+ name: "login-page-illustration",
+ title: "Login page illustration",
+ });
+
+ await selectCustomAndUpload(
+ new File(["a".repeat(2 * MB)], "corrupted-file.jpg", {
+ type: "image/jpeg",
+ }),
+ );
+
+ expect(
+ await screen.findByText(
+ "The image you chose is corrupted. Please choose another one.",
+ ),
+ ).toBeInTheDocument();
+ expect(screen.queryByText("corrupted-file.jpg")).not.toBeInTheDocument();
+ expect(await findRequests("PUT")).toHaveLength(0);
+ });
+
+ it.each([
+ "login-page-illustration",
+ "landing-page-illustration",
+ "no-data-illustration",
+ "no-object-illustration",
+ ] as const)("should save an uploaded image for %s", async (name) => {
+ mockImageDecoding({ isIntact: true });
+ await setup({ name, title: "Illustration" });
+
+ await selectCustomAndUpload(
+ new File(["logo"], "logo.jpeg", { type: "image/jpeg" }),
+ );
+
+ expect(await screen.findByText("logo.jpeg")).toBeInTheDocument();
+ const puts = await findRequests("PUT");
+ expect(puts.map(({ url, body }) => ({ url, body }))).toEqual([
+ {
+ url: `http://localhost/api/setting/${name}`,
+ body: { value: "custom" },
+ },
+ {
+ url: `http://localhost/api/setting/${name}-custom`,
+ body: { value: "data:image/jpeg;base64,bG9nbw==" },
+ },
+ ]);
+ });
+
+ it("should clear the corrupted image error after a valid upload", async () => {
+ const imageDecoding = mockImageDecoding({ isIntact: false });
+ await setup({
+ name: "login-page-illustration",
+ title: "Login page illustration",
+ });
+ await selectCustomAndUpload(
+ new File(["corrupted"], "corrupted-file.jpg", { type: "image/jpeg" }),
+ );
+ const errorMessage =
+ "The image you chose is corrupted. Please choose another one.";
+ expect(await screen.findByText(errorMessage)).toBeInTheDocument();
+
+ imageDecoding.mockRestore();
+ mockImageDecoding({ isIntact: true });
+ await userEvent.upload(
+ screen.getByTestId("file-input"),
+ new File(["logo"], "logo.jpeg", { type: "image/jpeg" }),
+ );
+
+ expect(await screen.findByText("logo.jpeg")).toBeInTheDocument();
+ expect(screen.queryByText(errorMessage)).not.toBeInTheDocument();
+ });
+ });
+
describe("select the same option twice", () => {
it("should update if the setting hasn't changed", async () => {
await setup({
diff --git a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/LandingPageUrlField/LandingPageUrlField.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/LandingPageUrlField/LandingPageUrlField.unit.spec.tsx
new file mode 100644
index 00000000000..3d3bf559bb1
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/LandingPageUrlField/LandingPageUrlField.unit.spec.tsx
@@ -0,0 +1,71 @@
+import userEvent from "@testing-library/user-event";
+
+import {
+ findRequests,
+ setupSettingsEndpoints,
+ setupStatefulSettingsEndpoints,
+} from "__support__/server-mocks";
+import { renderWithProviders, screen } from "__support__/ui";
+import { UndoListing } from "metabase/common/components/UndoListing";
+import { createMockSettings } from "metabase-types/api/mocks";
+
+import { LandingPageUrlField } from "./LandingPageUrlField";
+
+interface SetupOpts {
+ landingPage?: string;
+}
+
+const setup = ({ landingPage = "" }: SetupOpts = {}) => {
+ setupStatefulSettingsEndpoints(
+ createMockSettings({ "landing-page": landingPage }),
+ );
+ setupSettingsEndpoints([]);
+
+ renderWithProviders(
+ <>
+ <LandingPageUrlField />
+ <UndoListing />
+ </>,
+ );
+};
+
+const getInput = () =>
+ screen.findByLabelText("Landing page custom destination");
+
+describe("LandingPageUrlField", () => {
+ // The setting arrives after the first render, so the saved value reaches the
+ // input through an effect rather than through its initial state.
+ it("should show the saved landing page once the setting loads", async () => {
+ setup({ landingPage: "/dashboard/1" });
+
+ expect(await screen.findByDisplayValue("/dashboard/1")).toBeInTheDocument();
+ });
+
+ it("should save a relative URL", async () => {
+ setup();
+
+ await userEvent.type(await getInput(), "/test-1");
+ await userEvent.tab();
+
+ expect(await screen.findByText("Changes saved")).toBeInTheDocument();
+ const [put] = await findRequests("PUT");
+ expect(put.url).toMatch(/\/api\/setting\/landing-page$/);
+ expect(put.body).toEqual({ value: "/test-1" });
+ });
+
+ it("should reject an external URL and clear the error once typing resumes", async () => {
+ setup();
+ const input = await getInput();
+ const error = "This field must be a relative URL.";
+
+ await userEvent.type(input, "https://google.com");
+ await userEvent.tab();
+
+ expect(await screen.findByText(error)).toBeInTheDocument();
+ expect(await findRequests("PUT")).toHaveLength(0);
+
+ await userEvent.type(input, "/fixed");
+
+ expect(screen.queryByText(error)).not.toBeInTheDocument();
+ });
+});
diff --git a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelBrandingSettingsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelBrandingSettingsPage.unit.spec.tsx
index 870c323d2de..54d46742adb 100644
--- a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelBrandingSettingsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelBrandingSettingsPage.unit.spec.tsx
@@ -1,9 +1,14 @@
+import userEvent from "@testing-library/user-event";
+
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
+ setupUpdateSettingEndpoint,
} from "__support__/server-mocks";
import { renderWithProviders, screen } from "__support__/ui";
import { UndoListing } from "metabase/common/components/UndoListing";
+import type { LoadingMessage } from "metabase-types/api";
import {
createMockSettingDefinition,
createMockSettings,
@@ -11,8 +16,14 @@ import {
import { WhiteLabelBrandingSettingsPage } from "./WhiteLabelBrandingSettingsPage";
-const setup = async () => {
- const settings = createMockSettings({});
+interface SetupOpts {
+ loadingMessage?: LoadingMessage;
+}
+
+const setup = async ({ loadingMessage }: SetupOpts = {}) => {
+ const settings = createMockSettings({
+ ...(loadingMessage && { "loading-message": loadingMessage }),
+ });
setupPropertiesEndpoints(settings);
setupSettingsEndpoints([
@@ -21,6 +32,7 @@ const setup = async () => {
description: "Login page illustration",
}),
]);
+ setupUpdateSettingEndpoint();
renderWithProviders(
<>
@@ -48,4 +60,24 @@ describe("branding settings", () => {
expect((await screen.findAllByText(setting)).length).toBeGreaterThan(0);
});
+
+ it.each([
+ { label: "Loading results...", value: "loading-results" },
+ { label: "Running query...", value: "running-query" },
+ { label: "Doing science...", value: "doing-science" },
+ ] as const)("saves the $label loading message", async ({ label, value }) => {
+ await setup({
+ loadingMessage:
+ value === "doing-science" ? "running-query" : "doing-science",
+ });
+
+ await userEvent.click(await screen.findByLabelText("Loading message"));
+ await userEvent.click(await screen.findByRole("option", { name: label }));
+
+ expect(await screen.findByText("Changes saved")).toBeInTheDocument();
+ const puts = await findRequests("PUT");
+ expect(puts).toHaveLength(1);
+ expect(puts[0].url).toMatch(/\/api\/setting\/loading-message$/);
+ expect(puts[0].body).toEqual({ value });
+ });
});
diff --git a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelConcealSettingsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelConcealSettingsPage.unit.spec.tsx
index 15788d179ed..cd4efbbb363 100644
--- a/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelConcealSettingsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/whitelabel/components/WhiteLabelConcealSettingsPage.unit.spec.tsx
@@ -1,8 +1,12 @@
+import userEvent from "@testing-library/user-event";
+
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
+ setupUpdateSettingEndpoint,
} from "__support__/server-mocks";
-import { renderWithProviders, screen } from "__support__/ui";
+import { fireEvent, renderWithProviders, screen } from "__support__/ui";
import { UndoListing } from "metabase/common/components/UndoListing";
import {
createMockSettingDefinition,
@@ -21,6 +25,7 @@ const setup = async () => {
description: "Login page illustration",
}),
]);
+ setupUpdateSettingEndpoint();
renderWithProviders(
<>
@@ -50,4 +55,19 @@ describe("WhiteLabelConcealSettingsPage", () => {
expect((await screen.findAllByText(setting)).length).toBeGreaterThan(0);
});
+
+ it("saves the application name", async () => {
+ await setup();
+
+ const input = await screen.findByLabelText("Application name");
+ await userEvent.clear(input);
+ await userEvent.type(input, "New Test Co");
+ fireEvent.blur(input);
+
+ expect(await screen.findByText("Changes saved")).toBeInTheDocument();
+ const puts = await findRequests("PUT");
+ expect(puts).toHaveLength(1);
+ expect(puts[0].url).toContain("/api/setting/application-name");
+ expect(puts[0].body).toEqual({ value: "New Test Co" });
+ });
});
diff --git a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx
index d4223bd1beb..558f769541d 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx
@@ -3,7 +3,7 @@ import fetchMock from "fetch-mock";
import { setupSettingEndpoint } from "__support__/server-mocks";
import { createMockSettingsState } from "__support__/state";
-import { renderWithProviders, screen } from "__support__/ui";
+import { renderWithProviders, screen, within } from "__support__/ui";
import { Route } from "metabase/router";
import type { TokenFeatures } from "metabase-types/api";
import {
@@ -191,6 +191,27 @@ describe("SettingsNav", () => {
expect(screen.getByText("Conceal Metabase")).toBeInTheDocument();
});
+ it.each([
+ { whitelabel: true, hasGem: false },
+ { whitelabel: false, hasGem: true },
+ ])(
+ "should show the upsell gem on the Appearance link only without the whitelabel feature (whitelabel: $whitelabel)",
+ async ({ whitelabel, hasGem }) => {
+ await setup({
+ initialRoute: "/admin/settings/general",
+ tokenFeatures: { whitelabel },
+ });
+
+ const appearanceLink = await screen.findByRole("link", {
+ name: /Appearance/,
+ });
+ expect(appearanceLink).toHaveTextContent(/^Appearance$/);
+ expect(within(appearanceLink).queryByTestId("upsell-gem") !== null).toBe(
+ hasGem,
+ );
+ },
+ );
+
it("should hide Authentication and Python Runner from settings managers even with related tokens", async () => {
await setup({
initialRoute: "/admin/settings/general",
diff --git a/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
index 92145e0ce96..9757f7fffe1 100644
--- a/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { screen, waitFor } from "__support__/ui";
+import { screen, waitFor, within } from "__support__/ui";
import {
setup as baseSetup,
@@ -62,6 +62,40 @@ describe("Admin Settings Routing - Enterprise without features", () => {
);
});
+ it("should link the appearance upsell to the docs and offer a trial", async () => {
+ await setup({ isAdmin: true, initialRoute: "/appearance" });
+
+ expect(
+ await screen.findByRole("heading", {
+ name: "Make Metabase look like you",
+ }),
+ ).toBeInTheDocument();
+ const learnMoreHref = screen
+ .getByRole("link", { name: "Learn more" })
+ .getAttribute("href");
+ expect(learnMoreHref).toContain(
+ "https://www.metabase.com/docs/latest/configuring-metabase/appearance",
+ );
+ expect(learnMoreHref).toContain("utm_");
+ expect(
+ screen.getByRole("button", { name: "Try for free" }),
+ ).toBeInTheDocument();
+ });
+
+ it("should not offer a custom URL landing page without the whitelabel feature", async () => {
+ await setup({ isAdmin: true, initialRoute: "/general" });
+
+ const homepageSetting = await screen.findByTestId("homepage-setting");
+ expect(
+ within(homepageSetting).getByRole("radio", {
+ name: "Default Metabase home",
+ }),
+ ).toBeInTheDocument();
+ expect(
+ within(homepageSetting).queryByRole("radio", { name: "Custom URL" }),
+ ).not.toBeInTheDocument();
+ });
+
describe("does not render the premium routes", () => {
it.each(notFoundRoutes)(
"should not find the $name enterprise route",
diff --git a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
index 5019db950eb..a6969e0a05a 100644
--- a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { screen, waitFor } from "__support__/ui";
+import { screen, waitFor, within } from "__support__/ui";
import {
setup as baseSetup,
@@ -74,4 +74,13 @@ describe("Admin Settings Routing - Enterprise with all features", () => {
});
expect(await screen.findByText("Cloud settings")).toBeInTheDocument();
});
+
+ it("should offer a custom URL landing page with the whitelabel feature", async () => {
+ await setup({ isAdmin: true, initialRoute: "/general" });
+
+ const homepageSetting = await screen.findByTestId("homepage-setting");
+ expect(
+ within(homepageSetting).getByRole("radio", { name: "Custom URL" }),
+ ).toBeInTheDocument();
+ });
});
diff --git a/frontend/src/metabase/auth/components/AuthLayout/AuthLayout.unit.spec.tsx b/frontend/src/metabase/auth/components/AuthLayout/AuthLayout.unit.spec.tsx
new file mode 100644
index 00000000000..851d4aa3be1
--- /dev/null
+++ b/frontend/src/metabase/auth/components/AuthLayout/AuthLayout.unit.spec.tsx
@@ -0,0 +1,66 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
+import { renderWithProviders, screen, within } from "__support__/ui";
+import type { IllustrationSettingValue } from "metabase-types/api";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
+
+import { AuthLayout } from "./AuthLayout";
+
+jest.mock("metabase/common/components/LighthouseIllustration", () => ({
+ LighthouseIllustration: () => <div data-testid="lighthouse-illustration" />,
+}));
+
+const LOGO_URL = "data:image/jpeg;base64,/9j/4AAQSkZJRg==";
+const ILLUSTRATION_URL =
+ "api/session/illustration/login-page-illustration-custom?v=0123456789abcdef";
+
+interface SetupOpts {
+ loginPageIllustration?: IllustrationSettingValue;
+}
+
+const setup = ({ loginPageIllustration = "default" }: SetupOpts = {}) => {
+ const settings = mockSettings({
+ "application-logo-url": LOGO_URL,
+ "login-page-illustration": loginPageIllustration,
+ "login-page-illustration-custom": ILLUSTRATION_URL,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ });
+ setupEnterpriseOnlyPlugin("whitelabel");
+
+ renderWithProviders(<AuthLayout />, { storeInitialState: { settings } });
+};
+
+describe("AuthLayout (EE with whitelabel)", () => {
+ it("should show the whitelabel logo", async () => {
+ setup();
+
+ const logo = await screen.findByTestId("main-logo");
+ expect(within(logo).getByRole("img")).toHaveAttribute("src", LOGO_URL);
+ });
+
+ it("should show a custom login page illustration", () => {
+ setup({ loginPageIllustration: "custom" });
+
+ expect(screen.getByTestId("login-page-illustration")).toHaveStyle({
+ backgroundImage: `url("${ILLUSTRATION_URL}")`,
+ });
+ });
+
+ it("should show the lighthouse illustration by default", () => {
+ setup({ loginPageIllustration: "default" });
+
+ expect(screen.getByTestId("lighthouse-illustration")).toBeInTheDocument();
+ });
+
+ it("should not show an illustration when it is turned off", () => {
+ setup({ loginPageIllustration: "none" });
+
+ expect(screen.getByTestId("login-page")).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("login-page-illustration"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByTestId("lighthouse-illustration"),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/common/components/Pickers/EntityPicker/components/test/EntityPickerModal.unit.spec.tsx b/frontend/src/metabase/common/components/Pickers/EntityPicker/components/test/EntityPickerModal.unit.spec.tsx
index 43b41452a9c..7d96101492b 100644
--- a/frontend/src/metabase/common/components/Pickers/EntityPicker/components/test/EntityPickerModal.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Pickers/EntityPicker/components/test/EntityPickerModal.unit.spec.tsx
@@ -791,6 +791,20 @@ describe("EntityPickerModal", () => {
expect(within(searchList).getAllByRole("link")).toHaveLength(11);
});
+ it("should show the no objects illustration when the search finds nothing", async () => {
+ await setup({ searchResults: [] });
+
+ await userEvent.type(
+ await screen.findByPlaceholderText("Search…"),
+ "This aren't the objects you're looking for",
+ );
+
+ await waitFor(() => {
+ expect(screen.getByText("We didn't find anything")).toBeInTheDocument();
+ expect(screen.getByAltText("Nothing found")).toBeInTheDocument();
+ });
+ });
+
it("should hide search results based on isHiddenItem", async () => {
await setup({
isHiddenItem: (item) => item.name.includes("Dash"),
diff --git a/frontend/src/metabase/common/components/Unsubscribe.unit.spec.tsx b/frontend/src/metabase/common/components/Unsubscribe.unit.spec.tsx
new file mode 100644
index 00000000000..469d93e7849
--- /dev/null
+++ b/frontend/src/metabase/common/components/Unsubscribe.unit.spec.tsx
@@ -0,0 +1,77 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { setupUnsubscribeFromPulseEndpoint } from "__support__/server-mocks";
+import { mockSettings } from "__support__/settings";
+import { renderWithProviders, screen } from "__support__/ui";
+import { Route } from "metabase/router";
+import type { IllustrationSettingValue } from "metabase-types/api";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
+
+import { UnsubscribePage } from "./Unsubscribe";
+
+jest.mock("metabase/common/components/LighthouseIllustration", () => ({
+ LighthouseIllustration: () => <div data-testid="lighthouse-illustration" />,
+}));
+
+const ILLUSTRATION_URL =
+ "api/session/illustration/login-page-illustration-custom?v=0123456789abcdef";
+
+interface SetupOpts {
+ loginPageIllustration: IllustrationSettingValue;
+}
+
+const setup = ({ loginPageIllustration }: SetupOpts) => {
+ const settings = mockSettings({
+ // A non-SVG data URI renders without a fetch of the whitelabel logo
+ "application-logo-url": "data:image/png;base64,iVBORw0KGgo=",
+ "login-page-illustration": loginPageIllustration,
+ "login-page-illustration-custom": ILLUSTRATION_URL,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ });
+ setupEnterpriseOnlyPlugin("whitelabel");
+ setupUnsubscribeFromPulseEndpoint({ title: "Orders alert" });
+
+ renderWithProviders(
+ <Route path="/unsubscribe" element={<UnsubscribePage />} />,
+ {
+ withRouter: true,
+ initialRoute: "/unsubscribe?hash=hash&email=email&pulse-id=pulse-id",
+ storeInitialState: { settings },
+ },
+ );
+};
+
+describe("UnsubscribePage (EE with whitelabel)", () => {
+ it("should show a custom login page illustration", async () => {
+ setup({ loginPageIllustration: "custom" });
+
+ expect(
+ await screen.findByText(/from the "Orders alert" alert/),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId("unsubscribe-page-illustration")).toHaveStyle({
+ backgroundImage: `url("${ILLUSTRATION_URL}")`,
+ });
+ });
+
+ it("should show the lighthouse illustration by default", async () => {
+ setup({ loginPageIllustration: "default" });
+
+ expect(
+ await screen.findByText(/from the "Orders alert" alert/),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId("lighthouse-illustration")).toBeInTheDocument();
+ });
+
+ it("should not show an illustration when it is turned off", async () => {
+ setup({ loginPageIllustration: "none" });
+
+ expect(
+ await screen.findByText(/from the "Orders alert" alert/),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("unsubscribe-page-illustration"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByTestId("lighthouse-illustration"),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/common/components/errors/NoDataError.unit.spec.tsx b/frontend/src/metabase/common/components/errors/NoDataError.unit.spec.tsx
new file mode 100644
index 00000000000..4db3d79dcbb
--- /dev/null
+++ b/frontend/src/metabase/common/components/errors/NoDataError.unit.spec.tsx
@@ -0,0 +1,42 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
+import { renderWithProviders, screen } from "__support__/ui";
+import type { IllustrationSettingValue } from "metabase-types/api";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
+
+import { NoDataError } from "./NoDataError";
+
+const ILLUSTRATION_URL =
+ "api/session/illustration/no-data-illustration-custom?v=0123456789abcdef";
+
+interface SetupOpts {
+ illustration: IllustrationSettingValue;
+}
+
+const setup = ({ illustration }: SetupOpts) => {
+ const settings = mockSettings({
+ "no-data-illustration": illustration,
+ "no-data-illustration-custom": ILLUSTRATION_URL,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ });
+ setupEnterpriseOnlyPlugin("whitelabel");
+
+ renderWithProviders(<NoDataError />, { storeInitialState: { settings } });
+};
+
+describe("NoDataError (EE with whitelabel)", () => {
+ it("should show a custom illustration", () => {
+ setup({ illustration: "custom" });
+
+ expect(screen.getByAltText("No results")).toHaveAttribute(
+ "src",
+ ILLUSTRATION_URL,
+ );
+ });
+
+ it("should not show an illustration when it is turned off", () => {
+ setup({ illustration: "none" });
+
+ expect(screen.queryByAltText("No results")).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/common/components/errors/NoObjectError.unit.spec.tsx b/frontend/src/metabase/common/components/errors/NoObjectError.unit.spec.tsx
new file mode 100644
index 00000000000..4aadeee1c0d
--- /dev/null
+++ b/frontend/src/metabase/common/components/errors/NoObjectError.unit.spec.tsx
@@ -0,0 +1,42 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
+import { renderWithProviders, screen } from "__support__/ui";
+import type { IllustrationSettingValue } from "metabase-types/api";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
+
+import { NoObjectError } from "./NoObjectError";
+
+const ILLUSTRATION_URL =
+ "api/session/illustration/no-object-illustration-custom?v=0123456789abcdef";
+
+interface SetupOpts {
+ illustration: IllustrationSettingValue;
+}
+
+const setup = ({ illustration }: SetupOpts) => {
+ const settings = mockSettings({
+ "no-object-illustration": illustration,
+ "no-object-illustration-custom": ILLUSTRATION_URL,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ });
+ setupEnterpriseOnlyPlugin("whitelabel");
+
+ renderWithProviders(<NoObjectError />, { storeInitialState: { settings } });
+};
+
+describe("NoObjectError (EE with whitelabel)", () => {
+ it("should show a custom illustration", () => {
+ setup({ illustration: "custom" });
+
+ expect(screen.getByAltText("Nothing found")).toHaveAttribute(
+ "src",
+ ILLUSTRATION_URL,
+ );
+ });
+
+ it("should not show an illustration when it is turned off", () => {
+ setup({ illustration: "none" });
+
+ expect(screen.queryByAltText("Nothing found")).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.unit.spec.tsx b/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.unit.spec.tsx
index 2059a122535..6a1338665bc 100644
--- a/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/HomeGreeting/HomeGreeting.unit.spec.tsx
@@ -29,7 +29,7 @@ describe("HomeGreeting", () => {
});
expect(screen.getByText(/John/)).toBeInTheDocument();
- expect(screen.getAllByRole("img")).toHaveLength(2);
+ expect(screen.getAllByRole("img", { name: "Metabot" })).toHaveLength(2);
});
it("should render nothing when the welcome message is turned off", () => {
diff --git a/frontend/src/metabase/home/components/HomeLayout/HomeLayout.unit.spec.tsx b/frontend/src/metabase/home/components/HomeLayout/HomeLayout.unit.spec.tsx
index a58663a03ba..ecbe7a61a91 100644
--- a/frontend/src/metabase/home/components/HomeLayout/HomeLayout.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/HomeLayout/HomeLayout.unit.spec.tsx
@@ -1,18 +1,41 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
import { createMockState } from "__support__/state";
import { renderWithProviders, screen } from "__support__/ui";
-import type { User } from "metabase-types/api";
-import { createMockUser } from "metabase-types/api/mocks";
+import type { IllustrationSettingValue, User } from "metabase-types/api";
+import {
+ createMockTokenFeatures,
+ createMockUser,
+} from "metabase-types/api/mocks";
import { HomeLayout } from "./HomeLayout";
+jest.mock("metabase/common/components/LighthouseIllustration", () => ({
+ LighthouseIllustration: () => <div data-testid="lighthouse-illustration" />,
+}));
+
+const ILLUSTRATION_URL =
+ "api/session/illustration/landing-page-illustration-custom?v=0123456789abcdef";
+
interface SetupOpts {
currentUser?: User;
+ landingPageIllustration?: IllustrationSettingValue;
}
-const setup = ({ currentUser }: SetupOpts = {}) => {
+const setup = ({ currentUser, landingPageIllustration }: SetupOpts = {}) => {
const state = createMockState({
currentUser,
+ ...(landingPageIllustration && {
+ settings: mockSettings({
+ "landing-page-illustration": landingPageIllustration,
+ "landing-page-illustration-custom": ILLUSTRATION_URL,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ }),
+ }),
});
+ if (landingPageIllustration) {
+ setupEnterpriseOnlyPlugin("whitelabel");
+ }
renderWithProviders(<HomeLayout />, {
storeInitialState: state,
@@ -38,4 +61,32 @@ describe("HomeLayout", () => {
});
expect(screen.queryByText(/Customize/)).not.toBeInTheDocument();
});
+
+ describe("EE with whitelabel", () => {
+ it("should show a custom landing page illustration", () => {
+ setup({ landingPageIllustration: "custom" });
+
+ expect(screen.getByTestId("landing-page-illustration")).toHaveStyle({
+ backgroundImage: `url("${ILLUSTRATION_URL}")`,
+ });
+ });
+
+ it("should show the lighthouse illustration by default", () => {
+ setup({ landingPageIllustration: "default" });
+
+ expect(screen.getByTestId("lighthouse-illustration")).toBeInTheDocument();
+ });
+
+ it("should not show an illustration when it is turned off", () => {
+ setup({ landingPageIllustration: "none" });
+
+ expect(screen.getByTestId("home-page")).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("landing-page-illustration"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByTestId("lighthouse-illustration"),
+ ).not.toBeInTheDocument();
+ });
+ });
});
diff --git a/frontend/src/metabase/home/components/LandingPageRedirect/LandingPageRedirect.unit.spec.tsx b/frontend/src/metabase/home/components/LandingPageRedirect/LandingPageRedirect.unit.spec.tsx
index 5b9c7063645..eaa3c9e29df 100644
--- a/frontend/src/metabase/home/components/LandingPageRedirect/LandingPageRedirect.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/LandingPageRedirect/LandingPageRedirect.unit.spec.tsx
@@ -1,6 +1,9 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
import { renderWithProviders, screen, waitFor } from "__support__/ui";
import { PLUGIN_LANDING_PAGE } from "metabase/plugins";
import { Route } from "metabase/router";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
import { LandingPageRedirect } from "./LandingPageRedirect";
@@ -47,4 +50,15 @@ describe("LandingPageRedirect", () => {
await waitFor(() => expect(router?.location.pathname).toBe("/custom"));
});
+
+ it("redirects to the landing-page setting with the whitelabel feature", async () => {
+ mockSettings({
+ "landing-page": "/custom",
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ });
+ setupEnterpriseOnlyPlugin("whitelabel");
+ const { router } = setup();
+
+ await waitFor(() => expect(router?.location.pathname).toBe("/custom"));
+ });
});
diff --git a/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.unit.spec.tsx b/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.unit.spec.tsx
index 14928a17c14..5f3c9dbefcc 100644
--- a/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.unit.spec.tsx
+++ b/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.unit.spec.tsx
@@ -1,5 +1,6 @@
import userEvent from "@testing-library/user-event";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupBugReportingDetailsEndpoint } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import {
@@ -57,6 +58,7 @@ async function setup({
helpLinkCustomDestinationSetting = "https://custom-destination.com/help",
instanceCreationDate = dayjs().toISOString(),
tokenFeatures = {},
+ applicationName,
}: {
isAdmin?: boolean;
isAnalyst?: boolean;
@@ -66,6 +68,7 @@ async function setup({
helpLinkCustomDestinationSetting?: string;
instanceCreationDate?: string;
tokenFeatures?: Partial<TokenFeatures>;
+ applicationName?: string;
} = {}) {
setupBugReportingDetailsEndpoint();
@@ -76,8 +79,17 @@ async function setup({
"help-link-custom-destination": helpLinkCustomDestinationSetting,
"instance-creation": instanceCreationDate,
"token-features": createMockTokenFeatures(tokenFeatures),
+ ...(applicationName && {
+ "application-name": applicationName,
+ // A non-SVG data URI renders without a fetch of the whitelabel logo
+ "application-logo-url": "data:image/png;base64,iVBORw0KGgo=",
+ }),
});
+ if (applicationName) {
+ setupEnterpriseOnlyPlugin("whitelabel");
+ }
+
const admin = createMockAdminState({
app: createMockAdminAppState({
paths: isAdmin ? [adminNavItem] : [],
@@ -389,6 +401,24 @@ describe("ProfileLink", () => {
});
});
});
+
+ it("should use the whitelabel application name in the About menu item and modal", async () => {
+ await setup({
+ applicationName: "New Test Co",
+ tokenFeatures: { whitelabel: true },
+ });
+ await openHelpSubmenu();
+
+ await userEvent.click(
+ screen.getByRole("menuitem", { name: "About New Test Co" }),
+ );
+
+ expect(
+ await screen.findByRole("dialog", {
+ name: "Thanks for using New Test Co!",
+ }),
+ ).toBeInTheDocument();
+ });
});
});
diff --git a/frontend/src/metabase/querying/components/QueryVisualization/QueryVisualization.unit.spec.tsx b/frontend/src/metabase/querying/components/QueryVisualization/QueryVisualization.unit.spec.tsx
new file mode 100644
index 00000000000..3aaf1c7c397
--- /dev/null
+++ b/frontend/src/metabase/querying/components/QueryVisualization/QueryVisualization.unit.spec.tsx
@@ -0,0 +1,57 @@
+import { createMockMetadataFromState } from "__support__/metadata";
+import { createMockState } from "__support__/state";
+import { createMockEntitiesState } from "__support__/store";
+import { renderWithProviders, screen } from "__support__/ui";
+import Question from "metabase-lib/v1/Question";
+import {
+ ORDERS_ID,
+ SAMPLE_DB_ID,
+ createSampleDatabase,
+} from "metabase-types/api/mocks/presets";
+
+import { QueryVisualization } from "./QueryVisualization";
+
+const state = createMockState({
+ entities: createMockEntitiesState({
+ databases: [createSampleDatabase()],
+ }),
+});
+const metadata = createMockMetadataFromState(state);
+
+interface SetupOpts {
+ isRunning: boolean;
+}
+
+const setup = ({ isRunning }: SetupOpts) => {
+ const question = new Question(
+ {
+ dataset_query: {
+ type: "query",
+ query: { "source-table": ORDERS_ID },
+ database: SAMPLE_DB_ID,
+ },
+ display: "table",
+ visualization_settings: {},
+ },
+ metadata,
+ );
+
+ renderWithProviders(
+ <QueryVisualization question={question} isRunning={isRunning} />,
+ { storeInitialState: state },
+ );
+};
+
+describe("QueryVisualization", () => {
+ it("should show the loading message while the query runs", async () => {
+ setup({ isRunning: true });
+
+ expect(await screen.findByText("Doing science...")).toBeInTheDocument();
+ });
+
+ it("should not show the loading message when the query does not run", () => {
+ setup({ isRunning: false });
+
+ expect(screen.queryByText("Doing science...")).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/querying/components/QueryVisualization/VisualizationResult.unit.spec.tsx b/frontend/src/metabase/querying/components/QueryVisualization/VisualizationResult.unit.spec.tsx
index d1ca66d555d..d4411e9b33d 100644
--- a/frontend/src/metabase/querying/components/QueryVisualization/VisualizationResult.unit.spec.tsx
+++ b/frontend/src/metabase/querying/components/QueryVisualization/VisualizationResult.unit.spec.tsx
@@ -160,6 +160,7 @@ describe("VisualizationResult", () => {
});
expect(screen.getByText("No results")).toBeInTheDocument();
+ expect(screen.getByAltText("No results")).toBeInTheDocument();
expect(screen.getByText("Alert prompt")).toBeInTheDocument();
});
diff --git a/frontend/src/metabase/settings-components/AdminSettingInput.unit.spec.tsx b/frontend/src/metabase/settings-components/AdminSettingInput.unit.spec.tsx
index e68ededf9e8..d5fefa3c8bd 100644
--- a/frontend/src/metabase/settings-components/AdminSettingInput.unit.spec.tsx
+++ b/frontend/src/metabase/settings-components/AdminSettingInput.unit.spec.tsx
@@ -12,6 +12,7 @@ import {
renderWithProviders,
screen,
waitFor,
+ within,
} from "__support__/ui";
import { UndoListing } from "metabase/common/components/UndoListing";
import type { SettingKey } from "metabase-types/api";
@@ -46,6 +47,10 @@ const setup = (props: AdminSettingInputProps<SettingKey>) => {
is_env_setting: true,
env_name: "MB_HARDCODED_URL",
}),
+ createMockSettingDefinition({
+ key: "site-name",
+ description: "The name used for this instance of New Test Co.",
+ }),
]);
setupUpdateSettingEndpoint();
@@ -83,6 +88,20 @@ describe("AdminSettingInput", () => {
).toBeInTheDocument();
});
+ it("should fall back to the setting description from the API (metabase#17043)", async () => {
+ setup({
+ title: "Site Name",
+ name: "site-name",
+ inputType: "text",
+ });
+
+ expect(
+ await within(await screen.findByTestId("site-name-setting")).findByText(
+ "The name used for this instance of New Test Co.",
+ ),
+ ).toBeInTheDocument();
+ });
+
it("should render a text input", async () => {
setup({
title: "Site Name",
diff --git a/frontend/src/metabase/visualizations/components/Visualization/Visualization.unit.spec.tsx b/frontend/src/metabase/visualizations/components/Visualization/Visualization.unit.spec.tsx
index e92c78337cd..83bb67fdcae 100644
--- a/frontend/src/metabase/visualizations/components/Visualization/Visualization.unit.spec.tsx
+++ b/frontend/src/metabase/visualizations/components/Visualization/Visualization.unit.spec.tsx
@@ -195,6 +195,26 @@ describe("Visualization", () => {
).toBeInTheDocument();
});
+ it("should render the no results illustration for an empty result on a dashboard", async () => {
+ await renderViz(
+ [
+ {
+ card: createMockCard({ name: "Card", display: "bar" }),
+ data: createMockDatasetData({
+ cols: [
+ createMockCategoryColumn({ name: "Dimension" }),
+ createMockNumericColumn({ name: "Count" }),
+ ],
+ rows: [],
+ }),
+ },
+ ],
+ { isDashboard: true },
+ );
+
+ expect(screen.getByAltText("No results")).toBeInTheDocument();
+ });
+
describe("with a component that loads on demand", () => {
it("should render the chart once its chunk resolves", async () => {
// Registered here rather than at module scope so the shared setup hook,
diff --git a/frontend/src/metabase/visualizations/components/Visualization/VisualizationRunningState.unit.spec.tsx b/frontend/src/metabase/visualizations/components/Visualization/VisualizationRunningState.unit.spec.tsx
index d40b8756c6a..4d4710ffac5 100644
--- a/frontend/src/metabase/visualizations/components/Visualization/VisualizationRunningState.unit.spec.tsx
+++ b/frontend/src/metabase/visualizations/components/Visualization/VisualizationRunningState.unit.spec.tsx
@@ -1,20 +1,37 @@
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import { mockSettings } from "__support__/settings";
import { act, renderWithProviders, screen } from "__support__/ui";
import { PLUGIN_SELECTORS } from "metabase/plugins";
+import type { LoadingMessage } from "metabase-types/api";
+import { createMockTokenFeatures } from "metabase-types/api/mocks";
import { VisualizationRunningState } from "./VisualizationRunningState";
type SetupOpts = {
customMessage?: (isSlow?: boolean) => string;
+ loadingMessage?: LoadingMessage;
};
-function setup({ customMessage }: SetupOpts = {}) {
+function setup({ customMessage, loadingMessage }: SetupOpts = {}) {
if (customMessage) {
jest
.spyOn(PLUGIN_SELECTORS, "getLoadingMessageFactory")
.mockImplementation(() => customMessage);
}
- renderWithProviders(<VisualizationRunningState />);
+ const settings = loadingMessage
+ ? mockSettings({
+ "loading-message": loadingMessage,
+ "token-features": createMockTokenFeatures({ whitelabel: true }),
+ })
+ : undefined;
+ if (loadingMessage) {
+ setupEnterpriseOnlyPlugin("whitelabel");
+ }
+
+ renderWithProviders(<VisualizationRunningState />, {
+ storeInitialState: { settings },
+ });
}
describe("VisualizationRunningState", () => {
@@ -46,4 +63,16 @@ describe("VisualizationRunningState", () => {
await screen.findByText("Custom message (slow)..."),
).toBeInTheDocument();
});
+
+ it.each([
+ { value: "loading-results", message: "Loading results..." },
+ { value: "running-query", message: "Running query..." },
+ { value: "doing-science", message: "Doing science..." },
+ ] as const)(
+ "should render the $value whitelabel loading message",
+ async ({ value, message }) => {
+ setup({ loadingMessage: value });
+ expect(await screen.findByText(message)).toBeInTheDocument();
+ },
+ );
});
diff --git a/frontend/test/__support__/server-mocks/pulse.ts b/frontend/test/__support__/server-mocks/pulse.ts
index a3b11aa0e0d..1c70e806a11 100644
--- a/frontend/test/__support__/server-mocks/pulse.ts
+++ b/frontend/test/__support__/server-mocks/pulse.ts
@@ -5,6 +5,7 @@ import type {
ChannelApiResponse,
DashboardId,
DashboardSubscription,
+ UnsubscribeResponse,
} from "metabase-types/api";
export const setupNotificationChannelsEndpoints = (
@@ -27,3 +28,9 @@ export const setupListSubscriptionsEndpoint = (
export const setupNotificationChannelsEndpointError = () => {
fetchMock.get("path:/api/pulse/form_input", 500);
};
+
+export const setupUnsubscribeFromPulseEndpoint = (
+ response: UnsubscribeResponse,
+) => {
+ fetchMock.post("path:/api/pulse/unsubscribe", response);
+};
diff --git a/frontend/test/__support__/server-mocks/settings.ts b/frontend/test/__support__/server-mocks/settings.ts
index c6076653c8c..fb6d6eacb87 100644
--- a/frontend/test/__support__/server-mocks/settings.ts
+++ b/frontend/test/__support__/server-mocks/settings.ts
@@ -33,11 +33,15 @@ export function setupSettingEndpoint<K extends EnterpriseSettingKey>({
}
export function setupUpdateSettingEndpoint(
- { status }: { status?: number } = { status: 204 },
+ { status, body }: { status?: number; body?: unknown } = { status: 204 },
) {
const name = "update-setting";
fetchMock.removeRoute(name);
- fetchMock.put(new RegExp("/api/setting/"), { status }, { name: name });
+ fetchMock.put(
+ new RegExp("/api/setting/"),
+ body === undefined ? { status } : { status, body },
+ { name: name },
+ );
}
/**