The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Don't call trial check EE endpoint in OSS for Remote Sync upsell (#70349)
Anderson2b61cce77bde
diff --git a/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.tsx b/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.tsxindex 40c3b121b70..04c33235988 100644--- a/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.tsx+++ b/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.tsx@@ -43,7 +43,10 @@ export const UpsellCardContent = ({upgradeUrl,variant = "image-card",}: UpsellCardContentProps) => {- const { data: trialData } = useCheckTrialAvailableQuery();+ const isHosted = useSelector(getIsHosted);+ const { data: trialData } = useCheckTrialAvailableQuery(undefined, {+ skip: !isHosted,+ });const isTrialAvailable = trialData?.available ?? false;const leftSideSize = rem(280);@@ -121,8 +124,8 @@ type UpsellCardLeftColumnContentProps = {title: string;description: string;bulletPoints?: string[];- upgradeOnClick: (() => void) | undefined;- upgradeUrl: string | undefined;+ upgradeOnClick?: () => void;+ upgradeUrl?: string;};const UpsellCardLeftColumnContent = ({diff --git a/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.unit.spec.tsx b/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.unit.spec.tsxnew file mode 100644index 00000000000..ddbfb6c1e1a--- /dev/null+++ b/frontend/src/metabase/data-studio/upsells/components/UpsellCardContent.unit.spec.tsx@@ -0,0 +1,65 @@+import fetchMock from "fetch-mock";++import { setupTrialAvailableEndpoint } from "__support__/server-mocks";+import { mockSettings } from "__support__/settings";+import { renderWithProviders, screen } from "__support__/ui";+import { createMockUser } from "metabase-types/api/mocks";+import { createMockState } from "metabase-types/store/mocks";++import type { UpsellCardContentProps } from "./UpsellCardContent";+import { UpsellCardContent } from "./UpsellCardContent";++const defaultProps: UpsellCardContentProps = {+ campaign: "test-campaign",+ location: "test-location",+ title: "Test Title",+ description: "Test description",+};++interface SetupOpts {+ isHosted: boolean;+}++function setup({ isHosted }: SetupOpts) {+ setupTrialAvailableEndpoint({+ available: true,+ plan_alias: "pro-cloud",+ });++ renderWithProviders(<UpsellCardContent {...defaultProps} />, {+ storeInitialState: createMockState({+ currentUser: createMockUser({ is_superuser: true }),+ settings: mockSettings({+ "is-hosted?": isHosted,+ }),+ }),+ });+}++describe("UpsellCardContent", () => {+ describe("trial availability check", () => {+ it("should call trial availability endpoint when isHosted is true", async () => {+ setup({ isHosted: true });++ await screen.findByText("Test Title");++ expect(+ fetchMock.callHistory.called(+ "path:/api/ee/cloud-proxy/mb-plan-trial-up-available",+ ),+ ).toBe(true);+ });++ it("should not call trial availability endpoint when isHosted is false", async () => {+ setup({ isHosted: false });++ await screen.findByText("Test Title");++ expect(+ fetchMock.callHistory.called(+ "path:/api/ee/cloud-proxy/mb-plan-trial-up-available",+ ),+ ).toBe(false);+ });+ });+});