Skip to content

Commit

Permalink
Improve E2E testing around the Connection Form (airbytehq#17577)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
krishnaglick authored and jhammarstedt committed Oct 31, 2022
1 parent 7a63f59 commit b75804a
Showing 1 changed file with 93 additions and 13 deletions.
106 changes: 93 additions & 13 deletions airbyte-webapp-e2e-tests/cypress/integration/connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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",
Expand All @@ -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";
Expand Down

0 comments on commit b75804a

Please sign in to comment.