Skip to content
Snippets Groups Projects
Unverified Commit 9614786f authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix navigating back to a dashboard with text cards (#31035)

parent 28b1789c
No related merge requests found
......@@ -1053,6 +1053,7 @@ describe("scenarios > dashboard > dashboard drill", () => {
});
it("should preserve query results when navigating between the dashboard and the query builder", () => {
addTextCardToDashboard(1);
visitDashboard(1);
cy.wait("@dashboard");
cy.wait("@dashcardQuery");
......@@ -1067,12 +1068,17 @@ describe("scenarios > dashboard > dashboard drill", () => {
cy.findByLabelText("Back to Orders in a dashboard").click();
});
getDashboardCard().within(() => {
getDashboardCard(0).within(() => {
cy.findByText("101.04").should("be.visible"); // cached data
cy.get("@dashboard.all").should("have.length", 1);
cy.get("@dashcardQuery.all").should("have.length", 1);
});
getDashboardCard(1).within(() => {
cy.findByText("Text card").should("be.visible"); // cached data
});
cy.get("@dashboard.all").should("have.length", 1);
cy.get("@dashcardQuery.all").should("have.length", 1);
appBar().within(() => {
cy.findByText("Our analytics").click();
});
......@@ -1211,3 +1217,41 @@ function drillThroughCardTitle(title) {
function testPairedTooltipValues(val1, val2) {
cy.contains(val1).closest("td").siblings("td").findByText(val2);
}
function addTextCardToDashboard(dashboardId) {
cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, {
cards: [
{
id: 1,
card_id: 1,
dashboard_id: dashboardId,
row: 0,
col: 0,
size_x: 8,
size_y: 8,
visualization_settings: {},
},
{
id: -1,
card_id: null,
dashboard_id: dashboardId,
series: [],
col: 8,
row: 0,
size_x: 4,
size_y: 4,
parameter_mappings: [],
visualization_settings: {
virtual_card: {
name: null,
display: "text",
visualization_settings: {},
dataset_query: {},
archived: false,
},
text: "Text card",
},
},
],
});
}
......@@ -200,15 +200,18 @@ export const fetchDashboard = createThunkAction(
await dispatch(loadMetadataForDashboard(result.ordered_cards));
}
// copy over any virtual cards from the dashcard to the underlying card/question
result.ordered_cards.forEach(card => {
if (card.visualization_settings.virtual_card) {
card.card = Object.assign(
card.card || {},
card.visualization_settings.virtual_card,
);
}
});
const isUsingCachedResults = entities != null;
if (!isUsingCachedResults) {
// copy over any virtual cards from the dashcard to the underlying card/question
result.ordered_cards.forEach(card => {
if (card.visualization_settings.virtual_card) {
card.card = Object.assign(
card.card || {},
card.visualization_settings.virtual_card,
);
}
});
}
if (result.param_values) {
dispatch(addParamValues(result.param_values));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment