Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OUR415-314] Improves our test story with test templates and helpers for search; adds BrowserRefinementList component test #259

Merged
merged 7 commits into from
Nov 6, 2024

Conversation

rosschapman
Copy link
Collaborator

@rosschapman rosschapman commented Nov 5, 2024

I wrote our first component test of a component with Algolia hooks. This code establishes a precedent but as more tests are written we might come up with improvements to the "test harness" to increase ease of writing tests.

@rosschapman rosschapman changed the title Adds new component template, search test helpers, and adds browse ref… Improves our test story with test templates, search helpers, Nov 6, 2024
@rosschapman rosschapman changed the title Improves our test story with test templates, search helpers, Improves our test story with test templates and helpers for search; adds BrowserRefinementList component test Nov 6, 2024
@rosschapman rosschapman marked this pull request as ready for review November 6, 2024 20:15
@rosschapman rosschapman changed the title Improves our test story with test templates and helpers for search; adds BrowserRefinementList component test [OUR415-314] Improves our test story with test templates and helpers for search; adds BrowserRefinementList component test Nov 6, 2024
import { createSearchClient } from "../../../../test/helpers/createSearchClient";

describe("BrowseRefinementList", () => {
test("renders the correct the number of categories", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (non-blocking): There are 12 categories in searchClient but expected is 10. Is there anything in the repo that explains this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I updated the test name to indicate more explicitly what this is testing.

@@ -39,10 +39,12 @@ const BrowseRefinementList = ({ attribute, transform }: Props) => {
setChecked(checked);
};

// console.log(items);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: Let's get rid of this

*/
export function createSearchClient(options: Options) {
return {
search: (requests: any) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (if-minor): In the interest of minimizing lint warnings, can we change these 2 'any' types in this file or can we lint ignore this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops yeah, forgot to add ignore statements. I was going to clean up all the warnings in a separate PR so I can do it there.

@@ -0,0 +1,25 @@
/**
* Template for a simple component test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good idea

Copy link
Collaborator

@adriencyberspace adriencyberspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please answer / address my comments but looks good to me otherwise!

import { createSearchClient } from "../../../../test/helpers/createSearchClient";

describe("BrowseRefinementList", () => {
test("renders the correct the number of categories", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): Could you remove the second "the"?

@rosschapman rosschapman merged commit 9aee08b into main Nov 6, 2024
1 check passed
@rosschapman rosschapman deleted the OUR415-314-testing-browse branch November 6, 2024 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants