Skip to content

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

Split guest-embed.cy.spec.ts into describe blocks for OSS and EE (#78830)

Timofey Kachalovb909e55cdbb8
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/guest-embed.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/guest-embed.cy.spec.ts
index f93bd369f07..a2c83f8cd7b 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/guest-embed.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/guest-embed.cy.spec.ts
@@ -4,117 +4,120 @@ import { createQuestion, getSignedJwtForResource } from "e2e/support/helpers";
const { H } = cy;
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
-const IS_ENTERPRISE = Cypress.expose("IS_ENTERPRISE");
-const IS_OSS = !IS_ENTERPRISE;
-const MB_EDITION = IS_ENTERPRISE ? "ee" : "oss";
-
-describe(
- `scenarios > embedding > sdk iframe embedding > guest-embed > ${MB_EDITION}`,
- { ...(IS_OSS && { tags: "@OSS" }) },
- () => {
- beforeEach(() => {
- H.prepareGuestEmbedSdkIframeEmbedTest({
- onPrepare: () => {
- createQuestion({
- name: "47563",
- enable_embedding: true,
- embedding_type: "guest-embed",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["max", ["field", ORDERS.QUANTITY, null]]],
- breakout: [["field", ORDERS.PRODUCT_ID, null]],
- limit: 2,
- },
- }).then(({ body: question }) => {
- cy.wrap(question.id).as("questionId");
- });
- },
- });
+function guestEmbedSuite() {
+ beforeEach(() => {
+ H.prepareGuestEmbedSdkIframeEmbedTest({
+ onPrepare: () => {
+ createQuestion({
+ name: "47563",
+ enable_embedding: true,
+ embedding_type: "guest-embed",
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["max", ["field", ORDERS.QUANTITY, null]]],
+ breakout: [["field", ORDERS.PRODUCT_ID, null]],
+ limit: 2,
+ },
+ }).then(({ body: question }) => {
+ cy.wrap(question.id).as("questionId");
+ });
+ },
});
+ });
- it("shows a static question", () => {
- cy.get("@questionId").then(async (questionId) => {
- const token = await getSignedJwtForResource({
- // Unjustified type cast. FIXME
- resourceId: questionId as unknown as number,
- resourceType: "question",
- });
+ it("shows a static question", () => {
+ cy.get("@questionId").then(async (questionId) => {
+ const token = await getSignedJwtForResource({
+ // Unjustified type cast. FIXME
+ resourceId: questionId as unknown as number,
+ resourceType: "question",
+ });
- const frame = H.loadSdkIframeEmbedTestPage({
- metabaseConfig: { isGuest: true },
- elements: [
- {
- component: "metabase-question",
- attributes: {
- token,
- },
+ const frame = H.loadSdkIframeEmbedTestPage({
+ metabaseConfig: { isGuest: true },
+ elements: [
+ {
+ component: "metabase-question",
+ attributes: {
+ token,
},
- ],
- });
+ },
+ ],
+ });
- cy.wait("@getCardQuery");
+ cy.wait("@getCardQuery");
- frame.within(() => {
- cy.findByText("Product ID").should("be.visible");
- cy.findByText("Max of Quantity").should("be.visible");
- });
+ frame.within(() => {
+ cy.findByText("Product ID").should("be.visible");
+ cy.findByText("Max of Quantity").should("be.visible");
});
});
+ });
- it("allows to download a static question as CSV", () => {
- cy.get("@questionId").then(async (questionId) => {
- const token = await getSignedJwtForResource({
- // Unjustified type cast. FIXME
- resourceId: questionId as unknown as number,
- resourceType: "question",
- });
-
- const frame = H.loadSdkIframeEmbedTestPage({
- metabaseConfig: { isGuest: true },
- elements: [
- {
- component: "metabase-question",
- attributes: {
- token,
- "with-downloads": true,
- },
- },
- ],
- });
-
- cy.wait("@getCardQuery");
-
- frame.within(() => {
- H.downloadAndAssert({
- isDashboard: false,
- isEmbed: true,
- enableFormatting: true,
- assertStatusCode: 200,
- waitForDismiss: false,
- fileType: "csv",
- downloadUrl: "/api/embed/card/*/query/csv*",
- downloadMethod: "GET",
- });
- });
+ it("allows to download a static question as CSV", () => {
+ cy.get("@questionId").then(async (questionId) => {
+ const token = await getSignedJwtForResource({
+ // Unjustified type cast. FIXME
+ resourceId: questionId as unknown as number,
+ resourceType: "question",
});
- });
- it("shows an error for a component without guest embed support", () => {
const frame = H.loadSdkIframeEmbedTestPage({
metabaseConfig: { isGuest: true },
elements: [
{
- component: "metabase-browser",
- attributes: {},
+ component: "metabase-question",
+ attributes: {
+ token,
+ "with-downloads": true,
+ },
},
],
});
+ cy.wait("@getCardQuery");
+
frame.within(() => {
- cy.findByText("This component does not support guest embeds").should(
- "be.visible",
- );
+ H.downloadAndAssert({
+ isDashboard: false,
+ isEmbed: true,
+ enableFormatting: true,
+ assertStatusCode: 200,
+ waitForDismiss: false,
+ fileType: "csv",
+ downloadUrl: "/api/embed/card/*/query/csv*",
+ downloadMethod: "GET",
+ });
});
});
- },
+ });
+
+ it("shows an error for a component without guest embed support", () => {
+ const frame = H.loadSdkIframeEmbedTestPage({
+ metabaseConfig: { isGuest: true },
+ elements: [
+ {
+ component: "metabase-browser",
+ attributes: {},
+ },
+ ],
+ });
+
+ frame.within(() => {
+ cy.findByText("This component does not support guest embeds").should(
+ "be.visible",
+ );
+ });
+ });
+}
+
+describe(
+ "scenarios > embedding > sdk iframe embedding > guest-embed > ee",
+ guestEmbedSuite,
+);
+
+describe(
+ "scenarios > embedding > sdk iframe embedding > guest-embed > oss",
+ { tags: "@OSS" },
+ guestEmbedSuite,
);