Skip to content

Commit c2911d5

Browse files
committed
Fix cypress conditions to allow retry
1 parent 5a21b5f commit c2911d5

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

cypress/e2e/section/coordinator-section.cy.ts

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ describe("modifying students", () => {
182182
cy.get("input[type='checkbox'][value='DROP']").should("have.length", 1).should("be.disabled");
183183

184184
// remove email
185-
cy.get("span.inline-plus-sign").click().should("not.exist");
185+
cy.get("span.inline-plus-sign").clickUntil($el => {
186+
expect($el).to.not.exist;
187+
});
186188
});
187189
// should disappear after click
188190
cy.contains(".coordinator-email-response-item", USERNAME).should("not.exist");
@@ -211,36 +213,36 @@ describe("modifying students", () => {
211213
cy.wait("@section-students");
212214
cy.get(".coordinator-email-modal-button").click();
213215

214-
cy.get(".coordinator-add-student-modal")
215-
.within(() => {
216-
cy.get(".coordinator-email-input").type(USERNAME);
217-
cy.get(".coordinator-email-input-submit").click();
218-
219-
// wait for request; should fail
220-
cy.wait("@add-student").its("response.statusCode").should("eq", 422);
221-
222-
cy.contains(".coordinator-email-response-container", /section conflict/i).within(() => {
223-
// should display section conflict
224-
cy.contains(".coordinator-email-response-status-conflict", /section conflict/i).should("be.visible");
225-
226-
cy.contains(".coordinator-email-response-item", USERNAME).within(() => {
227-
// check text objects
228-
cy.contains("span", USERNAME).should("be.visible");
229-
cy.contains("div", /conflict: user one/i)
230-
.should("be.visible")
231-
.find("a")
232-
.invoke("attr", "href")
233-
.should("eq", "/sections/2");
234-
235-
// drop student from other section
236-
cy.get("input[type='checkbox'][value='DROP']").should("have.length", 1).should("not.be.disabled").click();
237-
});
216+
cy.get(".coordinator-add-student-modal").within(() => {
217+
cy.get(".coordinator-email-input").type(USERNAME);
218+
cy.get(".coordinator-email-input-submit").click();
219+
220+
// wait for request; should fail
221+
cy.wait("@add-student").its("response.statusCode").should("eq", 422);
222+
223+
cy.contains(".coordinator-email-response-container", /section conflict/i).within(() => {
224+
// should display section conflict
225+
cy.contains(".coordinator-email-response-status-conflict", /section conflict/i).should("be.visible");
226+
227+
cy.contains(".coordinator-email-response-item", USERNAME).within(() => {
228+
// check text objects
229+
cy.contains("span", USERNAME).should("be.visible");
230+
cy.contains("div", /conflict: user one/i)
231+
.should("be.visible")
232+
.find("a")
233+
.invoke("attr", "href")
234+
.should("eq", "/sections/2");
235+
236+
// drop student from other section
237+
cy.get("input[type='checkbox'][value='DROP']").should("have.length", 1).should("not.be.disabled").click();
238238
});
239+
});
239240

240-
cy.contains(".coordinator-email-input-submit", /retry/i).click();
241-
cy.wait("@add-student").its("response.statusCode").should("eq", 200);
242-
})
243-
.should("not.exist"); // should disappear after click
241+
cy.contains(".coordinator-email-input-submit", /retry/i).click();
242+
cy.wait("@add-student").its("response.statusCode").should("eq", 200);
243+
});
244+
// should disappear after click
245+
cy.get(".coordinator-add-student-modal").should("not.exist");
244246

245247
cy.wait("@section-students");
246248

@@ -386,7 +388,9 @@ describe("modifying students", () => {
386388
cy.get("input[type='checkbox'][value='DROP']").should("have.length", 1).should("be.disabled");
387389

388390
// remove email
389-
cy.get("span.inline-plus-sign").click().should("not.exist");
391+
cy.get("span.inline-plus-sign").clickUntil($el => {
392+
expect($el).to.not.exist;
393+
});
390394
});
391395

392396
// mentor for another section

0 commit comments

Comments
 (0)