Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve E2E testing around the Connection Form #17577

Merged
merged 15 commits into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was added in response to a specific OC bug 👍

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, do we have any plans to pull in types from the airbyte-webapp module in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what it would entail to do so. It might be trivial but no, I don't think we have a plan to do so. I wouldn't mind though.

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