Address code smells from #30453 (#31083)

* check recents length

* Improve sorting logic in capabilities dialog

* Fix allowedHosts regex array check

* Remove double negative in filter checks

* prettier
This commit is contained in:
David Langley
2025-10-29 08:52:17 +00:00
committed by GitHub
parent 3e809cd661
commit 80a7de4314
7 changed files with 207 additions and 11 deletions
@@ -664,4 +664,39 @@ describe("Spotlight Dialog", () => {
}),
);
});
describe("keyboard prompt filter and query checks", () => {
it("should show left and right arrow keys in keyboard hint when filter is null and no query", async () => {
render(<SpotlightDialog onFinished={() => null} />);
jest.advanceTimersByTime(200);
await flushPromisesWithFakeTimers();
const keyboardPrompt = document.querySelector("#mx_SpotlightDialog_keyboardPrompt");
expect(keyboardPrompt).toBeInTheDocument();
expect(keyboardPrompt?.textContent).toContain("←");
expect(keyboardPrompt?.textContent).toContain("→");
});
it("should not show left and right arrow keys in keyboard hint when filter is set", async () => {
render(<SpotlightDialog initialFilter={Filter.People} onFinished={() => null} />);
jest.advanceTimersByTime(200);
await flushPromisesWithFakeTimers();
const keyboardPrompt = document.querySelector("#mx_SpotlightDialog_keyboardPrompt");
expect(keyboardPrompt).toBeInTheDocument();
expect(keyboardPrompt?.textContent).not.toContain("←");
expect(keyboardPrompt?.textContent).not.toContain("→");
});
it("should not show left and right arrow keys in keyboard hint when query is present", async () => {
render(<SpotlightDialog initialText="test query" onFinished={() => null} />);
jest.advanceTimersByTime(200);
await flushPromisesWithFakeTimers();
const keyboardPrompt = document.querySelector("#mx_SpotlightDialog_keyboardPrompt");
expect(keyboardPrompt).toBeInTheDocument();
expect(keyboardPrompt?.textContent).not.toContain("←");
expect(keyboardPrompt?.textContent).not.toContain("→");
});
});
});