Skip to content

Commit 0a6388d

Browse files
SofiiaZaitsevaakashkulk
authored andcommitted
Add tests for checking Unsaved changes modal (#19080)
add tests
1 parent e46b281 commit 0a6388d

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

airbyte-webapp-e2e-tests/cypress/integration/source.spec.ts

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import { appendRandomString } from "commands/common";
1+
import { appendRandomString, submitButtonClick } from "commands/common";
22
import { createPostgresSource, deleteSource, updateSource } from "commands/source";
33
import { initialSetupCompleted } from "commands/workspaces";
4+
import { goToSourcePage, openNewSourceForm } from "pages/sourcePage";
5+
import { openHomepage } from "pages/sidebar";
6+
import { selectServiceType } from "pages/createConnectorPage";
7+
import { fillPokeAPIForm } from "commands/connector";
48

59
describe("Source main actions", () => {
6-
beforeEach(() => {
7-
initialSetupCompleted();
8-
});
10+
beforeEach(() => initialSetupCompleted());
911

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

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

1620
//TODO: add update source on some other connector or create 1 more user for pg
@@ -32,3 +36,60 @@ describe("Source main actions", () => {
3236
cy.get("div").contains(sourceName).should("not.exist");
3337
});
3438
});
39+
40+
describe("Unsaved changes modal", () => {
41+
beforeEach(() => initialSetupCompleted());
42+
43+
it("Check leaving Source page without any changes", () => {
44+
goToSourcePage();
45+
openNewSourceForm();
46+
47+
openHomepage();
48+
49+
cy.url().should("include", "/onboarding");
50+
cy.get("[data-testid='confirmationModal']").should("not.exist");
51+
});
52+
53+
it("Check leaving Source page without any changes after selection type", () => {
54+
goToSourcePage();
55+
openNewSourceForm();
56+
selectServiceType("PokeAPI");
57+
58+
openHomepage();
59+
60+
cy.url().should("include", "/onboarding");
61+
cy.get("[data-testid='confirmationModal']").should("not.exist");
62+
});
63+
64+
it("Check leaving Source page without any changes", () => {
65+
goToSourcePage();
66+
openNewSourceForm();
67+
fillPokeAPIForm("testName", "ditto");
68+
69+
openHomepage();
70+
71+
cy.get("[data-testid='confirmationModal']").should("exist");
72+
cy.get("[data-testid='confirmationModal']").contains("Discard changes");
73+
cy.get("[data-testid='confirmationModal']")
74+
.contains("There are unsaved changes. Are you sure you want to discard your changes?");
75+
});
76+
77+
//BUG - https://github.com/airbytehq/airbyte/issues/18246
78+
it.skip("Check leaving Source page after failing testing", () => {
79+
cy.intercept("/api/v1/scheduler/sources/check_connection").as("checkSourceUpdateConnection");
80+
81+
goToSourcePage();
82+
openNewSourceForm();
83+
fillPokeAPIForm("testName", "name");
84+
submitButtonClick();
85+
86+
cy.wait("@checkSourceUpdateConnection", {timeout: 5000});
87+
88+
openHomepage();
89+
90+
cy.get("[data-testid='confirmationModal']").should("exist");
91+
cy.get("[data-testid='confirmationModal']").contains("Discard changes");
92+
cy.get("[data-testid='confirmationModal']")
93+
.contains("There are unsaved changes. Are you sure you want to discard your changes?");
94+
});
95+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const setting = "nav a[href*='settings']";
2+
const homepage = "[aria-label='Homepage']";
23

34
export const openSettings = () => {
45
cy.get(setting).click();
56
};
7+
8+
export const openHomepage = () => {
9+
cy.get(homepage).click();
10+
};

airbyte-webapp/src/components/common/ConfirmationModal/ConfirmationModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
3030
const onSubmitBtnClick = () => startAction({ action: () => onSubmit() });
3131

3232
return (
33-
<Modal onClose={onClose} title={<FormattedMessage id={title} />}>
33+
<Modal onClose={onClose} title={<FormattedMessage id={title} />} testId="confirmationModal">
3434
<div className={styles.content}>
3535
<FormattedMessage id={text} />
3636
<div className={styles.buttonContent}>

0 commit comments

Comments
 (0)