From 4d73eb05f4898c254d700e2f630359ff9f21982e Mon Sep 17 00:00:00 2001 From: "Krishna (kc) Glick" Date: Fri, 7 Oct 2022 13:55:59 -0400 Subject: [PATCH] Improve E2E testing around the Connection Form (#17577) * Added an e2e test: creates a connection, then edits the schedule type * Schedule types successfully tested! * Removing .only * Prefix testing * Analytics calls fire as expected * Strict connection save check for schedule type * better check * Fixing failing tests * Lake CR * Update airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts * Can't test --- .../cypress/integration/connection.spec.ts | 106 +++++++++++++++--- 1 file changed, 93 insertions(+), 13 deletions(-) diff --git a/airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts b/airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts index 2bcecf91b023e..6750d7b186277 100644 --- a/airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts +++ b/airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts @@ -14,6 +14,7 @@ import { } from "pages/replicationPage"; import { openSourceDestinationFromGrid, goToSourcePage } from "pages/sourcePage"; import { goToSettingsPage } from "pages/settingsConnectionPage"; +import { update } from "cypress/types/lodash"; describe("Connection main actions", () => { beforeEach(() => { @@ -22,7 +23,7 @@ describe("Connection main actions", () => { it("Create new connection", () => { const sourceName = appendRandomString("Test connection source cypress"); - const destName = appendRandomString("Test connection destination cypress") + const destName = appendRandomString("Test connection destination cypress"); createTestConnection(sourceName, destName); @@ -66,12 +67,9 @@ describe("Connection main actions", () => { cy.intercept("/api/v1/web_backend/connections/update").as("updateConnection"); const sourceName = appendRandomString("Test update connection PokeAPI source cypress"); - const destName = appendRandomString("Test update connection Local JSON destination cypress") + const destName = appendRandomString("Test update connection Local JSON destination cypress"); - createTestConnection( - sourceName, - destName - ); + createTestConnection(sourceName, destName); goToSourcePage(); openSourceDestinationFromGrid(sourceName); @@ -84,19 +82,27 @@ describe("Connection main actions", () => { setupDestinationNamespaceCustomFormat("_test"); selectFullAppendSyncMode(); + const prefix = "auto_test"; + fillOutDestinationPrefix(prefix); + + // Ensures the prefix is applied to the streams + assert(cy.get(`[title*="${prefix}"]`)); + submitButtonClick(); confirmStreamConfigurationChangedPopup(); cy.wait("@updateConnection").then((interception) => { assert.isNotNull(interception.response?.statusCode, "200"); expect(interception.request.method).to.eq("POST"); - expect(interception.request).property("body").to.contain({ - name: sourceName + " <> " + destName + "Connection name", - prefix: "auto_test", - namespaceDefinition: "customformat", - namespaceFormat: "${SOURCE_NAMESPACE}_test", - status: "active", - }); + expect(interception.request) + .property("body") + .to.contain({ + name: sourceName + " <> " + destName + "Connection name", + prefix: "auto_test", + namespaceDefinition: "customformat", + namespaceFormat: "${SOURCE_NAMESPACE}_test", + status: "active", + }); expect(interception.request.body.scheduleData.basicSchedule).to.contain({ units: 1, timeUnit: "hours", @@ -121,6 +127,80 @@ describe("Connection main actions", () => { deleteDestination(destName); }); + it("creates a connection, then edits the schedule type", () => { + const sourceName = appendRandomString("Test connection source cypress PokeAPI"); + const destName = appendRandomString("Test connection destination cypress"); + + createTestConnection(sourceName, destName); + + cy.get("div").contains(sourceName).should("exist"); + cy.get("div").contains(destName).should("exist"); + + openSourceDestinationFromGrid(sourceName); + + goToReplicationTab(); + + selectSchedule("Cron"); + submitButtonClick(); + checkSuccessResult(); + + selectSchedule("Manual"); + submitButtonClick(); + checkSuccessResult(); + + selectSchedule("Every hour"); + submitButtonClick(); + checkSuccessResult(); + + deleteSource(sourceName); + deleteDestination(destName); + }); + + it("Saving a connection's schedule type only changes expected values", () => { + cy.intercept("/api/v1/web_backend/connections/update").as("updateConnection"); + cy.intercept("/api/v1/web_backend/connections/get").as("getConnection"); + + const sourceName = appendRandomString("Test update connection PokeAPI source cypress"); + const destName = appendRandomString("Test update connection Local JSON destination cypress"); + + createTestConnection(sourceName, destName); + + goToSourcePage(); + openSourceDestinationFromGrid(sourceName); + openSourceDestinationFromGrid(`${sourceName} <> ${destName}`); + + let loadedConnection: any = null; // Should be a WebBackendConnectionRead + cy.wait("@getConnection").then((interception) => { + const { scheduleType: readScheduleType, scheduleData: readScheduleData, ...connectionRead } = interception.response?.body; + loadedConnection = connectionRead; + + expect(loadedConnection).not.to.eq(null); + expect(readScheduleType).to.eq("manual"); + expect(readScheduleData).to.eq(undefined); + }); + + goToReplicationTab(); + + selectSchedule("Every hour"); + submitButtonClick(); + + cy.wait("@updateConnection").then((interception) => { + // Schedule is pulled out here, but we don't do anything with is as it's legacy + const { scheduleType, scheduleData, schedule, ...connectionUpdate } = interception.response?.body; + expect(scheduleType).to.eq("basic"); + expect(scheduleData.basicSchedule).to.deep.eq({ + timeUnit: "hours", + units: 1, + }); + + expect(loadedConnection).to.deep.eq(connectionUpdate); + }); + checkSuccessResult(); + + deleteSource(sourceName); + deleteDestination(destName); + }); + it("Delete connection", () => { const sourceName = "Test delete connection source cypress"; const destName = "Test delete connection destination cypress";