Skip to content

Commit

Permalink
Include artifact (id + group + version) in what gets searched
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Jun 21, 2024
1 parent 03f526f commit 4954ed3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/extensions-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] },
Expand Down Expand Up @@ -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", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/filters/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions src/components/filters/filters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("filters bar", () => {
const alice = {
name: "Alice",
description: "a nice person",
artifact: "some complex id",
metadata: {
categories: ["lynx"],
status: "wonky",
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const pageQuery = graphql`
allExtension(sort: { fields: [name], order: DESC }) {
nodes {
name
artifact
id
sortableName
description
Expand Down

0 comments on commit 4954ed3

Please sign in to comment.