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

Commit b20ceec

Browse files
committed
Optimize a test to check default buttons
Signed-off-by: Suguru Hirahara <[email protected]>
1 parent de2dd1c commit b20ceec

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

cypress/e2e/room/room-header.spec.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,28 @@ describe("Room Header", () => {
3333
cy.stopHomeserver(homeserver);
3434
});
3535

36-
it("should render seven buttons by default", () => {
36+
it("should render default buttons properly", () => {
3737
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room");
3838

3939
cy.get(".mx_RoomHeader").within(() => {
40-
cy.findAllByRole("button").should("have.length", 7).should("be.visible");
41-
42-
cy.findByRole("button", { name: "Room options" }).should("be.visible");
43-
cy.findByRole("button", { name: "Voice call" }).should("be.visible");
44-
cy.findByRole("button", { name: "Video call" }).should("be.visible");
45-
cy.findByRole("button", { name: "Search" }).should("be.visible");
46-
cy.findByRole("button", { name: "Threads" }).should("be.visible");
47-
cy.findByRole("button", { name: "Notifications" }).should("be.visible");
48-
cy.findByRole("button", { name: "Room info" }).should("be.visible");
40+
// Names (aria-label) of every button rendered on mx_RoomHeader by default
41+
const expectedButtonNames = [
42+
"Room options", // The room name button next to the room avatar, which renders dropdown menu on click
43+
"Voice call",
44+
"Video call",
45+
"Search",
46+
"Threads",
47+
"Notifications",
48+
"Room info",
49+
];
50+
51+
// Assert they are found and visible
52+
for (const name of expectedButtonNames) {
53+
cy.findByRole("button", { name }).should("be.visible");
54+
}
55+
56+
// Assert that just those seven buttons exist on mx_RoomHeader by default
57+
cy.findAllByRole("button").should("have.length", 7);
4958
});
5059

5160
cy.get(".mx_RoomHeader").percySnapshotElement("Room header");

0 commit comments

Comments
 (0)