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
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { createQuestion, getSignedJwtForResource } from "e2e/support/helpers";
const { H } = cy;
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
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 an error for a component without guest embed support, and shows and downloads a static question",
{ tags: "@prerelease" },
() => {
cy.log("component without guest embed support shows an error");
H.loadSdkIframeEmbedTestPage({
metabaseConfig: { isGuest: true },
elements: [
{
component: "metabase-browser",
attributes: {},
},
],
}).within(() => {
cy.findByText("This component does not support guest embeds").should(
"be.visible",
);
});
cy.log("static question shows and downloads 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(() => {
cy.findByText("Product ID").should("be.visible");
cy.findByText("Max of Quantity").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",
});
});
});
},
);
}
describe(
"scenarios > embedding > sdk iframe embedding > guest-embed > ee",
guestEmbedSuite,
);
describe(
"scenarios > embedding > sdk iframe embedding > guest-embed > oss",
{ tags: "@OSS" },
guestEmbedSuite,
);