diff --git a/src/components/extensions-list.test.js b/src/components/extensions-list.test.js index 3869ef0ccb29..a7a470595012 100644 --- a/src/components/extensions-list.test.js +++ b/src/components/extensions-list.test.js @@ -48,6 +48,7 @@ describe("extension list", () => { const maybeObsolete = { name: "Maybebsolete", id: "maybe-old", + artifact: "maybe-old-or-not", sortableName: "maybe-old", slug: "ambiguous-slug", metadata: { categories: [otherCategory] }, @@ -120,6 +121,16 @@ describe("extension list", () => { await user.keyboard("ruby") expect(screen.queryByText(ruby.name)).toBeTruthy() }) + + it("includes the artifact id in what it searches", async () => { + expect(screen.queryByText(maybeObsolete.name)).toBeTruthy() + const searchInput = screen.getByRole("textbox") + await user.click(searchInput) + await user.clear(searchInput) + await user.keyboard(maybeObsolete.artifact) + expect(screen.queryByText(maybeObsolete.name)).toBeTruthy() + expect(screen.queryByText(ruby.name)).toBeFalsy() + }) }) describe("category filter", () => { diff --git a/src/components/filters/filters.js b/src/components/filters/filters.js index 2bbd44c47044..944ddb9747db 100644 --- a/src/components/filters/filters.js +++ b/src/components/filters/filters.js @@ -19,6 +19,7 @@ const filterExtensions = ( extensions, { regex, categoryFilter, keywordFilter, statusFilter, compatibilityFilter } ) => { + console.log(extensions[0]) return ( extensions // Exclude unlisted extensions, unless they happen to match a non-trivial search filter @@ -27,6 +28,7 @@ const filterExtensions = ( .filter( extension => extension.name.toLowerCase().match(regex.toLowerCase()) || + extension.artifact?.toLowerCase().match(regex.toLowerCase()) || extension.description?.toLowerCase().match(regex.toLowerCase()) ) .filter( diff --git a/src/components/filters/filters.test.js b/src/components/filters/filters.test.js index 9e1338239a6f..4d8fad82a5b1 100644 --- a/src/components/filters/filters.test.js +++ b/src/components/filters/filters.test.js @@ -26,6 +26,7 @@ describe("filters bar", () => { const alice = { name: "Alice", description: "a nice person", + artifact: "some complex id", metadata: { categories: ["lynx"], status: "wonky", @@ -125,6 +126,15 @@ describe("filters bar", () => { expect(newExtensions).not.toContain(pascal) }) + it("leaves in extensions whose id match the search filter", async () => { + const searchInput = screen.getByRole("textbox") + await user.click(searchInput) + await user.keyboard(alice.artifact) + expect(extensionsListener).toHaveBeenCalled() + expect(newExtensions).toContain(alice) + expect(newExtensions).not.toContain(pascal) + }) + it("is case insensitive in its searching", async () => { const searchInput = screen.getByRole("textbox") await user.click(searchInput) diff --git a/src/pages/index.js b/src/pages/index.js index b12ed76419fe..003d3c7f9bd2 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -59,6 +59,7 @@ export const pageQuery = graphql` allExtension(sort: { fields: [name], order: DESC }) { nodes { name + artifact id sortableName description