parent
ba90e0b255
commit
d9d0b84152
3 changed files with 13 additions and 28 deletions
|
@ -345,7 +345,8 @@ describe("Spotlight", () => {
|
||||||
cy.spotlightFilter(Filter.People);
|
cy.spotlightFilter(Filter.People);
|
||||||
cy.spotlightSearch().clear().type(bot2Name);
|
cy.spotlightSearch().clear().type(bot2Name);
|
||||||
cy.spotlightResults().should("have.length", 1);
|
cy.spotlightResults().should("have.length", 1);
|
||||||
cy.spotlightResults().contains(bot2Name).click();
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
||||||
|
cy.spotlightResults().eq(0).click();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.roomHeaderName().should("contain", bot2Name);
|
cy.roomHeaderName().should("contain", bot2Name);
|
||||||
|
@ -360,7 +361,9 @@ describe("Spotlight", () => {
|
||||||
cy.openSpotlightDialog().within(() => {
|
cy.openSpotlightDialog().within(() => {
|
||||||
cy.spotlightFilter(Filter.People);
|
cy.spotlightFilter(Filter.People);
|
||||||
cy.spotlightSearch().clear().type(bot2Name);
|
cy.spotlightSearch().clear().type(bot2Name);
|
||||||
cy.spotlightResults().contains(bot2Name).click();
|
cy.spotlightResults().should("have.length", 1);
|
||||||
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
||||||
|
cy.spotlightResults().eq(0).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send first message to actually start DM
|
// Send first message to actually start DM
|
||||||
|
@ -387,10 +390,11 @@ describe("Spotlight", () => {
|
||||||
cy.spotlightFilter(Filter.People);
|
cy.spotlightFilter(Filter.People);
|
||||||
cy.spotlightSearch().clear().type(bot1.getUserId());
|
cy.spotlightSearch().clear().type(bot1.getUserId());
|
||||||
cy.wait(1000); // wait for the dialog code to settle
|
cy.wait(1000); // wait for the dialog code to settle
|
||||||
|
cy.spotlightResults().should("have.length", 2);
|
||||||
cy.contains(
|
cy.contains(
|
||||||
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
||||||
groupDm.name,
|
groupDm.name,
|
||||||
).should("exist");
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Search for ByteBot by id, should return group DM and user
|
// Search for ByteBot by id, should return group DM and user
|
||||||
|
@ -398,10 +402,11 @@ describe("Spotlight", () => {
|
||||||
cy.spotlightFilter(Filter.People);
|
cy.spotlightFilter(Filter.People);
|
||||||
cy.spotlightSearch().clear().type(bot2.getUserId());
|
cy.spotlightSearch().clear().type(bot2.getUserId());
|
||||||
cy.wait(1000); // wait for the dialog code to settle
|
cy.wait(1000); // wait for the dialog code to settle
|
||||||
|
cy.spotlightResults().should("have.length", 2);
|
||||||
cy.contains(
|
cy.contains(
|
||||||
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
||||||
groupDm.name,
|
groupDm.name,
|
||||||
).should("exist");
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -431,7 +436,9 @@ describe("Spotlight", () => {
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.spotlightFilter(Filter.People);
|
cy.spotlightFilter(Filter.People);
|
||||||
cy.spotlightSearch().clear().type(bot2Name);
|
cy.spotlightSearch().clear().type(bot2Name);
|
||||||
cy.spotlightResults().should("contain", bot2Name);
|
cy.wait(3000); // wait for the dialog code to settle
|
||||||
|
cy.spotlightResults().should("have.length", 1);
|
||||||
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
||||||
cy.get(".mx_SpotlightDialog_startGroupChat").should("contain", "Start a group chat");
|
cy.get(".mx_SpotlightDialog_startGroupChat").should("contain", "Start a group chat");
|
||||||
cy.get(".mx_SpotlightDialog_startGroupChat").click();
|
cy.get(".mx_SpotlightDialog_startGroupChat").click();
|
||||||
})
|
})
|
||||||
|
|
|
@ -399,8 +399,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
)
|
)
|
||||||
return; // bail, does not match query
|
return; // bail, does not match query
|
||||||
} else if (isMemberResult(entry)) {
|
} else if (isMemberResult(entry)) {
|
||||||
// Do not filter users as we rely on the server to filter them for us.
|
if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query
|
||||||
// The server may filter based on fields we do not have access to, e.g. e-mail addresses.
|
|
||||||
} else if (isPublicRoomResult(entry)) {
|
} else if (isPublicRoomResult(entry)) {
|
||||||
if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query
|
if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -338,27 +338,6 @@ describe("Spotlight Dialog", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not filter out users sent by the server", async () => {
|
|
||||||
mocked(mockedClient.searchUserDirectory).mockResolvedValue({
|
|
||||||
results: [
|
|
||||||
{ user_id: "@user1:server", display_name: "User Alpha", avatar_url: "mxc://1/avatar" },
|
|
||||||
{ user_id: "@user2:server", display_name: "User Beta", avatar_url: "mxc://2/avatar" },
|
|
||||||
],
|
|
||||||
limited: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<SpotlightDialog initialFilter={Filter.People} initialText="Alpha" onFinished={() => null} />);
|
|
||||||
// search is debounced
|
|
||||||
jest.advanceTimersByTime(200);
|
|
||||||
await flushPromisesWithFakeTimers();
|
|
||||||
|
|
||||||
const content = document.querySelector("#mx_SpotlightDialog_content")!;
|
|
||||||
const options = content.querySelectorAll("li.mx_SpotlightDialog_option");
|
|
||||||
expect(options.length).toBeGreaterThanOrEqual(2);
|
|
||||||
expect(options[0]).toHaveTextContent("User Alpha");
|
|
||||||
expect(options[1]).toHaveTextContent("User Beta");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should start a DM when clicking a person", async () => {
|
it("should start a DM when clicking a person", async () => {
|
||||||
render(
|
render(
|
||||||
<SpotlightDialog
|
<SpotlightDialog
|
||||||
|
|
Loading…
Reference in a new issue