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

Update room-directory.spec.ts - use Cypress Testing Library #10596

Merged
merged 2 commits 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
33 changes: 19 additions & 14 deletions cypress/e2e/room-directory/room-directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ describe("Room Directory", () => {

// First add a local address `gaming`
cy.contains(".mx_SettingsFieldset", "Local Addresses").within(() => {
cy.get(".mx_Field input").type("gaming");
cy.contains(".mx_AccessibleButton", "Add").click();
cy.get(".mx_EditableItem_item").should("contain", "#gaming:localhost");
cy.findByRole("textbox").type("gaming");
cy.findByRole("button", { name: "Add" }).click();
cy.findByText("#gaming:localhost").should("have.class", "mx_EditableItem_item").should("exist");
});

// Publish into the public rooms directory
cy.contains(".mx_SettingsFieldset", "Published Addresses").within(() => {
cy.get("#canonicalAlias").find(":selected").should("contain", "#gaming:localhost");
cy.get(`[aria-label="Publish this room to the public in localhost's room directory?"]`)
cy.get("#canonicalAlias").find(":selected").findByText("#gaming:localhost");
cy.findByLabelText("Publish this room to the public in localhost's room directory?")
.click()
.should("have.attr", "aria-checked", "true");
});
Expand All @@ -81,20 +81,25 @@ describe("Room Directory", () => {
});
});

cy.get('[role="button"][aria-label="Explore rooms"]').click();
cy.findByRole("button", { name: "Explore rooms" }).click();

cy.get('.mx_SpotlightDialog [aria-label="Search"]').type("Unknown Room");
cy.get(".mx_SpotlightDialog .mx_SpotlightDialog_otherSearches_messageSearchText").should(
"contain",
"can't find the room you're looking for",
);
cy.get(".mx_SpotlightDialog").within(() => {
cy.findByRole("textbox", { name: "Search" }).type("Unknown Room");
cy.findByText("If you can't find the room you're looking for, ask for an invite or create a new room.")
.should("have.class", "mx_SpotlightDialog_otherSearches_messageSearchText")
.should("exist");
});
cy.get(".mx_SpotlightDialog_wrapper").percySnapshotElement("Room Directory - filtered no results");

cy.get('.mx_SpotlightDialog [aria-label="Search"]').type("{selectAll}{backspace}test1234");
cy.contains(".mx_SpotlightDialog .mx_SpotlightDialog_result_publicRoomName", name).should("exist");
cy.get(".mx_SpotlightDialog").within(() => {
cy.findByRole("textbox", { name: "Search" }).type("{selectAll}{backspace}test1234");
cy.findByText(name).should("have.class", "mx_SpotlightDialog_result_publicRoomName").should("exist");
});

// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
//cy.get(".mx_SpotlightDialog_wrapper").percySnapshotElement("Room Directory - filtered one result");
cy.get(".mx_SpotlightDialog .mx_SpotlightDialog_option").find(".mx_AccessibleButton").contains("Join").click();

cy.get(".mx_SpotlightDialog .mx_SpotlightDialog_option").findByRole("button", { name: "Join" }).click();

cy.url().should("contain", `/#/room/#test1234:localhost`);
});
Expand Down