Don't show the same user twice in Spotlight (#8978)

Co-authored-by: Janne Mareike Koschinski <janne@kuschku.de>
This commit is contained in:
Šimon Brandner 2022-07-06 14:07:10 +02:00 committed by GitHub
parent 7afc8c5869
commit e65409861a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 5 deletions

View file

@ -55,6 +55,7 @@ declare global {
roomHeaderName(
options?: Partial<Loggable & Timeoutable & Withinable & Shadow>
): Chainable<JQuery<HTMLElement>>;
startDM(name: string): Chainable<void>;
}
}
}
@ -109,6 +110,20 @@ Cypress.Commands.add("roomHeaderName", (
return cy.get(".mx_RoomHeader_nametext", options);
});
Cypress.Commands.add("startDM", (name: string) => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(name);
cy.get(".mx_Spinner").should("not.exist");
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", name);
cy.spotlightResults().eq(0).click();
}).then(() => {
cy.roomHeaderName().should("contain", name);
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", name);
});
});
describe("Spotlight", () => {
let synapse: SynapseInstance;
@ -319,6 +334,23 @@ describe("Spotlight", () => {
});
});
it("should close spotlight after starting a DM", () => {
cy.startDM(bot1Name);
cy.get(".mx_SpotlightDialog").should("have.length", 0);
});
it("should show the same user only once", () => {
cy.startDM(bot1Name);
cy.visit("/#/home");
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1Name);
cy.get(".mx_Spinner").should("not.exist");
cy.spotlightResults().should("have.length", 1);
});
});
it("should be able to navigate results via keyboard", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);