Skip to content

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

Remove skipped Metabase Cloud e2e tests (#63417)

Frasereeab38518ac2
diff --git a/e2e/test/scenarios/admin-2/settings.cy.spec.js b/e2e/test/scenarios/admin-2/settings.cy.spec.js
index b0270b744ed..7fb62b356d8 100644
--- a/e2e/test/scenarios/admin-2/settings.cy.spec.js
+++ b/e2e/test/scenarios/admin-2/settings.cy.spec.js
@@ -267,40 +267,6 @@ H.describeWithSnowplow("scenarios > admin > settings", () => {
cy.findByText(/Site URL/i);
});
- // Unskip when mocking Cloud in Cypress is fixed (#18289)
- it(
- "should hide self-hosted settings when running Metabase Cloud",
- { tags: "@skip" },
- () => {
- H.setupMetabaseCloud();
- cy.visit("/admin/settings/general");
-
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Site Name");
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Site URL").should("not.exist");
-
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Email").should("not.exist");
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Updates").should("not.exist");
- },
- );
-
- // Unskip when mocking Cloud in Cypress is fixed (#18289)
- it(
- "should hide the store link when running Metabase Cloud",
- { tags: "@skip" },
- () => {
- H.setupMetabaseCloud();
- cy.visit("/admin/settings/general");
-
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Metabase Admin");
- cy.findByLabelText("store icon").should("not.exist");
- },
- );
-
describe(" > slack settings", () => {
it("should present the form and display errors", () => {
cy.visit("/admin/settings/notifications");
@@ -338,21 +304,6 @@ describe("scenarios > admin > settings (EE)", () => {
H.activateToken("pro-self-hosted");
});
- // Unskip when mocking Cloud in Cypress is fixed (#18289)
- it(
- "should hide Enterprise page when running Metabase Cloud",
- { tags: "@skip" },
- () => {
- H.setupMetabaseCloud();
- cy.visit("/admin/settings/general");
-
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Site Name");
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Enterprise").should("not.exist");
- },
- );
-
it("should hide the store link when running Metabase EE", () => {
cy.visit("/admin/settings/license");
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 0d04079b65c..dd807fff9db 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,18 +3,37 @@ import { Route } from "react-router";
import { setupSettingEndpoint } from "__support__/server-mocks";
import { renderWithProviders, screen } from "__support__/ui";
-import { createMockVersionInfo } from "metabase-types/api/mocks";
+import {
+ createMockSettings,
+ createMockTokenFeatures,
+ createMockVersionInfo,
+} from "metabase-types/api/mocks";
import {
createMockLocation,
createMockRoutingState,
+ createMockSettingsState,
} from "metabase-types/store/mocks";
import { SettingsNav } from "./SettingsNav";
-const setup = async ({ initialRoute }: { initialRoute: string }) => {
+const setup = async ({
+ initialRoute,
+ isHosted,
+}: {
+ initialRoute: string;
+ isHosted?: boolean;
+}) => {
+ const versionInfo = createMockVersionInfo();
+ const settings = createMockSettings({
+ "version-info": versionInfo,
+ "token-features": createMockTokenFeatures({
+ hosting: Boolean(isHosted),
+ }),
+ });
+
setupSettingEndpoint({
settingKey: "version-info",
- settingValue: createMockVersionInfo(),
+ settingValue: versionInfo,
});
renderWithProviders(<Route path="*" component={SettingsNav} />, {
@@ -26,6 +45,7 @@ const setup = async ({ initialRoute }: { initialRoute: string }) => {
pathname: initialRoute,
}),
}),
+ settings: createMockSettingsState(settings),
},
});
};
@@ -98,4 +118,9 @@ describe("SettingsNav", () => {
expect(authNavItem).not.toHaveAttribute("data-expanded");
expect(authNavItem).toHaveAttribute("data-active", "true");
});
+
+ it("should only show Updates nav item when hosted", async () => {
+ await setup({ initialRoute: "/admin/settings/general", isHosted: true });
+ expect(screen.queryByText("Updates")).not.toBeInTheDocument();
+ });
});
diff --git a/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
index 8318f26b060..5d4f334adef 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
@@ -8,43 +8,55 @@ import {
} from "__support__/server-mocks";
import { fireEvent, renderWithProviders, screen } from "__support__/ui";
import { UndoListing } from "metabase/common/components/UndoListing";
+import type { SettingKey } from "metabase-types/api";
import {
createMockSettingDefinition,
createMockSettings,
+ createMockTokenFeatures,
} from "metabase-types/api/mocks";
+import { createMockSettingsState } from "metabase-types/store/mocks";
import { SiteUrlWidget } from "./SiteUrlWidget";
-const setup = () => {
- setupPropertiesEndpoints(
- createMockSettings({
- "site-url": "http://mysite.biz",
+const setup = (props: { isHosted?: boolean }) => {
+ const siteUrlWidgetSettings = {
+ "site-url": "http://mysite.biz",
+ "token-features": createMockTokenFeatures({
+ hosting: Boolean(props.isHosted),
}),
- );
+ } as const;
+
+ const settings = createMockSettings(siteUrlWidgetSettings);
+
+ setupPropertiesEndpoints(settings);
setupUpdateSettingEndpoint();
- setupSettingsEndpoints([
- createMockSettingDefinition({
- key: "site-url",
- value: "http://mysite.biz",
- }),
- ]);
+ setupSettingsEndpoints(
+ Object.entries(settings).map(([key, value]) =>
+ createMockSettingDefinition({ key: key as SettingKey, value }),
+ ),
+ );
return renderWithProviders(
<div>
<SiteUrlWidget />
<UndoListing />
</div>,
+ {
+ storeInitialState: {
+ settings: createMockSettingsState(settings),
+ },
+ },
);
};
describe("siteUrlWidget", () => {
it("should render a SiteUrlWidget", async () => {
- setup();
+ setup({});
expect(await screen.findByText("Site url")).toBeInTheDocument();
});
it("should load existing value", async () => {
- setup();
+ setup({});
const selectInput = await screen.findByRole("textbox", {
name: "input-prefix",
});
@@ -55,7 +67,7 @@ describe("siteUrlWidget", () => {
});
it("should update the value", async () => {
- setup();
+ setup({});
const input = await screen.findByDisplayValue("mysite.biz");
await userEvent.clear(input);
await userEvent.type(input, "newsite.guru");
@@ -68,7 +80,7 @@ describe("siteUrlWidget", () => {
});
it("can change from http to https", async () => {
- setup();
+ setup({});
await userEvent.click(
await screen.findByRole("textbox", { name: "input-prefix" }),
);
@@ -80,7 +92,7 @@ describe("siteUrlWidget", () => {
});
it("should show success toast", async () => {
- setup();
+ setup({});
const input = await screen.findByDisplayValue("mysite.biz");
await userEvent.clear(input);
await userEvent.type(input, "newsite.guru");
@@ -94,7 +106,7 @@ describe("siteUrlWidget", () => {
});
it("should show error message", async () => {
- setup();
+ setup({});
setupUpdateSettingEndpoint({ status: 500 });
const input = await screen.findByDisplayValue("mysite.biz");
@@ -107,4 +119,9 @@ describe("siteUrlWidget", () => {
await screen.findByText("Error saving Site URL"),
).toBeInTheDocument();
});
+
+ it("should not render if it's hosted", async () => {
+ setup({ isHosted: true });
+ expect(screen.queryByText("Site url")).not.toBeInTheDocument();
+ });
});