Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update spotlight.spec.ts - use Cypress Testing Library #10621

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cypress/e2e/spotlight/spotlight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Cypress.Commands.add(
Cypress.Commands.add(
"spotlightSearch",
(options?: Partial<Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery<HTMLElement>> => {
return cy.get(".mx_SpotlightDialog_searchBox input", options);
return cy.get(".mx_SpotlightDialog_searchBox", options).findByRole("textbox", { name: "Search" });
},
);

Expand Down Expand Up @@ -129,10 +129,10 @@ Cypress.Commands.add("startDM", (name: string) => {
cy.spotlightResults().eq(0).click();
});
// send first message to start DM
cy.get(".mx_BasicMessageComposer_input").should("have.focus").type("Hey!{enter}");
cy.findByRole("textbox", { name: "Send a message…" }).should("have.focus").type("Hey!{enter}");
// The DM room is created at this point, this can take a little bit of time
cy.contains(".mx_EventTile_body", "Hey!", { timeout: 30000 });
cy.contains(".mx_RoomSublist[aria-label=People]", name);
cy.get(".mx_EventTile_body", { timeout: 30000 }).findByText("Hey!");
cy.findByRole("group", { name: "People" }).findByText(name);
});

describe("Spotlight", () => {
Expand Down Expand Up @@ -290,7 +290,7 @@ describe("Spotlight", () => {
cy.url().should("contain", room3Id);
})
.then(() => {
cy.get(".mx_RoomPreviewBar_actions .mx_AccessibleButton").click();
cy.findByRole("button", { name: "Join the discussion" }).click();
cy.roomHeaderName().should("contain", room3Name);
});
});
Expand Down Expand Up @@ -365,11 +365,11 @@ describe("Spotlight", () => {

// Send first message to actually start DM
cy.roomHeaderName().should("contain", bot2Name);
cy.get(".mx_BasicMessageComposer_input").click().should("have.focus").type("Hey!{enter}");
cy.findByRole("textbox", { name: "Send a message…" }).type("Hey!{enter}");

// Assert DM exists by checking for the first message and the room being in the room list
cy.contains(".mx_EventTile_body", "Hey!", { timeout: 30000 });
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", bot2Name);
cy.findByRole("group", { name: "People" }).should("contain", bot2Name);

// Invite BotBob into existing DM with ByteBot
cy.getDmRooms(bot2.getUserId())
Expand All @@ -378,7 +378,7 @@ describe("Spotlight", () => {
.then((groupDm) => {
cy.inviteUser(groupDm.roomId, bot1.getUserId());
cy.roomHeaderName().should(($element) => expect($element.get(0).innerText).contains(groupDm.name));
cy.get(".mx_RoomSublist[aria-label=People]").should(($element) =>
cy.findByRole("group", { name: "People" }).should(($element) =>
expect($element.get(0).innerText).contains(groupDm.name),
);

Expand Down Expand Up @@ -440,7 +440,7 @@ describe("Spotlight", () => {
cy.get(".mx_SpotlightDialog_startGroupChat").click();
})
.then(() => {
cy.get("[role=dialog]").should("contain", "Direct Messages");
cy.findByRole("dialog").should("contain", "Direct Messages");
});
});

Expand Down