From 8232f28885532ede114c153cbaf95d88983fdfe9 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 26 Jul 2022 18:23:05 +0100 Subject: [PATCH] Cypress: PostgreSql and createTable Changes PostgreSql - Added intercept when saving a query, sometimes it runs too fast createTable command - Improved to ensure better timing, and that table is correctly created --- .../cypress/integration/datasources/postgreSql.spec.js | 2 ++ packages/builder/cypress/support/commands.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/builder/cypress/integration/datasources/postgreSql.spec.js b/packages/builder/cypress/integration/datasources/postgreSql.spec.js index 0c3f2b9124..978c763203 100644 --- a/packages/builder/cypress/integration/datasources/postgreSql.spec.js +++ b/packages/builder/cypress/integration/datasources/postgreSql.spec.js @@ -150,7 +150,9 @@ filterTests(["all"], () => { cy.get("@query").its("response.statusCode").should("eq", 200) cy.get("@query").its("response.body").should("not.be.empty") // Save query + cy.intercept("**/queries").as("saveQuery") cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) + cy.wait("@saveQuery") cy.get(".spectrum-Tabs-content", { timeout: 2000 }).should("contain", queryName) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 16381a8336..9688894d24 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -422,7 +422,12 @@ Cypress.Commands.add("createTable", (tableName, initialTable) => { cy.get("input", { timeout: 2000 }).first().type(tableName).blur() cy.get(".spectrum-ButtonGroup").contains("Create").click() }) - cy.contains(tableName).should("be.visible") + // Ensure modal has closed and table is created + cy.get(".spectrum-Modal").should("not.exist") + cy.get(".spectrum-Tabs-content", { timeout: 1000 }).should( + "contain", + tableName + ) }) Cypress.Commands.add("createTestTableWithData", () => {