Newer
Older
Kamil Mielnik
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { editDashboard, restore, visitDashboard } from "e2e/support/helpers";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
const baseQuestion = {
name: "Base question",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [["field", PRODUCTS.CATEGORY, null]],
},
visualization_settings: {
"graph.dimensions": ["CATEGORY"],
"graph.metrics": ["count"],
},
display: "bar",
};
const incompleteQuestion = {
name: "Incomplete question",
native: {
query: "select 1;",
},
visualization_settings: {
"graph.dimensions": [null],
"graph.metrics": ["1"],
},
display: "bar",
};
const issue32231Error = "Cannot read properties of undefined (reading 'name')";
const multipleSeriesError = "Unable to combine these questions";
const defaultError = "Which fields do you want to use for the X and Y axes?";
describe("issue 32231", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.intercept("GET", "/api/card/*/series?limit=*").as("seriesQuery");
});
it("should show user-friendly error when combining series that cannot be visualized together (metabase#32231)", () => {
cy.createNativeQuestion(incompleteQuestion);
cy.createQuestionAndDashboard({ questionDetails: baseQuestion }).then(
({ body: { id, card_id, dashboard_id } }) => {
cy.request("PUT", `/api/dashboard/${dashboard_id}/cards`, {
cards: [
{
id,
card_id,
row: 0,
col: 0,
size_x: 16,
size_y: 10,
},
],
});
visitDashboard(dashboard_id);
},
);
editDashboard();
cy.findByTestId("add-series-button").click({ force: true });
cy.wait("@seriesQuery");
cy.findByTestId("add-series-modal").within(() => {
cy.get(".LineAreaBarChart").should("exist");
cy.findByText(issue32231Error).should("not.exist");
cy.findByText(multipleSeriesError).should("not.exist");
cy.findByText(defaultError).should("not.exist");
cy.findByText(incompleteQuestion.name).click();
cy.get(".LineAreaBarChart").should("not.exist");
cy.findByText(issue32231Error).should("not.exist");
cy.findByText(multipleSeriesError).should("exist");
cy.findByText(defaultError).should("not.exist");
cy.findByText(incompleteQuestion.name).click();
cy.get(".LineAreaBarChart").should("exist");
cy.findByText(issue32231Error).should("not.exist");
cy.findByText(multipleSeriesError).should("not.exist");
cy.findByText(defaultError).should("not.exist");
});
});
it("should show default visualization error message when the only series is incomplete", () => {
cy.createNativeQuestionAndDashboard({
questionDetails: incompleteQuestion,
}).then(({ body: { id, card_id, dashboard_id } }) => {
cy.request("PUT", `/api/dashboard/${dashboard_id}/cards`, {
cards: [
{
id,
card_id,
row: 0,
col: 0,
size_x: 16,
size_y: 10,
},
],
});
visitDashboard(dashboard_id);
});
cy.findByTestId("dashcard").findByText(defaultError).should("exist");
cy.icon("pencil").click();
cy.findByTestId("add-series-button").click({ force: true });
cy.wait("@seriesQuery");
cy.findByTestId("add-series-modal").within(() => {
cy.get(".LineAreaBarChart").should("not.exist");
cy.findByText(issue32231Error).should("not.exist");
cy.findByText(multipleSeriesError).should("not.exist");
cy.findByText(defaultError).should("exist");
});
});
});