Skip to content

Commit

Permalink
Add test to verify non-breaking prefrence update
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundito committed Jan 18, 2023
1 parent 5ed91e2 commit e6c3723
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ import { runDbQuery } from "commands/db/db";
import { alterTable, createUsersTableQuery, dropUsersTableQuery } from "commands/db/queries";
import { initialSetupCompleted } from "commands/workspaces";
import { getSyncEnabledSwitch, visitConnectionPage } from "pages/connectionPage";
import {
getManualSyncButton,
getNonBreakingChangeIcon,
getSchemaChangeIcon,
visitConnectionsListPage,
} from "pages/connnectionsListPage";
import { getManualSyncButton, getSchemaChangeIcon, visitConnectionsListPage } from "pages/connnectionsListPage";
import { checkCatalogDiffModal, clickCatalogDiffCloseButton } from "pages/modals/catalogDiffModal";
import {
checkSchemaChangesDetected,
Expand All @@ -32,10 +27,11 @@ import {
clickSchemaChangesReviewButton,
searchStream,
selectCursorField,
selectNonBreakingChangesPreference,
selectSyncMode,
} from "pages/replicationPage";

describe("Auto-detect schema changes", () => {
describe("Connection - Auto-detect schema changes", () => {
let source: Source;
let destination: Destination;
let connection: Connection;
Expand Down Expand Up @@ -154,4 +150,19 @@ describe("Auto-detect schema changes", () => {
getSyncEnabledSwitch().should("be.enabled");
});
});

describe("non-breaking schema update preference", () => {
it("saves non-breaking schema update preference change", () => {
visitConnectionPage(connection, "replication");
selectNonBreakingChangesPreference("disable");

cy.intercept("/api/v1/web_backend/connections/update").as("updatesNonBreakingPreference");

clickSaveReplication({ confirm: false });

cy.wait("@updatesNonBreakingPreference").then((interception) => {
assert.equal((interception.response?.body as Connection).nonBreakingChangesPreference, "disable");
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Connection } from "commands/api/types";
import { getWorkspaceId } from "commands/api/workspace";

const statusCell = (connectionId: string) => `[data-testId='statusCell-${connectionId}']`;
const changesStatusIcon = (type: string) => `[data-testId='changesStatusIcon-${type}']`;
const manualSyncButton = "button[data-testId='manual-sync-button']";

export const visitConnectionsListPage = () => {
cy.intercept("**/web_backend/connections/list").as("listConnections");
cy.visit(`/workspaces/${getWorkspaceId()}/connections`);
cy.wait("@listConnections");
};

export const getSchemaChangeIcon = (connection: Connection, type: "breaking" | "non_breaking") =>
cy.get(`[data-testId='statusCell-${connection.connectionId}'] [data-testId='changesStatusIcon-${type}']`);
cy.get(`${statusCell(connection.connectionId)} ${changesStatusIcon(type)}`);

export const getManualSyncButton = (connection: Connection) =>
cy.get(`[data-testId='statusCell-${connection.connectionId}'] button[data-testId='manual-sync-button']`);
cy.get(`${statusCell(connection.connectionId)} ${manualSyncButton}`);
13 changes: 11 additions & 2 deletions airbyte-webapp-e2e-tests/cypress/pages/replicationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const streamNameInput = "input[data-testid='input']";
const schemaChangesDetectedBanner = "[data-testid='schemaChangesDetected']";
const schemaChangesReviewButton = "[data-testid='schemaChangesReviewButton']";
const schemaChangesBackdrop = "[data-testid='schemaChangesBackdrop']";
const nonBreakingChangesPreference = "[data-testid='nonBreakingChangesPreference']";
const nonBreakingChangesPreferenceValue = (value: string) => `div[data-testid='nonBreakingChangesPreference-${value}']`;

export const goToReplicationTab = () => {
cy.get(replicationTab).click();
Expand Down Expand Up @@ -122,12 +124,14 @@ export const searchStream = (value: string) => {
cy.get(streamNameInput).type(value);
};

export const clickSaveReplication = ({ reset = false } = {}) => {
export const clickSaveReplication = ({ reset = false, confirm = true } = {}) => {
cy.intercept("/api/v1/web_backend/connections/update").as("updateConnection");

submitButtonClick();

confirmStreamConfigurationChangedPopup({ reset });
if (confirm) {
confirmStreamConfigurationChangedPopup({ reset });
}

cy.wait("@updateConnection").then((interception) => {
assert.isNotNull(interception.response?.statusCode, "200");
Expand Down Expand Up @@ -168,3 +172,8 @@ export const clickSchemaChangesReviewButton = () => {
cy.get(schemaChangesReviewButton).click();
// cy.get(schemaChangesReviewButton).should("be.disabled");
};

export const selectNonBreakingChangesPreference = (preference: "ignore" | "disable") => {
cy.get(nonBreakingChangesPreference).click();
cy.get(nonBreakingChangesPreferenceValue(preference)).click();
};

0 comments on commit e6c3723

Please sign in to comment.