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
Consolidate table visualization e2e tests (#83957)
Nemanja Glumac70a0c69415b9
diff --git a/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts b/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.tsindex 5b6bb6c674b..2ad7fe2b2ee 100644--- a/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts+++ b/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts@@ -94,21 +94,19 @@ describe("extract shortcut", () => {});describe("date columns", () => {- describe("should add a date expression for each option", () => {+ it("should add a date expression for each option", () => {+ H.openOrdersTable({ limit: 1 });DATE_CASES.forEach(({ option, value, example, expressions }) => {- it(option, () => {- H.openOrdersTable({ limit: 1 });- extractColumnAndCheck({- column: "Created At",- option,- value,- example,- });- H.expectUnstructuredSnowplowEvent({- event: "column_extract_via_plus_modal",- custom_expressions_used: expressions,- database_id: SAMPLE_DB_ID,- });+ extractColumnAndCheck({+ column: "Created At",+ option,+ value,+ example,+ });+ H.expectUnstructuredSnowplowEvent({+ event: "column_extract_via_plus_modal",+ custom_expressions_used: expressions,+ database_id: SAMPLE_DB_ID,});});});@@ -143,86 +141,45 @@ describe("extract shortcut", () => {});H.popover().button("Update").should("not.be.disabled").click();H.visualize();+ H.tableHeaderColumn("custom formula").should("be.visible");cy.findByRole("gridcell", { name: "2,030" }).should("be.visible");});});- describe("email columns", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- EMAIL_CASES.forEach(({ option, value, example, expressions }) => {- it(option, () => {- H.createQuestion(- {- query: {- "source-table": PEOPLE_ID,- limit: 1,- },- },- {- visitQuestion: true,- },- );-- extractColumnAndCheck({- column: "Email",- option,- value,- example,- });- H.expectUnstructuredSnowplowEvent({- event: "column_extract_via_plus_modal",- custom_expressions_used: expressions,- database_id: SAMPLE_DB_ID,- });- });+ it("should add a url expression for each option", () => {+ // Make the Email column a URL column for this test, to avoid having to create a new model+ cy.request("PUT", `/api/field/${PEOPLE.EMAIL}`, {+ semantic_type: "type/URL",});- });- describe("url columns", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- // Make the Email column a URL column for these tests, to avoid having to create a new model- cy.request("PUT", `/api/field/${PEOPLE.EMAIL}`, {- semantic_type: "type/URL",- });- });+ H.createQuestion(+ {+ query: {+ "source-table": PEOPLE_ID,+ limit: 1,+ },+ },+ {+ visitQuestion: true,+ },+ );URL_CASES.forEach(({ option, value, example, expressions }) => {- it(option, () => {- H.createQuestion(- {- query: {- "source-table": PEOPLE_ID,- limit: 1,- },- },- {- visitQuestion: true,- },- );-- extractColumnAndCheck({- column: "Email",- option,- value,- example,- });- H.expectUnstructuredSnowplowEvent({- event: "column_extract_via_plus_modal",- custom_expressions_used: expressions,- database_id: SAMPLE_DB_ID,- });+ extractColumnAndCheck({+ column: "Email",+ option,+ value,+ example,+ });+ H.expectUnstructuredSnowplowEvent({+ event: "column_extract_via_plus_modal",+ custom_expressions_used: expressions,+ database_id: SAMPLE_DB_ID,});});});- it("should disable the scroll behaviour after it has been rendered", () => {+ it("should add an email expression for each option and disable the scroll behaviour after it has been rendered", () => {H.createQuestion({query: {@@ -235,9 +192,18 @@ describe("extract shortcut", () => {},);- extractColumnAndCheck({- column: "Email",- option: "Host",+ EMAIL_CASES.forEach(({ option, value, example, expressions }) => {+ extractColumnAndCheck({+ column: "Email",+ option,+ value,+ example,+ });+ H.expectUnstructuredSnowplowEvent({+ event: "column_extract_via_plus_modal",+ custom_expressions_used: expressions,+ database_id: SAMPLE_DB_ID,+ });});H.tableInteractiveScrollContainer().scrollTo("left", {@@ -246,8 +212,10 @@ describe("extract shortcut", () => {H.tableHeaderClick("ID");+ cy.intercept("POST", "/api/dataset").as("sortedDataset");// Change sort directionH.popover().findAllByRole("button").first().click();+ cy.wait("@sortedDataset");// ID should still be visible (ie. no scrolling to the end should have happened)cy.findAllByRole("columnheader").contains("ID").should("be.visible");@@ -273,10 +241,6 @@ describe("extract shortcut", () => {column: "Created At: Month",option: "Month of year",});-- cy.findAllByRole("columnheader", { name: "Month of year" }).should(- "be.visible",- );});it("should be possible to extract columns from table with breakouts", () => {@@ -299,10 +263,6 @@ describe("extract shortcut", () => {column: "Created At: Month",option: "Month of year",});-- cy.findAllByRole("columnheader", { name: "Month of year" }).should(- "be.visible",- );});});@@ -334,15 +294,19 @@ function extractColumnAndCheck({cy.wait(`@${requestAlias}`);- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByRole("columnheader")- .last()- .should("have.text", newColumn)- .should("be.visible");+ cy.findByRole("columnheader", { name: newColumn }).should("exist");++ // With many columns, the "Add column" button can cover the last header,+ // so the visible value cell shows that the table scrolled to the new column.+ if (!value) {+ cy.findByRole("columnheader", { name: newColumn }).should("be.visible");+ }- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByRole("columnheader").last().should("have.text", newColumn);- if (value) {+ if (value === "") {+ H.tableInteractiveBody()+ .find(`[data-column-id="${newColumn}"]`)+ .should("have.text", "");+ } else if (value) {cy.findByRole("gridcell", { name: value }).should("be.visible");}}diff --git a/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.jsindex ec88bc90285..9f2cfb6c718 100644--- a/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js@@ -11,7 +11,6 @@ const tableQuestion = {query: {"source-table": ORDERS_ID,},- limit: 5,};const tableQuestionWithJoin = {@@ -75,7 +74,6 @@ const tableQuestionWithJoinAndFields = {},],},- limit: 5,};const tableQuestionWithSelfJoinAndFields = {@@ -163,7 +161,6 @@ const nativeQuestion = {native: {query: "SELECT * FROM ORDERS",},- limit: 5,};const nestedQuestion = (card) => ({@@ -171,7 +168,6 @@ const nestedQuestion = (card) => ({query: {"source-table": `card__${card.id}`,},- limit: 5,});const nestedQuestionWithJoinOnTable = (card) => ({@@ -229,18 +225,24 @@ describe("scenarios > visualizations > table column settings", () => {needsScroll = true,scrollTimes = 1,}) => {+ const scroll = () => {+ if (needsScroll) {+ _.times(scrollTimes, () => {+ scrollVisualization();+ cy.wait(200);+ });+ }+ };+cy.log("hide the column");+ scroll();+ visualization().findByText(columnName).should("exist");visibleColumns().within(() => hideColumn(columnName));assertColumnHidden(getColumn(columnName));if (sanityCheck) {assertColumnEnabled(getColumn(sanityCheck));}- if (needsScroll) {- _.times(scrollTimes, () => {- scrollVisualization();- cy.wait(200);- });- }+ scroll();visualization().findByText(columnName).should("not.exist");cy.findByRole("button", { name: /Add or remove columns/ }).click();@@ -331,10 +333,21 @@ describe("scenarios > visualizations > table column settings", () => {};describe("tables", () => {- it("should be able to show and hide table fields", () => {+ it("should be able to show and hide table fields, implicitly joinable fields, and rename columns via popover", () => {H.createQuestion(tableQuestion, { visitQuestion: true });openSettings();+ const implicitColumn = {+ column: "Category",+ columnName: "Product → Category",+ table: "product",+ };++ _addColumn(implicitColumn);+ _hideColumn(implicitColumn);+ _showColumn(implicitColumn);+ _removeColumn(implicitColumn);+const testData = {column: "Tax",columnName: "Tax",@@ -346,10 +359,6 @@ describe("scenarios > visualizations > table column settings", () => {_showColumn(testData);_removeColumn(testData);_addColumn(testData);- });-- it("should be able to rename table columns via popover", () => {- H.createQuestion(tableQuestion, { visitQuestion: true });H.tableHeaderClick("Product ID");@@ -366,24 +375,7 @@ describe("scenarios > visualizations > table column settings", () => {});});- it("should be able to show and hide table fields with in a join", () => {- H.createQuestion(tableQuestionWithJoin, { visitQuestion: true });- openSettings();-- const testData = {- column: "Category",- columnName: "Products → Category",- sanityCheck: "Products → Ean",- table: "products",- };-- _hideColumn(testData);- _showColumn(testData);- _removeColumn(testData);- _addColumn(testData);- });-- it("should be able to show and hide all table fields with a single click", () => {+ it("should be able to show and hide all and single table fields in a join", () => {H.createQuestion(tableQuestionWithJoin, { visitQuestion: true });openSettings();@@ -419,6 +411,19 @@ describe("scenarios > visualizations > table column settings", () => {cy.findByLabelText("Category").should("be.checked");cy.findByLabelText("Price").should("be.checked");});+ cy.findByRole("button", { name: /Done picking columns/ }).click();++ const testData = {+ column: "Category",+ columnName: "Products → Category",+ sanityCheck: "Products → Ean",+ table: "products",+ };++ _hideColumn(testData);+ _showColumn(testData);+ _removeColumn(testData);+ _addColumn(testData);});it("should be able to show and hide table fields with a join with fields", () => {@@ -464,22 +469,6 @@ describe("scenarios > visualizations > table column settings", () => {_addColumn(testData);});- it("should be able to show and hide implicitly joinable fields for a table", () => {- H.createQuestion(tableQuestion, { visitQuestion: true });- openSettings();-- const testData = {- column: "Category",- columnName: "Product → Category",- table: "product",- };-- _addColumn(testData);- _hideColumn(testData);- _showColumn(testData);- _removeColumn(testData);- });-it("should be able to show and hide custom expressions for a table", () => {H.createQuestion(tableQuestionWithExpression, {visitQuestion: true,@@ -570,27 +559,34 @@ describe("scenarios > visualizations > table column settings", () => {it("should not duplicate column in settings when removing and adding it back (metabase#22206)", () => {H.openVizSettingsSidebar();- // remove column- cy.findByTestId("sidebar-content")- .findByTestId("draggable-item-Subtotal")- .icon("eye_outline")- .click({ force: true });+ // The duplicate shows on the second cycle+ _.times(2, () => {+ cy.findByTestId("sidebar-content")+ .findByTestId("draggable-item-Subtotal")+ .icon("eye_outline")+ .click({ force: true });++ cy.findAllByTestId("run-button").first().click();+ cy.wait("@dataset");+ cy.findByTestId("loading-indicator").should("not.exist");++ cy.findByTestId("sidebar-content")+ .findByTestId("draggable-item-Subtotal")+ .icon("eye_crossed_out")+ .click({ force: true });++ cy.findByTestId("sidebar-content")+ .findByTestId("draggable-item-Subtotal")+ .icon("eye_outline")+ .should("exist");+ cy.findByTestId("sidebar-content")+ .findAllByTestId("draggable-item-Subtotal")+ .should("have.length", 1);+ });- // rerun querycy.findAllByTestId("run-button").first().click();cy.wait("@dataset");- cy.findByTestId("loading-indicator").should("not.exist");-- // add column back again- cy.findByTestId("sidebar-content")- .findByTestId("draggable-item-Subtotal")- .icon("eye_crossed_out")- .click({ force: true });-- // fails because there are 2 columns, when there should be one- cy.findByTestId("sidebar-content").findByText("Subtotal");-- // if you add it back again it crashes the question+ H.tableInteractive().findByText("Subtotal").should("exist");});});});@@ -688,12 +684,22 @@ describe("scenarios > visualizations > table column settings", () => {});describe("nested structured questions", () => {- it("should be able to show and hide fields from a nested query", () => {+ it("should be able to show and hide fields and implicitly joinable fields from a nested query", () => {H.createQuestion(tableQuestion).then(({ body: card }) => {H.createQuestion(nestedQuestion(card), { visitQuestion: true });});openSettings();+ const implicitColumn = {+ column: "Category",+ columnName: "Product → Category",+ table: "product",+ };++ _addColumn(implicitColumn);+ _hideColumn(implicitColumn);+ _removeColumn(implicitColumn);+const testData = {column: "Tax",columnName: "Tax",@@ -774,23 +780,6 @@ describe("scenarios > visualizations > table column settings", () => {_removeColumn(newColumn);});- it("should be able to show and hide implicitly joinable fields for a nested query", () => {- H.createQuestion(tableQuestion).then(({ body: card }) => {- H.createQuestion(nestedQuestion(card), { visitQuestion: true });- });- openSettings();-- const newColumn = {- column: "Category",- columnName: "Product → Category",- table: "product",- };-- _addColumn(newColumn);- _hideColumn(newColumn);- _removeColumn(newColumn);- });-it("should be able to show and hide custom expressions from a nested query", () => {H.createQuestion(tableQuestionWithExpression).then(({ body: card }) => {H.createQuestion(nestedQuestion(card), { visitQuestion: true });@@ -1269,7 +1258,8 @@ describe("scenarios > visualizations > table column settings", () => {.findAllByTestId("header-cell").should("have.length", 1).first()- .should("contain.text", "ID");+ .findByText("ID")+ .should("exist");H.tableHeaderColumn("User ID").as("dragElement");H.moveDnDKitElementByAlias("@dragElement", { horizontal: -50 });@@ -1278,7 +1268,8 @@ describe("scenarios > visualizations > table column settings", () => {.findAllByTestId("header-cell").should("have.length", 1).first()- .should("contain.text", "User ID");+ .findByText("User ID")+ .should("exist");});it("should allow reordering a column from the pinned section into the unpinned section", () => {@@ -1296,9 +1287,9 @@ describe("scenarios > visualizations > table column settings", () => {cy.findByTestId("header-pinned-quadrant").findAllByTestId("header-cell").should("have.length", 2)- .then((cells) => {- expect(cells.eq(0)).to.contain("ID");- expect(cells.eq(1)).to.contain("User ID");+ .should((cells) => {+ expect(cells.eq(0).text()).to.match(/^ID/);+ expect(cells.eq(1).text()).to.match(/^User ID/);});H.tableHeaderColumn("ID").as("dragElement");@@ -1306,9 +1297,9 @@ describe("scenarios > visualizations > table column settings", () => {cy.findByTestId("header-pinned-quadrant").findAllByTestId("header-cell")- .then((cells) => {- expect(cells.eq(0)).to.contain("User ID");- expect(cells.eq(1)).to.contain("Product ID");+ .should((cells) => {+ expect(cells.eq(0).text()).to.match(/^User ID/);+ expect(cells.eq(1).text()).to.match(/^Product ID/);});});});diff --git a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.jsindex 546a5c69bc0..efc5fde3759 100644--- a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js@@ -41,6 +41,7 @@ describe("scenarios > visualizations > table", () => {H.assertTableData({columns: initialColumnsOrder,});+ assertColumnNotSortable("Count");H.notebookButton().click();@@ -56,6 +57,7 @@ describe("scenarios > visualizations > table", () => {H.assertTableData({columns: initialColumnsOrder,});+ assertColumnNotSortable("Count");});it("should allow changing column title when the field ref is the same except for the join-alias", () => {@@ -77,7 +79,8 @@ describe("scenarios > visualizations > table", () => {});cy.realPress("Escape");- headerCells().findAllByText("ID updated").should("have.length", 1);+ H.tableHeaderColumn("ID updated").should("exist");+ H.tableHeaderColumn("Orders_2 → ID").should("exist");});it("should allow selecting cells in a table and copy the values", () => {@@ -145,6 +148,7 @@ describe("scenarios > visualizations > table", () => {// Click outside to clear selectiongetNonPKCells().eq(0).click();+ assertSelectedCells(1);// Click outside the tableH.queryBuilderHeader().findByText("Orders").click();assertSelectedCells(0);@@ -155,6 +159,10 @@ describe("scenarios > visualizations > table", () => {H.openVizSettingsSidebar();H.sidebar().findByText("Display").click();H.sidebar().findByText("Show row index").click();+ H.tableInteractive()+ .findAllByTestId("row-id-cell")+ .eq(5)+ .should("have.text", "6");H.openObjectDetail(5);@@ -183,6 +191,9 @@ describe("scenarios > visualizations > table", () => {cy.findByTestId("sidebar-left").findByText("Done").click();headerCells().eq(3).should("contain.text", "TOTAL");+ H.tableHeaderColumn("TOTAL")+ .parents('[aria-roledescription="sortable"]')+ .should("exist");H.tableHeaderColumn("TOTAL").as("dragElement");H.moveDnDKitElementByAlias("@dragElement", { horizontal: -220 });headerCells().eq(1).should("contain.text", "TOTAL");@@ -193,55 +204,15 @@ describe("scenarios > visualizations > table", () => {headerCells().contains("QUANTITY").should("not.exist");});- it("should preserve set widths after reordering (VIZ-439)", () => {- cy.intercept(- "GET",- "/api/search?models=dataset&models=table&table_db_id=*",- ).as("getSearchResults");- cy.intercept("POST", "/api/dataset").as("getDataset");- H.startNewNativeQuestion({- query: 'select 1 "first_column", 2 "second_column"',- display: "table",- visualization_settings: { "table.column_widths": [600, 150] },- });-- cy.findByTestId("native-query-editor-container").icon("play").click();- cy.wait(["@getSearchResults", "@getDataset"]);-- H.tableHeaderColumn("first_column").invoke("outerWidth").as("firstWidth");- H.tableHeaderColumn("second_column").invoke("outerWidth").as("secondWidth");-- H.tableHeaderColumn("first_column").as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- horizontal: 100,- });-- const assertUnchangedWidths = () => {- cy.get("@firstWidth").then((firstWidth) => {- H.tableHeaderColumn("first_column")- .invoke("outerWidth")- .should("eq", firstWidth);- });-- cy.get("@secondWidth").then((secondWidth) => {- H.tableHeaderColumn("second_column")- .invoke("outerWidth")- .should("eq", secondWidth);- });- };-- assertUnchangedWidths();- cy.reload();+ it("should close the column popover on subsequent click and display any column as link with extrapolated url and text (metabase#16789)", () => {+ H.openPeopleTable({ limit: 2 });- cy.findByTestId("native-query-editor-container").icon("play").click();- // Wait for column widths to be set- cy.wait(["@getSearchResults", "@getDataset"]);- H.tableHeaderColumn("first_column").should("be.visible");- assertUnchangedWidths();- });+ H.tableHeaderColumn("City").click();+ H.clickActionsPopover().should("be.visible");- it("should allow to display any column as link with extrapolated url and text", () => {- H.openPeopleTable({ limit: 2 });+ H.tableHeaderColumn("City").click();+ cy.wait(100); // Ensure popover is closed+ H.clickActionsPopover({ skipVisibilityCheck: true }).should("not.exist");H.tableHeaderClick("City");@@ -403,7 +374,7 @@ describe("scenarios > visualizations > table", () => {});});- it("should show the field metadata popover for a foreign key field (metabase#19577)", () => {+ it("should show foreign key metadata, close the header popover with Escape, and show metadata in the summarize sidebar (metabase#19577, metabase#55673)", () => {H.openOrdersTable({ limit: 2 });cy.get("[data-testid=cell-data]")@@ -414,10 +385,22 @@ describe("scenarios > visualizations > table", () => {cy.contains("Foreign Key");cy.contains("The product ID.");});- });- it("should show field metadata in a hovercard when hovering over a table column in the summarize sidebar", () => {- H.openOrdersTable({ limit: 2 });+ cy.get("[data-testid=cell-data]")+ .contains("Product ID")+ .trigger("mouseout");+ H.hovercard().should("not.exist");++ H.tableHeaderClick("Product ID");+ cy.findByTestId("click-actions-view").should("be.visible");++ cy.focused().should(+ "have.attr",+ "data-testid",+ "click-actions-sort-control-sort.ascending",+ );+ cy.realPress(["Escape"]);+ cy.findByTestId("click-actions-view").should("not.exist");H.summarize();@@ -452,31 +435,6 @@ describe("scenarios > visualizations > table", () => {.and("contain", "No description");});- it("should close the colum popover on subsequent click (metabase#16789)", () => {- H.openPeopleTable({ limit: 2 });-- H.tableHeaderColumn("City").click();- H.clickActionsPopover().should("be.visible");-- H.tableHeaderColumn("City").click();- cy.wait(100); // Ensure popover is closed- H.clickActionsPopover({ skipVisibilityCheck: true }).should("not.exist");- });-- it("should be able to close a header popover using Escape (metabase#55673)", () => {- H.openOrdersTable();- H.tableHeaderClick("Product ID");- cy.findByTestId("click-actions-view").should("be.visible");-- cy.focused().should(- "have.attr",- "data-testid",- "click-actions-sort-control-sort.ascending",- );- cy.realPress(["Escape"]);- cy.findByTestId("click-actions-view").should("not.exist");- });-it("popover should not be scrollable horizontally (metabase#31339)", () => {H.openPeopleTable();H.tableHeaderClick("Password");@@ -503,13 +461,15 @@ describe("scenarios > visualizations > table", () => {});});+ cy.clock();cy.button("Visualize").click();- cy.clock();- cy.tick(1000);cy.findByTestId("query-builder-main").findByText("Doing science...");+ cy.findByTestId("query-builder-main")+ .findByText("Waiting for results...")+ .should("not.exist");- cy.tick(5000);+ cy.tick(4000);cy.findByTestId("query-builder-main").findByText("Waiting for results...");});@@ -544,7 +504,8 @@ describe("scenarios > visualizations > table", () => {});it("should not crash when the table viz gets automatically pivoted (metabase#45481)", () => {- H.openOrdersTable({ mode: "notebook" });+ H.openOrdersTable();+ H.openNotebook();H.summarize({ mode: "notebook" });H.popover().findByText("Count of rows").click();H.getNotebookStep("summarize")@@ -560,7 +521,7 @@ describe("scenarios > visualizations > table", () => {cy.findByText("Category").click();});H.visualize();- H.tableInteractive().should("be.visible");+ H.tableInteractiveHeader().should("contain", "Doohickey");});describe("issue 56094", () => {@@ -724,11 +685,14 @@ describe("scenarios > visualizations > table", () => {H.tableInteractive().should("be.visible");cy.findByTestId("visualization-root").icon("warning").should("not.exist");+ cy.intercept("POST", "/api/dataset").as("dataset");cy.findByTestId("qb-header-action-panel").findByText("Explore results").click();+ cy.wait("@dataset");H.tableInteractive().should("be.visible");+ cy.findByTestId("visualization-root").icon("warning").should("not.exist");});});});@@ -769,10 +733,8 @@ describe("scenarios > visualizations > table > dashboards context", () => {H.dashboardCards().eq(0).as("tableDashcard")- .findByText(rowsRegex)- .should("not.exist");-- cy.get("@tableDashcard").findByText("Showing first 2,000 rows");+ .findByText("Showing first 2,000 rows");+ cy.get("@tableDashcard").findByText(rowsRegex).should("not.exist");// Enable paginationH.editDashboard();@@ -813,38 +775,67 @@ describe("scenarios > visualizations > table > dashboards context", () => {cy.get(idCellSelector).should("contain", secondPageId);});- it("should display pinned rows correctly with pagination", () => {- H.createQuestionAndDashboard({- questionDetails: {- display: "table",- query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },- visualization_settings: {- "table.freeze_rows": true,- "table.freeze_rows_count": 1,- "table.pagination": true,+ it("should display pinned rows correctly with pagination and client-side sorting", () => {+ const pinnedRowsSettings = {+ "table.freeze_rows": true,+ "table.freeze_rows_count": 1,+ };++ H.createDashboardWithQuestions({+ questions: [+ {+ display: "table",+ query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },+ visualization_settings: {+ ...pinnedRowsSettings,+ "table.pagination": true,+ },},- },- cardDetails: {- size_x: 24,- size_y: 12,- },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);+ {+ display: "table",+ query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },+ visualization_settings: pinnedRowsSettings,+ },+ ],+ cards: [+ { row: 0, col: 0, size_x: 12, size_y: 12 },+ { row: 0, col: 12, size_x: 12, size_y: 12 },+ ],+ }).then(({ dashboard }) => {+ H.visitDashboard(dashboard.id);});- cy.findByTestId("pinned-center-quadrant")- .findByRole("row")- .find("[data-column-id=ID]")- .findByTestId("cell-data")- .should("have.text", "1");+ const pinnedRowId = () =>+ cy+ .findByTestId("pinned-center-quadrant")+ .findByRole("row")+ .find("[data-column-id=ID]")+ .findByTestId("cell-data");++ cy.log("pagination");+ H.getDashboardCard(0).within(() => {+ pinnedRowId().should("have.text", "1");++ cy.findByText(/Rows 1-\d+ of first 2,000/).should("exist");+ cy.findByLabelText("Next page").click();+ cy.findByText(/Rows \d+-\d+ of first 2,000/).should(+ "not.contain.text",+ "Rows 1-",+ );- cy.findByLabelText("Next page").click();+ pinnedRowId().should("have.text", "1");+ });++ cy.log("client-side sorting");+ H.getDashboardCard(1).within(() => {+ pinnedRowId().should("have.text", "1");++ H.tableHeaderClick("ID");+ pinnedRowId().should("have.text", "2000");- cy.findByTestId("pinned-center-quadrant")- .findByRole("row")- .find("[data-column-id=ID]")- .findByTestId("cell-data")- .should("have.text", "1");+ H.tableHeaderClick("ID");+ pinnedRowId().should("have.text", "1");+ });});it("should support text wrapping setting", () => {@@ -991,11 +982,14 @@ describe("scenarios > visualizations > table > dashboards context", () => {.should("exist").then(() => {H.tableHeaderClick("Rating");+ H.tableHeaderColumn("Rating")+ .closest("[role=columnheader]")+ .findByLabelText("chevrondown icon");// Verify rows don't overlap by checking their bounding rectsH.tableInteractiveBody().find("[role=row]")- .then(($rows) => {+ .should(($rows) => {const rects = $rows.toArray().map((row) => row.getBoundingClientRect())@@ -1007,12 +1001,15 @@ describe("scenarios > visualizations > table > dashboards context", () => {}});- // Sort again (descending) to verify heights update on subsequent sorts+ // Sort again (ascending) to verify heights update on subsequent sortsH.tableHeaderClick("Rating");+ H.tableHeaderColumn("Rating")+ .closest("[role=columnheader]")+ .findByLabelText("chevronup icon");H.tableInteractiveBody().find("[role=row]")- .then(($rows) => {+ .should(($rows) => {const rects = $rows.toArray().map((row) => row.getBoundingClientRect())@@ -1026,77 +1023,6 @@ describe("scenarios > visualizations > table > dashboards context", () => {});});- it("should support the row index setting", () => {- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();-- H.getDashboardCard(0)- .realHover()- .within(() => {- cy.findByLabelText("Show visualization options").click();- });- H.modal().findByText("Display").click();- H.modal().findByText("Show row index").click();-- cy.button("Done").click();-- H.saveDashboard();-- H.tableInteractiveBody()- .findAllByTestId("row-id-cell")- .eq(0)- .should("have.text", 1);-- // Apply sorting to ensure row index does not change- H.tableHeaderClick("ID");-- H.tableInteractiveBody()- .findAllByTestId("row-id-cell")- .eq(0)- .should("have.text", 1);- });-- it("should sort pinned rows correctly with client-side sorting", () => {- H.createQuestionAndDashboard({- questionDetails: {- display: "table",- query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },- visualization_settings: {- "table.freeze_rows": true,- "table.freeze_rows_count": 1,- },- },- cardDetails: {- size_x: 24,- size_y: 12,- },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });-- cy.findByTestId("pinned-center-quadrant")- .findByRole("row")- .find("[data-column-id=ID]")- .findByTestId("cell-data")- .should("have.text", "1");-- H.tableHeaderClick("ID");-- cy.findByTestId("pinned-center-quadrant")- .findByRole("row")- .find("[data-column-id=ID]")- .findByTestId("cell-data")- .should("have.text", "2000");-- H.tableHeaderClick("ID");-- cy.findByTestId("pinned-center-quadrant")- .findByRole("row")- .find("[data-column-id=ID]")- .findByTestId("cell-data")- .should("have.text", "1");- });-it("should expand columns to the full width of the dashcard (metabase#57381)", () => {const sideColumnsWidth = 200;const expandedSideColumnsWidth = 2 * sideColumnsWidth;@@ -1172,7 +1098,7 @@ describe("scenarios > visualizations > table > dashboards context", () => {});});- it("should support resizing columns in dashcard viz settings", () => {+ it("should support resizing columns and the row index setting in dashcard viz settings", () => {H.visitDashboard(ORDERS_DASHBOARD_ID);cy.findAllByTestId("header-cell").filter(":contains(ID)")@@ -1213,6 +1139,37 @@ describe("scenarios > visualizations > table > dashboards context", () => {expect(newWidth).to.be.gte(originalWidth + resizeByWidth);});});++ cy.log("row index setting");+ H.editDashboard();++ H.getDashboardCard(0)+ .realHover()+ .within(() => {+ cy.findByLabelText("Show visualization options").click();+ });+ H.modal().findByText("Display").click();+ H.modal().findByText("Show row index").click();++ cy.button("Done").click();++ H.saveDashboard();++ H.tableInteractiveBody()+ .findAllByTestId("row-id-cell")+ .eq(0)+ .should("have.text", 1);++ // Apply sorting to ensure row index does not change+ H.tableHeaderClick("ID");+ H.tableHeaderColumn("ID")+ .closest("[role=columnheader]")+ .findByLabelText("chevrondown icon");++ H.tableInteractiveBody()+ .findAllByTestId("row-id-cell")+ .eq(0)+ .should("have.text", 1);});});@@ -1393,7 +1350,7 @@ describe("scenarios > visualizations > table > with tracking", () => {H.expectNoBadSnowplowEvents();});- it("should track when freeze columns is enabled from viz settings", () => {+ it("should track when freeze columns and freeze rows are enabled from viz settings", () => {H.openOrdersTable();H.openVizSettingsSidebar();H.sidebar().findByText("Display").click();@@ -1409,12 +1366,6 @@ describe("scenarios > visualizations > table > with tracking", () => {},1,);- });-- it("should track when freeze rows is enabled from viz settings", () => {- H.openOrdersTable();- H.openVizSettingsSidebar();- H.sidebar().findByText("Display").click();H.sidebar().findByText("Freeze rows").click();@@ -1483,7 +1434,9 @@ describe("scenarios > visualizations > table > time formatting (#11398)", () =>H.openOrdersTable();const targetDatasetIndex = 15;+ const firstRowSelector = '[role=row][data-dataset-index="0"]';+ H.tableInteractiveBody().find(firstRowSelector).should("exist");H.tableInteractiveBody().find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`).then(($row) => {@@ -1495,6 +1448,7 @@ describe("scenarios > visualizations > table > time formatting (#11398)", () =>currentScroll + 36 * (targetDatasetIndex - 1);});+ H.tableInteractiveBody().find(firstRowSelector).should("not.exist");H.tableInteractiveBody().find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`).should("exist")@@ -1506,6 +1460,12 @@ describe("scenarios > visualizations > table > time formatting (#11398)", () =>});});+function assertColumnNotSortable(columnName) {+ H.tableHeaderColumn(columnName)+ .parents('[aria-roledescription="sortable"]')+ .should("not.exist");+}+function headerCells() {return cy.findAllByTestId("header-cell");}