Skip to content

Commit

Permalink
Intercept /talks/new route to avoid flaky test
Browse files Browse the repository at this point in the history
This is due to the form not being completely loaded while we
already go on.
  • Loading branch information
Splines committed Nov 9, 2024
1 parent cc82b94 commit 68e161d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions spec/cypress/e2e/lectures_people_select_specs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ function shouldNotContainUserInOptions(selector, user) {
}

describe("Seminar speakers (new talk)", () => {
function openTalkForm() {
cy.intercept("GET", "/talks/new*").as("newTalk");
cy.getBySelector("new-talk-btn").click();
cy.getBySelector("talk-form").should("be.visible");
cy.wait("@newTalk");
}

beforeEach(function () {
cy.createUser("generic").as("user");
cy.createUserAndLogin("teacher").as("teacher");
Expand All @@ -131,8 +138,7 @@ describe("Seminar speakers (new talk)", () => {
context("when logged in as teacher", () => {
it("prohibits searching for arbitrary users in the speakers dropdown", function () {
cy.visit(this.seminarUrl);
cy.getBySelector("new-talk-btn").click();
cy.getBySelector("talk-form").should("be.visible");
openTalkForm();
shouldNotContainUserInOptions("speaker-select", this.user);
typeCyInInput("speaker-select-div", false);
shouldContainUsers("speaker-select-div", this, false, true);
Expand All @@ -147,8 +153,7 @@ describe("Seminar speakers (new talk)", () => {

it("allows searching for arbitrary users to assign them as speakers", function () {
cy.visit(this.seminarUrl);
cy.getBySelector("new-talk-btn").click();
cy.getBySelector("talk-form").should("be.visible");
openTalkForm();
typeCyInInput("speaker-select-div");
shouldContainUsers("speaker-select-div", this, true, true);
});
Expand Down

0 comments on commit 68e161d

Please sign in to comment.