-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
70b1daa
commit 0102009
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...scenarios/visualizations/reproductions/19373-pivot-wrong-distinct-value-totals.cy.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { restore } from "__support__/e2e/helpers"; | ||
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database"; | ||
|
||
const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE; | ||
|
||
const questiondDetails = { | ||
name: "Products, Distinct values of Rating, Grouped by Category and Created At (year)", | ||
query: { | ||
"source-table": PRODUCTS_ID, | ||
aggregation: [["distinct", ["field", PRODUCTS.RATING, null]]], | ||
breakout: [ | ||
["field", PRODUCTS.CATEGORY, null], | ||
["field", PRODUCTS.CREATED_AT, { "temporal-unit": "year" }], | ||
], | ||
}, | ||
}; | ||
|
||
const ROW_TOTALS_INDEX = 4; | ||
const GRAND_TOTALS_INDEX = 4; | ||
|
||
describe.skip("issue 19373", () => { | ||
beforeEach(() => { | ||
cy.intercept("POST", "/api/dataset/pivot").as("pivotDataset"); | ||
|
||
restore(); | ||
cy.signInAsAdmin(); | ||
|
||
cy.createQuestion(questiondDetails, { visitQuestion: true }); | ||
}); | ||
|
||
it("should return correct sum of the distinct values in row totals (metabase#19373)", () => { | ||
// Convert to the pivot table manually to reflect the real-world scenario | ||
cy.findByTestId("viz-type-button").click(); | ||
cy.findByTestId("Pivot Table-button").should("be.visible").click(); | ||
cy.wait("@pivotDataset"); | ||
|
||
cy.findAllByRole("grid").eq(0).as("columnTitles"); | ||
cy.findAllByRole("grid").eq(1).as("rowTitles"); | ||
cy.findAllByRole("grid").eq(2).as("tableCells"); | ||
|
||
// Sanity check before we start asserting on this column | ||
cy.get("@columnTitles") | ||
.findAllByTestId("pivot-table-cell") | ||
.eq(ROW_TOTALS_INDEX) | ||
.should("contain", "Row totals"); | ||
|
||
cy.get("@rowTitles") | ||
.findAllByTestId("pivot-table-cell") | ||
.eq(GRAND_TOTALS_INDEX) | ||
.should("contain", "Grand totals"); | ||
|
||
cy.get("@tableCells") | ||
.findAllByTestId("pivot-table-cell") | ||
.eq(ROW_TOTALS_INDEX) | ||
.should("contain", "31"); | ||
}); | ||
}); |