Skip to content

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

25.4 KB
Raw Blame
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
  ORDERS_COUNT_QUESTION_ID,
  ORDERS_DASHBOARD_ID,
  ORDERS_QUESTION_ID,
  THIRD_COLLECTION_ID,
} from "e2e/support/cypress_sample_instance_data";

const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;

const { H } = cy;

const LIMITED_ORDERS_ROW_COUNT = 5;

const clickEmbeddedTableCell = (value: string, rowsCount: number) => {
  // Scoped to the table on purpose: column auto-sizing renders a hidden copy of
  // the cells on the iframe's body and drops it once measured, so a body-wide
  // query can latch onto a copy that is about to detach.
  const tableRoot = () =>
    H.getSimpleEmbedIframeContent().findByTestId("table-root");

  // Anchor on the fully rendered table before interacting with it.
  tableRoot().should("have.attr", "data-rows-count", String(rowsCount));

  tableRoot().findByText(value).should("be.visible").click({ force: true });
};

const LIMITED_ORDERS_QUESTION_DETAILS = {
  name: "Limited Orders",
  query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
};

const LIMITED_ORDERS_DASHBOARD_NAME = "Limited Orders dashboard";

const assertDrillsEnabled = () => {
  clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);

  H.getSimpleEmbedIframeContent()
    .findByText(/Filter by this value/)
    .should("be.visible");

  H.getSimpleEmbedIframeContent()
    .findByTestId("click-actions-filter-section")
    .find("button")
    .first()
    .click();

  H.getSimpleEmbedIframeContent()
    .findByTestId("table-root")
    .findByText("29.8")
    .should("be.visible");
  H.getSimpleEmbedIframeContent().findByText("Save").should("not.exist");
};

const assertDrillsDisabled = () => {
  clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);

  H.getSimpleEmbedIframeContent()
    .findByText(/Filter by this value/)
    .should("not.exist");
};

describe("scenarios > embedding > sdk iframe embedding > custom elements api", () => {
  beforeEach(() => {
    cy.signInAsAdmin();
    H.prepareSdkIframeEmbedTest({
      withToken: "bleeding-edge",
    });
  });

  describe("<metabase-dashboard>", () => {
    it("should embed a dashboard with <metabase-dashboard dashboard-id='${number}'>", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}

      ${H.getNewEmbedConfigurationScript({})}

      <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" />
      `);

      H.getSimpleEmbedIframeContent().should(
        "contain",
        "Orders in a dashboard",
      );
    });

    it("should allow setting initial parameters and hidden parameters via `initial-parameters` and `hidden-parameters` attributes", () => {
      const DASHBOARD_PARAMETERS = [
        { name: "ID", slug: "id", id: "11111111", type: "id" },
        { name: "Product ID", slug: "product_id", id: "22222222", type: "id" },
      ];

      H.createQuestionAndDashboard({
        questionDetails: {
          name: "Orders table",
          query: { "source-table": ORDERS_ID },
        },
        dashboardDetails: {
          name: "Dashboard with Parameters",
          parameters: DASHBOARD_PARAMETERS,
        },
      }).then(({ body: card }) => {
        H.editDashboardCard(card, {
          parameter_mappings: DASHBOARD_PARAMETERS.map((parameter) => ({
            card_id: card.card_id,
            parameter_id: parameter.id,
            target: ["dimension", ["field", ORDERS.ID, null]],
          })),
        }).then(() => {
          const dashboardId = card.dashboard_id;

          H.visitCustomHtmlPage(`
          ${H.getNewEmbedScriptTag()}
          ${H.getNewEmbedConfigurationScript({})}

          <metabase-dashboard dashboard-id="${dashboardId}" initial-parameters='{"id": "123"}' hidden-parameters='["product_id"]' />
          `);

          H.getSimpleEmbedIframeContent()
            .findByTestId("dashboard-parameters-widget-container")
            .within(() => {
              cy.findByLabelText("ID").should("contain", "123");
              cy.findByLabelText("Product ID").should("not.exist");
            });

          // make sure the filter is applied
          H.getSimpleEmbedIframeContent().findByText("1 row").should("exist");
        });
      });
    });

    it("should respect the theme passed to the configuration function", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}

      ${H.getNewEmbedConfigurationScript({
        theme: { colors: { brand: "#123456" } },
      })}

      <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" />
      `);

      H.getSimpleEmbedIframeContent()
        .findByText("User ID")
        // the color is applied via rgb, not via hex
        .should("have.css", "color", "rgb(18, 52, 86)");
    });

    (
      [
        {
          attributes: "with-title drills",
          withTitle: true,
          drills: true,
          withDownloads: false,
        },
        {
          attributes: 'with-title="false" drills="false" with-downloads',
          withTitle: false,
          drills: false,
          withDownloads: true,
        },
        {
          attributes: 'with-title="true" drills="true" with-downloads',
          withTitle: true,
          drills: true,
          withDownloads: true,
        },
      ] as const
    ).forEach(({ attributes, withTitle, drills, withDownloads }) => {
      it(`should apply \`${attributes}\``, () => {
        H.createQuestionAndDashboard({
          questionDetails: LIMITED_ORDERS_QUESTION_DETAILS,
          dashboardDetails: { name: LIMITED_ORDERS_DASHBOARD_NAME },
        }).then(({ body: { dashboard_id } }) => {
          H.visitCustomHtmlPage(`
          ${H.getNewEmbedScriptTag()}
          ${H.getNewEmbedConfigurationScript()}
          <metabase-dashboard dashboard-id="${dashboard_id}" ${attributes} />
          `);

          cy.wait("@getDashCardQuery");

          H.getSimpleEmbedIframeContent()
            .findByText(LIMITED_ORDERS_QUESTION_DETAILS.name)
            .should("be.visible");
          H.getSimpleEmbedIframeContent()
            .findByText(LIMITED_ORDERS_DASHBOARD_NAME)
            .should(withTitle ? "be.visible" : "not.exist");
          H.getSimpleEmbedIframeContent()
            .findByLabelText("Download as PDF")
            .should(withDownloads ? "be.visible" : "not.exist");

          if (drills) {
            assertDrillsEnabled();
          } else {
            assertDrillsDisabled();
          }
        });
      });
    });
  });

  describe("<metabase-question>", () => {
    it("should embed a question with <metabase-question question-id='${number}'> and remove a column via viz settings (metabase#77135)", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}

      ${H.getNewEmbedConfigurationScript()}

      <metabase-question question-id="${ORDERS_QUESTION_ID}" />
      `);

      H.getSimpleEmbedIframeContent(0).findByText("Orders").should("exist");

      cy.log("remove a column via viz settings (metabase#77135)");
      H.getSimpleEmbedIframeContent().within(() => {
        H.tableInteractive().findByText("Tax").should("be.visible");

        cy.findByTestId("viz-settings-button").click();
        cy.findByRole("button", { name: /Add or remove columns/ }).click();

        cy.findByLabelText("Tax").should("be.checked").click();
        H.tableInteractive().findByText("Tax").should("not.exist");
      });
    });

    it("should allow rendering two different questions in the same page", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}

      <div style="display: flex; flex-direction: row; gap: 10px;">
        <div>
          <p>Question ${ORDERS_QUESTION_ID}</p>
          <metabase-question question-id="${ORDERS_QUESTION_ID}" />
        </div>
        <div>
          <p>Question ${ORDERS_COUNT_QUESTION_ID}</p>
          <metabase-question question-id="${ORDERS_COUNT_QUESTION_ID}" />
        </div>
      </div>
      `);

      H.waitForSimpleEmbedIframesToLoad(2);

      H.getSimpleEmbedIframeContent(0)
        .findByText("Orders")
        .should("exist", { timeout: 10000 });
      H.getSimpleEmbedIframeContent(1)
        .findByText("Orders, Count")
        .should("exist", { timeout: 10000 });
    });

    (
      [
        {
          attributes: "with-title drills with-downloads",
          withTitle: true,
          drills: true,
          withDownloads: true,
        },
        {
          attributes: 'with-title="true" drills="false"',
          withTitle: true,
          drills: false,
          withDownloads: undefined,
        },
        {
          attributes: 'with-title="false" drills="true" with-downloads="false"',
          withTitle: false,
          drills: true,
          withDownloads: false,
        },
      ] as const
    ).forEach(({ attributes, withTitle, drills, withDownloads }) => {
      it(`should apply \`${attributes}\``, () => {
        H.createQuestion(LIMITED_ORDERS_QUESTION_DETAILS).then(
          ({ body: { id: questionId } }) => {
            H.visitCustomHtmlPage(`
            ${H.getNewEmbedScriptTag()}
            ${H.getNewEmbedConfigurationScript()}
            <metabase-question question-id="${questionId}" ${attributes} />
            `);

            cy.wait("@getCardQuery");

            H.getSimpleEmbedIframeContent()
              .findByTestId("table-root")
              .should(
                "have.attr",
                "data-rows-count",
                String(LIMITED_ORDERS_ROW_COUNT),
              );
            H.getSimpleEmbedIframeContent()
              .findByText(LIMITED_ORDERS_QUESTION_DETAILS.name)
              .should(withTitle ? "be.visible" : "not.exist");

            if (drills) {
              H.getSimpleEmbedIframeContent()
                .findByTestId("interactive-question-result-toolbar")
                .should("be.visible")
                .findByLabelText("download icon")
                .should(withDownloads ? "be.visible" : "not.exist");
            } else {
              H.getSimpleEmbedIframeContent()
                .findByTestId("interactive-question-result-toolbar")
                .should("not.exist");
            }

            if (drills) {
              assertDrillsEnabled();
            } else {
              assertDrillsDisabled();
            }
          },
        );
      });
    });

    it("should allow saving a question when `is-save-enabled` is true", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-question question-id="new" is-save-enabled />
      `);

      H.getSimpleEmbedIframeContent().within(() => {
        H.popover().findByText("Orders Model").should("be.visible");
      });
      H.getSimpleEmbedIframeContent().findByText("Orders").click();
      H.getSimpleEmbedIframeContent().findByText("Save").should("be.visible");
    });

    it("should not allow saving a question when `is-save-enabled` is false", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-question question-id="new" is-save-enabled="false" />
      `);

      H.getSimpleEmbedIframeContent().findByText("Orders").click();
      H.getSimpleEmbedIframeContent().findByText("Save").should("not.exist");
    });

    it("should set initial sql parameters with `initial-sql-parameters`", () => {
      H.createNativeQuestion({
        name: "SQL question with parameter",
        native: {
          query: "select * from orders where id = {{id}}",
          "template-tags": {
            id: {
              id: "6b8b10ef-0104-1047-1e5v-2701dfc64356",
              name: "id",
              "display-name": "ID",
              type: "number",
              required: true,
            },
          },
        },
      }).then(({ body: { id: questionId } }) => {
        H.visitCustomHtmlPage(`
        ${H.getNewEmbedScriptTag()}
        ${H.getNewEmbedConfigurationScript()}
        <metabase-question question-id="${questionId}" initial-sql-parameters='{"id": 123}' />
        `);

        H.getSimpleEmbedIframeContent()
          .findByTestId("query-visualization-root")
          .findByText("123")
          .should("be.visible");
      });
    });

    it("should save a new question to a target collection when `target-collection` is set", () => {
      cy.log("Create a new collection to save the question to");

      H.visitCustomHtmlPage(`
          ${H.getNewEmbedScriptTag()}
          ${H.getNewEmbedConfigurationScript()}
          <metabase-question question-id="new" drills="false" is-save-enabled target-collection="${THIRD_COLLECTION_ID}" />
        `);

      cy.intercept("POST", "/api/card").as("createCard");

      cy.log("Create a new question and save it");
      H.getSimpleEmbedIframeContent().within(() => {
        cy.findByText("Orders").click();
        cy.findByText("Save").click();

        cy.findByRole("dialog").within(() => {
          cy.findByText("Where do you want to save this?").should("not.exist");

          cy.findByRole("button", { name: "Save" }).click();
        });

        cy.wait("@createCard").then(({ response }) => {
          expect(response?.body.collection_id).to.equal(THIRD_COLLECTION_ID);
        });
      });
    });
  });

  describe("<metabase-metabot>", () => {
    beforeEach(() => {
      H.setupAnthropicLlmProvider();
    });

    it("should handle scrolling gracefully (metabase#67399)", () => {
      const question = `
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      `;

      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-metabot />
      `);

      H.getSimpleEmbedIframeContent().within(() => {
        cy.log("metabot chat should be interactive");
        cy.findByText("Ask questions to AI.").should("be.visible");

        cy.findByPlaceholderText("Ask AI a question...")
          .paste(question)
          .type("{enter}");

        // Making sure the ChatInput is still within the viewport
        cy.findByPlaceholderText("Ask AI a question...").should("be.visible");
      });
    });

    it("should load the embedded Metabot component", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-metabot />
      `);

      H.getSimpleEmbedIframeContent().within(() => {
        cy.log("metabot chat should be interactive");
        cy.findByText("Ask questions to AI.").should("be.visible");
        cy.findByPlaceholderText("Ask AI a question...").type("Foo{enter}");
        cy.findByText(/Something went wrong/).should("be.visible");

        cy.log(
          "uses sidebar layout by default when no layout attribute is provided",
        );
        cy.findByTestId("metabot-question-container").should(
          "have.attr",
          "data-layout",
          "sidebar",
        );

        cy.log("should show disclaimer text in sidebar layout");
        cy.findAllByText("AI isn't perfect. Double-check results.").should(
          "be.visible",
        );
      });
    });

    it("should apply the data-layout attribute when layout is set to stacked", () => {
      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-metabot layout="stacked" />
      `);

      H.getSimpleEmbedIframeContent()
        .findByTestId("metabot-question-container")
        .should("have.attr", "data-layout", "stacked");

      cy.log("should show disclaimer text in stacked layout");
      H.getSimpleEmbedIframeContent()
        .findAllByText("AI isn't perfect. Double-check results.")
        .should("be.visible");
    });

    describe("saving a metabot question", () => {
      const query = {
        "source-table": ORDERS_ID,
        aggregation: [["max", ["field", ORDERS.QUANTITY, null]]],
        breakout: [["field", ORDERS.PRODUCT_ID, null]],
        limit: 2,
      };
      const adHocQuestionPath = `/question#${btoa(
        JSON.stringify({
          dataset_query: { database: 1, type: "query", query },
          display: "table",
          displayIsLocked: true,
          visualization_settings: {},
        }),
      )}`;

      const metabotResponse = H.createMetabotSSEBody(
        H.metabotTextPart(`Here is the [question link](${adHocQuestionPath})`),
      );

      it("should allow to save a new question", () => {
        H.mockMetabotResponse({
          statusCode: 200,
          body: metabotResponse,
        });

        cy.intercept("POST", "http://localhost:4000/api/card").as("postCard");

        cy.log("Create a collection");
        cy.request("POST", "/api/collection", {
          name: "first_collection",
          description: "First collection",
          parent_id: undefined,
        }).then(({ body }) => {
          cy.log("Visit an embed metabase-metabot");
          H.visitCustomHtmlPage(`
            ${H.getNewEmbedScriptTag()}
            ${H.getNewEmbedConfigurationScript()}
            <metabase-metabot is-save-enabled="true" target-collection="${body.id}" />
          `);

          H.getSimpleEmbedIframeContent().within(() => {
            cy.log("Ask a Metabot to create a question");
            // the question doesn't matter, we're stubbing the response
            cy.findByPlaceholderText("Ask AI a question...").type(
              "Show me something{enter}",
            );

            cy.findByText("question link").click();

            cy.findByText("Max of Quantity by Product ID").should("be.visible");

            cy.log("Save the question");
            cy.findByRole("button", { name: "Save" })
              .should("be.visible")
              .click();

            H.modal().within(() => {
              cy.findByText("Save new question").should("be.visible");
              cy.findByRole("button", { name: "Save" }).click();
            });
          });

          cy.wait("@postCard").then((interception) => {
            const response = interception.response?.body;
            const questionId = response.id;

            cy.log("Open the question");
            cy.signInAsAdmin();
            H.visitQuestion(questionId)?.then(() => {
              // Name of the collection should be visible at the top of the page
              // findAllBy because there are two "first_collection", one in the sidebar and one at the top
              cy.findAllByText("first_collection").first().should("be.visible");
              // Name of the new question should be visible too
              cy.findByText(
                "Orders, Max of Quantity, Grouped by Product ID, 2 rows",
              ).should("be.visible");
            });
          });
        });
      });
    });

    it("should not render metabot when embedded-metabot-enabled? is false", () => {
      H.updateSetting("embedded-metabot-enabled?", false);

      H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-metabot />
      `);

      H.getSimpleEmbedIframeContent().within(() => {
        // When embedded metabot is disabled, the component should not render the chat interface
        cy.findByText("Ask questions to AI.").should("not.exist");
        cy.findByPlaceholderText("Ask AI a question...").should("not.exist");
      });
    });
  });

  describe("common checks", () => {
    describe("should be permissive with json attributes", () => {
      // NOTE: pay attention if you use initialFilters for these tests, as when the filters are not parsed correctly
      // we default them to the latest filters used by that user
      it("should support normal json with strings wrapped in double quotes", () => {
        H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-question question-id="new" entity-types='["table"]' />
      `);

        H.getSimpleEmbedIframeContent().within(() => {
          H.popover().findByText("Orders").should("be.visible");
          H.popover().findByText("Orders Model").should("not.exist");
        });
      });

      it("should support json5 with strings wrapped in single quotes", () => {
        H.visitCustomHtmlPage(`
      ${H.getNewEmbedScriptTag()}
      ${H.getNewEmbedConfigurationScript()}
      <metabase-question question-id="new" entity-types="['table']" />
      `);

        H.getSimpleEmbedIframeContent().within(() => {
          H.popover().findByText("Orders").should("be.visible");
          H.popover().findByText("Orders Model").should("not.exist");
        });
      });
    });

    it("should not define color-scheme meta tag on embeds (metabase#65533)", () => {
      H.visitCustomHtmlPage(`
        ${H.getNewEmbedScriptTag()}
        ${H.getNewEmbedConfigurationScript()}
        <metabase-question question-id="new" />
      `);

      H.waitForSimpleEmbedIframesToLoad();

      cy.get("iframe[data-metabase-embed]")
        .its("0.contentDocument")
        .within(() => {
          cy.log("a generic meta tag should exist");
          cy.get("meta[name='viewport']").should("exist");

          cy.log("the color-scheme tag should not exist on EAJS embeds");
          cy.get("meta[name='color-scheme']").should("not.exist");
        });
    });
  });

  describe("sync vs async vs defer script loading", () => {
    (
      [
        {
          loadType: "sync",
        },
        {
          loadType: "async",
        },
        {
          loadType: "defer",
        },
      ] as const
    ).forEach(({ loadType }) => {
      it(`should work correctly when the script is loaded ${loadType}`, () => {
        H.visitCustomHtmlPage(`
          ${H.getNewEmbedScriptTag({ loadType })}
          ${H.getNewEmbedConfigurationScript({
            theme: { colors: { brand: "#FF0000" } },
          })}
          <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" />

          <button onclick="defineMetabaseConfig({ theme: { colors: { brand: '#00FF00' } } })">Change theme</button>
        `);

        cy.log("Check if the dashboard is loaded");
        H.getSimpleEmbedIframeContent().should(
          "contain",
          "Orders in a dashboard",
        );

        cy.log("Check that the initial theme is applied");

        H.getSimpleEmbedIframeContent()
          .findByText("User ID")
          .should("have.css", "color", "rgb(255, 0, 0)");

        cy.log(
          "Check that calling defineMetabaseConfig after the initial load works",
        );
        // eslint-disable-next-line metabase/no-unscoped-text-selectors -- this is not the real app
        cy.findByText("Change theme").click();

        H.getSimpleEmbedIframeContent()
          .findByText("User ID")
          .should("have.css", "color", "rgb(0, 255, 0)");
      });
    });
  });
});