Skip to content

Commit

Permalink
Migrate dashcards
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskaber committed Mar 13, 2024
1 parent d83de59 commit 5faffa8
Show file tree
Hide file tree
Showing 61 changed files with 319 additions and 183 deletions.
4 changes: 2 additions & 2 deletions e2e/support/helpers/e2e-dashboard-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export function disconnectDashboardFilter(selection) {
}

export function getDashboardCards() {
return cy.get(".DashCard");
return cy.findAllByTestId("dashcard-container");
}

export function getDashboardCard(index = 0) {
return getDashboardCards().eq(index);
}

export function ensureDashboardCardHasText(text, index = 0) {
cy.get(".Card").eq(index).should("contain", text);
cy.findAllByTestId("dashcard").eq(index).should("contain", text);
}

function getDashboardApiUrl(dashId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe("metabase#31587", () => {
const actionButtonContainer = cy.findByTestId(
"action-button-full-container",
);
const dashCard = cy.contains(".DashCard", "Click Me");
const dashCard = cy
.findAllByTestId("dashcard-container")
.last()
.should("have.text", "Click Me");

actionButtonContainer.then(actionButtonElem => {
dashCard.then(dashCardElem => {
Expand All @@ -55,7 +58,10 @@ describe("metabase#31587", () => {
const actionButtonContainer = cy.findByTestId(
"action-button-full-container",
);
const dashCard = cy.contains(".DashCard", "Click Me");
const dashCard = cy
.findAllByTestId("dashcard-container")
.last()
.should("have.text", "Click Me");

actionButtonContainer.then(actionButtonElem => {
dashCard.then(dashCardElem => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function addNumberParameterToDashboard() {
}

function mapParameterToCustomColumn() {
cy.get(".DashCard").contains("Select…").click();
cy.findByTestId("dashcard-container").contains("Select…").click();
popover().contains("Quantity_2").click({ force: true });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe.skip("issue 19744", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("All Options").click();

cy.get(".DashCard").contains("Select…").click();
cy.findByTestId("dashcard-container").contains("Select…").click();
popover().contains("Created At");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ describe("scenarios > dashboard card resizing", () => {
cy.request("GET", `/api/dashboard/${dashId}`).then(({ body }) => {
const dashcards = body.dashcards;
dashcards.forEach(({ card }) => {
const dashcard = cy.contains(".DashCard", card.name);
const dashcard = cy.contains(
"[data-testid='dashcard-container']",
card.name,
);
resizeDashboardCard({
card: dashcard,
x: getDefaultSize(card.display).width * 100,
Expand All @@ -292,7 +295,10 @@ describe("scenarios > dashboard card resizing", () => {
editDashboard();

dashcards.forEach(({ card }) => {
const dashcard = cy.contains(".DashCard", card.name);
const dashcard = cy.contains(
"[data-testid='dashcard-container']",
card.name,
);
dashcard.within(() => {
resizeDashboardCard({
card: dashcard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ describe("scenarios > dashboard > dashboard drill", () => {
cy.button("Save").click();
cy.findByText("You're editing this dashboard.").should("not.exist");
cy.log("Reported failing on v0.38.0 - link gets dropped");
cy.get(".DashCard").findAllByText(LINK_NAME);
cy.findByTestId("dashcard-container").findAllByText(LINK_NAME);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe("issue 18454", () => {
});

it("should show card descriptions (metabase#18454)", () => {
cy.get(".DashCard").realHover();
cy.get(".DashCard").within(() => {
cy.findByTestId("dashcard-container").realHover();
cy.findByTestId("dashcard-container").within(() => {
cy.icon("info").trigger("mouseenter", { force: true });
});
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ describe("support > permissions (metabase#8472)", () => {
popover().contains("Is").click();

// Filter the first card by User Address
selectDashboardFilter(cy.get(".DashCard").first(), "Address");
selectDashboardFilter(
cy.findByTestId("dashcard-container").first(),
"Address",
);

// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("Done").click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("scenarios > dashboard > filters > date", () => {
});

cy.log(`Make sure ${filter} filter returns correct result`);
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText(representativeResult);
});

Expand Down Expand Up @@ -88,7 +88,7 @@ describe("scenarios > dashboard > filters > date", () => {
saveDashboard();

// The default value should immediately be applied
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("85.88");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("scenarios > dashboard > filters", () => {

filterWidget().contains("2 selections");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findAllByText("Awesome Concrete Shoes");
cy.findAllByText("Awesome Iron Hat");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("scenarios > dashboard > filters > ID", () => {
addWidgetStringFilter("15");
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("114.42");
});
});
Expand All @@ -50,7 +50,7 @@ describe("scenarios > dashboard > filters > ID", () => {
saveDashboard();
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("114.42");
});
});
Expand All @@ -68,7 +68,7 @@ describe("scenarios > dashboard > filters > ID", () => {
addWidgetStringFilter("4");
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("47.68");
});

Expand All @@ -83,7 +83,7 @@ describe("scenarios > dashboard > filters > ID", () => {
saveDashboard();
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("47.68");
});

Expand All @@ -108,7 +108,7 @@ describe("scenarios > dashboard > filters > ID", () => {
addWidgetStringFilter("10");
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("6.75");
});
});
Expand All @@ -121,7 +121,7 @@ describe("scenarios > dashboard > filters > ID", () => {
saveDashboard();
cy.findByTestId("loading-spinner").should("not.exist");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("6.75");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("scenarios > dashboard > filters > location", () => {
addWidgetStringFilter(value);

cy.log(`Make sure ${filter} filter returns correct result`);
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains(representativeResult);
});

Expand All @@ -66,7 +66,7 @@ describe("scenarios > dashboard > filters > location", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains("1510");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("scenarios > dashboard > filters > number", () => {
addWidgetNumberFilter(value);

cy.log(`Make sure ${filter} filter returns correct result`);
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText(representativeResult);
});

Expand All @@ -74,7 +74,7 @@ describe("scenarios > dashboard > filters > number", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("37.65");
});

Expand All @@ -84,7 +84,7 @@ describe("scenarios > dashboard > filters > number", () => {

addWidgetNumberFilter("5.27", { buttonLabel: "Update filter" });

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("101.04");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("scenarios > dashboard > filters > SQL > date", () => {
});

cy.log(`Make sure ${filter} filter returns correct result`);
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains(representativeResult);
});

Expand All @@ -83,7 +83,7 @@ describe("scenarios > dashboard > filters > SQL > date", () => {
saveDashboard();

// The default value should immediately be applied
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains("Dagmar Fay");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("scenarios > dashboard > filters > SQL > ID", () => {
filterWidget().click();
addWidgetStringFilter("15");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("114.42");
});
});
Expand All @@ -43,7 +43,7 @@ describe("scenarios > dashboard > filters > SQL > ID", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("114.42");
});
});
Expand All @@ -60,7 +60,7 @@ describe("scenarios > dashboard > filters > SQL > ID", () => {
filterWidget().click();
addWidgetStringFilter("4");

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("47.68");
});
});
Expand All @@ -72,7 +72,7 @@ describe("scenarios > dashboard > filters > SQL > ID", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("47.68");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("scenarios > dashboard > filters > location", () => {
filterWidget().eq(index).click();
addWidgetStringFilter(value);

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains(representativeResult);
});

Expand All @@ -76,7 +76,7 @@ describe("scenarios > dashboard > filters > location", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains("Arnold Adams");
});

Expand All @@ -88,7 +88,7 @@ describe("scenarios > dashboard > filters > location", () => {

addWidgetStringFilter("Pittsburg", { buttonLabel: "Update filter" });

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains("Aracely Jenkins");
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("scenarios > dashboard > filters > SQL > text/category", () => {
addWidgetNumberFilter(value);

cy.log(`Make sure ${filter} filter returns correct result`);
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains(representativeResult);
});

Expand All @@ -78,7 +78,7 @@ describe("scenarios > dashboard > filters > SQL > text/category", () => {

saveDashboard();

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.contains("Small Marble Hat");
cy.contains("Rustic Paper Wallet").should("not.exist");
});
Expand All @@ -89,7 +89,7 @@ describe("scenarios > dashboard > filters > SQL > text/category", () => {

addWidgetNumberFilter("4.6", { buttonLabel: "Update filter" });

cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("Ergonomic Linen Toucan");
cy.contains("Small Marble Hat").should("not.exist");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()

// the native SQL filter is not mapped to the dashcard filter
// the results should show the default value was applied
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("Gizmo");
cy.contains("Widget").should("not.exist");
});
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()
clearFilterWidget();

// the results should show that the field filter was not applied
cy.get(".Card").within(() => {
cy.findByTestId("dashcard").within(() => {
cy.findByText("Doohickey");
});
});
Expand All @@ -118,7 +118,7 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()
// Default dashboard filter
cy.location("search").should("eq", "?category=Widget");

cy.get(".Card").as("dashboardCard").contains("Widget");
cy.findByTestId("dashcard").as("dashboardCard").contains("Widget");

filterWidget().contains("Widget");

Expand All @@ -127,7 +127,9 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()
cy.location("search").should("eq", "?category=");

// The default shouldn't apply, so we should get an error
cy.get(".Card").contains("There was a problem displaying this chart.");
cy.findByTestId("dashcard").contains(
"There was a problem displaying this chart.",
);

// The empty filter widget
filterWidget().contains("Category");
Expand All @@ -136,7 +138,9 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()

// This part confirms that the issue metabase#13960 has been fixed
cy.location("search").should("eq", "?category=");
cy.get(".Card").contains("There was a problem displaying this chart.");
cy.findByTestId("dashcard").contains(
"There was a problem displaying this chart.",
);

// Let's make sure the default dashboard filter is respected upon a subsequent visit from the root
cy.visit("/collection/root");
Expand Down
Loading

0 comments on commit 5faffa8

Please sign in to comment.