Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix flaky data-studio bulk "syncing multiple tables" e2e test (#76492)

github-automation-metabasea55fd162cf0f
diff --git a/e2e/test/scenarios/data-studio/data-model/data-studio-bulk-table.cy.spec.ts b/e2e/test/scenarios/data-studio/data-model/data-studio-bulk-table.cy.spec.ts
index d42e78526f1..fb720a89af3 100644
--- a/e2e/test/scenarios/data-studio/data-model/data-studio-bulk-table.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/data-model/data-studio-bulk-table.cy.spec.ts
@@ -47,14 +47,28 @@ describe("bulk table operations", { viewportWidth: 1600 }, () => {
it("syncing multiple tables", { tags: ["@external"] }, () => {
H.restore("postgres-writable");
H.activateToken("pro-self-hosted");
+ // Re-authenticate after restoring the writable-DB snapshot, like the
+ // sibling tests do — otherwise visiting Data Studio can land in an
+ // unauthenticated state and the TablePicker never issues the schema
+ // request, making `cy.wait("@getSchema")` time out.
+ cy.signInAsAdmin();
H.DataModel.visitDataStudio();
TablePicker.getDatabase("Writable Postgres12").click();
- cy.wait("@getSchema").then(({ response }) => {
- const tables = response?.body ?? [];
- const accountTableId = getTableId(tables, "Orders");
- const feedbackTableId = getTableId(tables, "Products");
+ // Wait for the UI to load the database's tables before interacting.
+ cy.wait("@getSchema");
+
+ // Capture the expected table IDs from a direct API request rather than the
+ // intercepted UI response: under stress the aliased `@getSchema` response
+ // body is occasionally a non-array (e.g. an error map), which made
+ // `tables.find` throw `TypeError: tables.find is not a function`. A
+ // `cy.request` deterministically returns the table list.
+ cy.request<Table[]>(
+ `/api/database/${WRITABLE_DB_ID}/schema/public?include_hidden=true`,
+ ).then(({ body: tables }) => {
+ const ordersTableId = getTableId(tables, "Orders");
+ const productsTableId = getTableId(tables, "Products");
- cy.wrap([accountTableId, feedbackTableId]).as("tableIds");
+ cy.wrap([ordersTableId, productsTableId]).as("tableIds");
});
TablePicker.getTable("Orders").find('input[type="checkbox"]').check();