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

Add tests for checking Unsaved changes modal #19080

Merged
merged 8 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
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
71 changes: 66 additions & 5 deletions airbyte-webapp-e2e-tests/cypress/integration/source.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { appendRandomString } from "commands/common";
import { appendRandomString, submitButtonClick } from "commands/common";
import { createPostgresSource, deleteSource, updateSource } from "commands/source";
import { initialSetupCompleted } from "commands/workspaces";
import { goToSourcePage, openNewSourceForm } from "pages/sourcePage";
import { openHomepage } from "pages/sidebar";
import { selectServiceType } from "pages/createConnectorPage";
import { fillPokeAPIForm } from "commands/connector";

describe("Source main actions", () => {
beforeEach(() => {
initialSetupCompleted();
});
beforeEach(() => initialSetupCompleted());

it("Create new source", () => {
cy.intercept("/api/v1/sources/create").as("createSource");
createPostgresSource("Test source cypress");

cy.url().should("include", `/source/`);
cy.wait("@createSource", {timeout: 30000}).then((interception) => {
assert("include", `/source/${interception.response?.body.Id}`)});
});

//TODO: add update source on some other connector or create 1 more user for pg
Expand All @@ -32,3 +36,60 @@ describe("Source main actions", () => {
cy.get("div").contains(sourceName).should("not.exist");
});
});

describe("Unsaved changes modal", () => {
beforeEach(() => initialSetupCompleted());

it("Check leaving Source page without any changes", () => {
goToSourcePage();
openNewSourceForm();

openHomepage();

cy.url().should("include", "/onboarding");
dizel852 marked this conversation as resolved.
Show resolved Hide resolved
cy.get("[data-testid='confirmationModal']").should("not.exist");
});

it("Check leaving Source page without any changes after selection type", () => {
goToSourcePage();
openNewSourceForm();
selectServiceType("PokeAPI");

openHomepage();

cy.url().should("include", "/onboarding");
cy.get("[data-testid='confirmationModal']").should("not.exist");
});

it("Check leaving Source page without any changes", () => {
goToSourcePage();
openNewSourceForm();
fillPokeAPIForm("testName", "ditto");

openHomepage();

cy.get("[data-testid='confirmationModal']").should("exist");
cy.get("[data-testid='confirmationModal']").contains("Discard changes");
cy.get("[data-testid='confirmationModal']")
.contains("There are unsaved changes. Are you sure you want to discard your changes?");
});

//BUG - https://github.com/airbytehq/airbyte/issues/18246
it.skip("Check leaving Source page after failing testing", () => {
cy.intercept("/api/v1/scheduler/sources/check_connection").as("checkSourceUpdateConnection");

goToSourcePage();
openNewSourceForm();
fillPokeAPIForm("testName", "name");
submitButtonClick();

cy.wait("@checkSourceUpdateConnection", {timeout: 5000});

openHomepage();

cy.get("[data-testid='confirmationModal']").should("exist");
cy.get("[data-testid='confirmationModal']").contains("Discard changes");
cy.get("[data-testid='confirmationModal']")
.contains("There are unsaved changes. Are you sure you want to discard your changes?");
});
});
5 changes: 5 additions & 0 deletions airbyte-webapp-e2e-tests/cypress/pages/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const setting = "nav a[href*='settings']";
const homepage = "[aria-label='Homepage']";

export const openSettings = () => {
cy.get(setting).click();
};

export const openHomepage = () => {
cy.get(homepage).click();
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
const onSubmitBtnClick = () => startAction({ action: () => onSubmit() });

return (
<Modal onClose={onClose} title={<FormattedMessage id={title} />}>
<Modal onClose={onClose} title={<FormattedMessage id={title} />} testId="confirmationModal">
<div className={styles.content}>
<FormattedMessage id={text} />
<div className={styles.buttonContent}>
Expand Down