Skip to content
Snippets Groups Projects
Unverified Commit 21ae344b authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

search result order (#50048)

parent b3a46a77
No related branches found
No related tags found
No related merge requests found
......@@ -87,12 +87,12 @@ describe("command palette", () => {
// Check that we are not filtering search results by action name
commandPaletteInput().clear().type("Company");
cy.findByRole("option", { name: /View and filter/ }).should("exist");
cy.findByRole("option", { name: "PEOPLE" }).should(
cy.findByRole("option", { name: "REVIEWS" }).should(
"have.attr",
"aria-selected",
"true",
);
cy.findByRole("option", { name: "REVIEWS" }).should("exist");
cy.findByRole("option", { name: "PEOPLE" }).should("exist");
cy.findByRole("option", { name: "PRODUCTS" }).should("exist");
commandPaletteInput().clear();
......@@ -139,6 +139,29 @@ describe("command palette", () => {
.should("have.attr", "aria-selected", "true");
});
it("should display search results in the order returned by the API", () => {
cy.visit("/");
cy.findByRole("button", { name: /Search/ }).click();
cy.intercept("/api/search?*").as("searchData");
commandPalette().within(() => {
commandPaletteInput().type("Cou");
cy.wait("@searchData");
cy.findByText("Loading...").should("not.exist");
cy.get("@searchData").then(({ response }) => {
const results = response.body.data;
results.forEach((result, index) => {
cy.findAllByRole("option")
.eq(index + 2)
.should("contain.text", result.name);
});
});
});
});
it("should render links to site settings in settings pages", () => {
cy.visit("/admin");
cy.findByRole("heading", { name: "Getting set up" }).should("exist");
......
......@@ -188,7 +188,7 @@ export const useCommandPalette = ({
icon: icon.name,
section: "search",
keywords: debouncedSearchText,
priority: Priority.NORMAL,
priority: Priority.NORMAL - index,
perform: () => {
trackSearchClick("item", index, "command-palette");
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment