Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafpaf committed Dec 20, 2023
1 parent 5b341c2 commit f9f6bb1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
53 changes: 25 additions & 28 deletions e2e/test/scenarios/sharing/alert/email-alert.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ describe("scenarios > alert > email_alert", { tags: "@external" }, () => {

saveAlert();

cy.findByTestId("toast-undo").within(() => {
cy.findByText("Your alert is all set up.").should("be.visible");
});
cy.findByTestId("toast-undo")
.findByText("Your alert is all set up.")
.should("be.visible");

cy.wait("@savedAlert").then(({ response: { body } }) => {
expect(body.channels[0].channel_type).to.eq("email");
Expand All @@ -86,9 +86,9 @@ describe("scenarios > alert > email_alert", { tags: "@external" }, () => {
cy.log("Check that /api/card has been called once");
cy.get("@saveCard.all").should("have.length", 1);

cy.findByTestId("toast-undo").within(() => {
cy.findByText("Your alert is all set up.").should("be.visible");
});
cy.findByTestId("toast-undo")
.findByText("Your alert is all set up.")
.should("be.visible");

clickAlertBell();

Expand All @@ -99,21 +99,21 @@ describe("scenarios > alert > email_alert", { tags: "@external" }, () => {

cy.log("Change the frequency of the alert to weekly");

cy.get(".Modal--full").within(() => {
cy.findByText("How often should we check for results?")
.parent()
.parent()
.within(() => {
const buttons = cy.findAllByTestId("select-button");
buttons.should("have.length", 2);
buttons.eq(0).click();
});
});

const weekly = cy.findByRole("option", { name: "Weekly" });
weekly.should("have.attr", "aria-selected", "false");
weekly.click();
cy.findByRole("button", { name: "Save changes" }).click();
cy.findByRole("dialog", { name: "Edit your alert" })
.findByText("How often should we check for results?")
.parent()
.parent()
.within(() => {
cy.findAllByTestId("select-button")
.should("have.length", 2)
.eq(0)
.click();
});

cy.findByRole("option", { name: "Weekly" })
.should("have.attr", "aria-selected", "false")
.click();
cy.button("Save changes").click();

cy.log("Check that /api/card has still only been called once");
cy.get("@saveCard.all").should("have.length", 1);
Expand All @@ -123,7 +123,6 @@ describe("scenarios > alert > email_alert", { tags: "@external" }, () => {
function openAlertForQuestion(id) {
visitQuestion(id);
cy.icon("bell").click();

cy.findByText("Set up an alert").click();
}

Expand All @@ -132,23 +131,21 @@ function toggleChannel(channel) {
}

function clickAlertBell() {
cy.findByTestId("view-footer").within(() => {
cy.icon("bell").click();
});
cy.findByTestId("view-footer").icon("bell").click();
}

function saveAlert() {
clickAlertBell();

cy.findByRole("dialog").within(() => {
cy.findByLabelText("Name").type(" alert");
cy.findByRole("button", { name: "Save" }).click();
cy.button("Save").click();
});

cy.wait("@saveCard");

cy.findByTestId("alert-education-screen").within(() => {
cy.findByRole("button", { name: "Set up an alert" }).click();
cy.button("Set up an alert").click();
});
cy.findByRole("button", { name: "Done" }).click();
cy.button("Done").click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export default class ModalContent extends Component<ModalContentProps> {
{ pb4: formModal && !footer },
)}
data-testid={dataTestId}
aria-labelledby={title}
role="dialog"
aria-modal="true"
>
{title && (
<ModalHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class UpdateAlertModalContentInner extends Component {

// TODO: Remove PulseEdit css hack
return (
<ModalContent onClose={onCancel}>
<ModalContent onClose={onCancel} title={title}>
<div
className="PulseEdit ml-auto mr-auto mb4"
style={{ maxWidth: "550px" }}
Expand Down

0 comments on commit f9f6bb1

Please sign in to comment.