-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add tests for checking Unsaved changes modal #19080
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
Changes from 5 commits
05e1cb9
c8f9c7d
d65c8a5
14093b4
2985c27
0637191
921148d
972f211
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
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"; | ||
import { should } from "chai"; | ||
|
||
|
||
describe("Source main actions", () => { | ||
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)}); | ||
|
||
//cy.url().should("include", `/source/`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does assert("include", `/source/${interception.response?.body.Id}`)` assert against the url? (As an aside, if you're using backticks, you can insert values into the string with code, like cy.wait("@createSource", { timeout: 30000 }).then((interception) => {
cy.url().should("include", `/source/${interception.response?.body.Id}`);
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, that's actually my suggestion during short sync with @SofiiaZaitseva. After connector creation, we aim to check that we were redirected to the "Overview" page. |
||
}); | ||
|
||
//TODO: add update source on some other connector or create 1 more user for pg | ||
|
@@ -32,3 +42,60 @@ describe("Source main actions", () => { | |
cy.get("div").contains(sourceName).should("not.exist"); | ||
}); | ||
}); | ||
|
||
describe("Unsaved changes modal", () => { | ||
beforeEach(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor detail: there's no need for the anonymous wrapper function ( // all three of these do the same thing in the context of a test
beforeEach(() => {
initialSetupCompleted();
})
// and these last two behave exactly the same in every way
beforeEach(() => initialSetupCompleted());
// but this one is the shortest and cleanest
beforeEach(initialSetupCompleted); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used beforeEach(() => initialSetupCompleted()); due to initialSetupCompleted has optional parameter and cannot be used in this beforeEach(initialSetupCompleted); way |
||
initialSetupCompleted(); | ||
}); | ||
|
||
it("Check leaving Source page without any changes", () => { | ||
goToSourcePage(); | ||
openNewSourceForm(); | ||
|
||
openHomepage(); | ||
|
||
cy.url().should("include", `/onboarding`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use the same style of quotes throughout, unless you're using the interpolation feature of the backtick strings |
||
}); | ||
|
||
it("Check leaving Source page without any changes after selection type", () => { | ||
goToSourcePage(); | ||
openNewSourceForm(); | ||
selectServiceType("PokeAPI"); | ||
|
||
openHomepage(); | ||
|
||
cy.url().should("include", `/onboarding`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consistent quote marks again |
||
}); | ||
|
||
it("Check leaving Source page without any changes", () => { | ||
goToSourcePage(); | ||
openNewSourceForm(); | ||
fillPokeAPIForm("testName", "ditto"); | ||
|
||
openHomepage(); | ||
|
||
cy.get("#headlessui-portal-root h5").should("exist"); | ||
cy.get("#headlessui-portal-root h5").should("have.text", "Discard changes"); | ||
cy.get("#headlessui-portal-root [class*='ConfirmationModal_content']") | ||
.should("have.text", "There are unsaved changes. Are you sure you want to discard your changes?CancelDiscard 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("#headlessui-portal-root h5").should("exist"); | ||
cy.get("#headlessui-portal-root h5").should("have.text", "Discard changes"); | ||
cy.get("#headlessui-portal-root [class*='ConfirmationModal_content']") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These selectors are a bit brittle: if we ever stop using the headlessui library for this modal or use a different level heading than In this case, I would make the following changes:
<Modal onClose={onClose} title={<FormattedMessage id={title} />} data-testid="confirmationModal">
{/* rest of modal implementation */}
</Modal>
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed, thanks! |
||
.should("have.text", "There are unsaved changes. Are you sure you want to discard your changes?CancelDiscard changes"); | ||
}); | ||
}); |
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(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
{ should }
import is unused, and should be removed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed