Skip to content

Commit 0ba11fb

Browse files
committed
Include artifact (id + group + version) in what gets searched
1 parent 080f842 commit 0ba11fb

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/components/extensions-list.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe("extension list", () => {
4848
const maybeObsolete = {
4949
name: "Maybebsolete",
5050
id: "maybe-old",
51+
artifact: "maybe-old-or-not",
5152
sortableName: "maybe-old",
5253
slug: "ambiguous-slug",
5354
metadata: { categories: [otherCategory] },
@@ -120,6 +121,16 @@ describe("extension list", () => {
120121
await user.keyboard("ruby")
121122
expect(screen.queryByText(ruby.name)).toBeTruthy()
122123
})
124+
125+
it("includes the artifact id in what it searches", async () => {
126+
expect(screen.queryByText(maybeObsolete.name)).toBeTruthy()
127+
const searchInput = screen.getByRole("textbox")
128+
await user.click(searchInput)
129+
await user.clear(searchInput)
130+
await user.keyboard(maybeObsolete.artifact)
131+
expect(screen.queryByText(maybeObsolete.name)).toBeTruthy()
132+
expect(screen.queryByText(ruby.name)).toBeFalsy()
133+
})
123134
})
124135

125136
describe("category filter", () => {

src/components/filters/filters.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const filterExtensions = (
1919
extensions,
2020
{ regex, categoryFilter, keywordFilter, statusFilter, compatibilityFilter }
2121
) => {
22+
console.log(extensions[0])
2223
return (
2324
extensions
2425
// Exclude unlisted extensions, unless they happen to match a non-trivial search filter
@@ -27,6 +28,7 @@ const filterExtensions = (
2728
.filter(
2829
extension =>
2930
extension.name.toLowerCase().match(regex.toLowerCase()) ||
31+
extension.artifact?.toLowerCase().match(regex.toLowerCase()) ||
3032
extension.description?.toLowerCase().match(regex.toLowerCase())
3133
)
3234
.filter(

src/components/filters/filters.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe("filters bar", () => {
2626
const alice = {
2727
name: "Alice",
2828
description: "a nice person",
29+
artifact: "some complex id",
2930
metadata: {
3031
categories: ["lynx"],
3132
status: "wonky",
@@ -125,6 +126,15 @@ describe("filters bar", () => {
125126
expect(newExtensions).not.toContain(pascal)
126127
})
127128

129+
it("leaves in extensions whose id match the search filter", async () => {
130+
const searchInput = screen.getByRole("textbox")
131+
await user.click(searchInput)
132+
await user.keyboard(alice.artifact)
133+
expect(extensionsListener).toHaveBeenCalled()
134+
expect(newExtensions).toContain(alice)
135+
expect(newExtensions).not.toContain(pascal)
136+
})
137+
128138
it("is case insensitive in its searching", async () => {
129139
const searchInput = screen.getByRole("textbox")
130140
await user.click(searchInput)

src/pages/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const pageQuery = graphql`
5959
allExtension(sort: { fields: [name], order: DESC }) {
6060
nodes {
6161
name
62+
artifact
6263
id
6364
sortableName
6465
description

0 commit comments

Comments
 (0)