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
Fix library e2e empty state flaky test (#75429)
Gabriel Morenof23467960859
diff --git a/e2e/support/helpers/api/createLibrary.ts b/e2e/support/helpers/api/createLibrary.tsindex 523aa777cbe..c571630a2c5 100644--- a/e2e/support/helpers/api/createLibrary.ts+++ b/e2e/support/helpers/api/createLibrary.ts@@ -1,9 +1,20 @@import type { Collection } from "metabase-types/api";+import { retryRequest } from "../e2e-request-helpers";+type LibraryResponse = Collection & {effective_children?: Collection[];};+const hasLibraryRootCollections = (collections: Collection[]) => {+ const libraryCollection = collections.find(({ type }) => type === "library");++ return Boolean(+ libraryCollection?.children?.some(({ type }) => type === "library-data") &&+ libraryCollection?.children?.some(({ type }) => type === "library-metrics"),+ );+};+export const createLibrary = (): Cypress.Chainable<Cypress.Response<LibraryResponse>> => {@@ -11,5 +22,20 @@ export const createLibrary = (): Cypress.Chainable<return cy.request("POST", "/api/ee/library")- .then(() => cy.request<LibraryResponse>("GET", "/api/ee/library"));+ .then(() => cy.request<LibraryResponse>("GET", "/api/ee/library"))+ .then((response) => {+ return retryRequest(+ () =>+ cy.request<Collection[]>({+ method: "GET",+ url: "/api/collection/tree",+ qs: {+ "exclude-other-user-collections": true,+ "exclude-archived": true,+ "include-library": true,+ },+ }),+ ({ body }) => hasLibraryRootCollections(body),+ ).then(() => response);+ });};diff --git a/e2e/support/helpers/e2e-data-studio-helpers.ts b/e2e/support/helpers/e2e-data-studio-helpers.tsindex e97bba44a00..400026682e0 100644--- a/e2e/support/helpers/e2e-data-studio-helpers.ts+++ b/e2e/support/helpers/e2e-data-studio-helpers.ts@@ -143,6 +143,9 @@ export const DataStudio = {visit: () => {cy.visit("/data-studio/library");DataStudio.Library.libraryPage().should("be.visible");+ DataStudio.Library.collectionItem("Data").should("be.visible");+ DataStudio.Library.collectionItem("Metrics").should("be.visible");+ DataStudio.Library.collectionItem("SQL snippets").should("be.visible");},noResults: () =>libraryPage().findByText("No tables, metrics, or snippets yet"),@@ -155,5 +158,7 @@ export const DataStudio = {newButton: () => libraryPage().findByRole("button", { name: /New/ }),collectionItem: (name: string | RegExp) =>libraryPage().findAllByTestId("collection-name").contains(name),+ emptyStateRow: (description: string | RegExp) =>+ libraryPage().contains('[data-testid="empty-state-row"]', description),},};diff --git a/e2e/test/scenarios/data-studio/data-studio-library.cy.spec.ts b/e2e/test/scenarios/data-studio/data-studio-library.cy.spec.tsindex a38a3fa1753..bf7ed52a377 100644--- a/e2e/test/scenarios/data-studio/data-studio-library.cy.spec.ts+++ b/e2e/test/scenarios/data-studio/data-studio-library.cy.spec.ts@@ -403,18 +403,9 @@ describe("scenarios > data studio > library", () => {H.DataStudio.Library.visit();cy.log("Verify Data empty state is visible initially");- // `Library.visit()` only waits for the page container, not the library- // tree fetch. The empty-state row renders once that resolves; under- // fetch (microtask) timing the load can exceed the default assertion- // timeout, so give this first post-visit assertion a longer one.- H.DataStudio.Library.libraryPage()- .findByText(- "Cleaned, pre-transformed data sources ready for exploring",- {- timeout: 10000,- },- )- .should("be.visible");+ H.DataStudio.Library.emptyStateRow(+ "Cleaned, pre-transformed data sources ready for exploring",+ ).should("be.visible");cy.log("Publish a table via the +New menu");H.DataStudio.Library.newButton().click();@@ -433,21 +424,16 @@ describe("scenarios > data studio > library", () => {cy.log("Verify Data section shows the table (empty state hidden)");H.DataStudio.Library.tableItem("Orders").should("be.visible");- H.DataStudio.Library.libraryPage()- .findByText(- "Cleaned, pre-transformed data sources ready for exploring.",- )- .should("not.exist");cy.log("Verify Metrics and SQL snippets still show empty states (always expanded behavior)",);- H.DataStudio.Library.libraryPage()- .findByText("Standardized calculations with known dimensions")- .should("be.visible");- H.DataStudio.Library.libraryPage()- .findByText("Reusable bits of code that save your time")- .should("be.visible");+ H.DataStudio.Library.emptyStateRow(+ "Standardized calculations with known dimensions",+ ).should("be.visible");+ H.DataStudio.Library.emptyStateRow(+ "Reusable bits of code that save your time",+ ).should("be.visible");});describe("read-only mode", () => {