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

chore: component testing #177

Merged
merged 28 commits into from
Sep 25, 2024
Merged

chore: component testing #177

merged 28 commits into from
Sep 25, 2024

Conversation

luukbrauckmann
Copy link
Member

@luukbrauckmann luukbrauckmann commented Sep 16, 2024

Changes

  • Adds unit tests for all components and blocks

Associated issue

None

How to test

  1. Open project in editor
  2. Run in terminal npm ci
  3. Run npm run test
  4. All tests should run.

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@luukbrauckmann luukbrauckmann self-assigned this Sep 16, 2024
Copy link

cloudflare-workers-and-pages bot commented Sep 16, 2024

Deploying head-start with  Cloudflare Pages  Cloudflare Pages

Latest commit: 24f5842
Status: ✅  Deploy successful!
Preview URL: https://3ba9f26e.head-start.pages.dev
Branch Preview URL: https://feat-component-testing.head-start.pages.dev

View logs

@luukbrauckmann luukbrauckmann marked this pull request as ready for review September 17, 2024 14:06
@jbmoelker jbmoelker changed the title Feat/component testing chore: component testing Sep 17, 2024
Copy link
Contributor

@jurgenbelien jurgenbelien left a comment

Choose a reason for hiding this comment

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

Good job, I can imagine this took quite some effort!

I do have some remarks regarding how to structure tests and how to handle the data going into the tests. I also noticed some changes in the component to sidestep some issues with the renderer. I think it might be wise to skip those components instead of adding behavior that might have unintended consequences.

And a final tip that I did not mention in the comments: take a look at your commit history and see if you can clean that up a bit. You have three subsequent commits called 'Refactor'. Are you refactoring things you did in this branch earlier? If so, try to squash those with the changes your made earlier, they are no longer relevant. If not, try to elaborate a bit on what you are refactoring and why. Make commits atomic and only about the issue at hand.

src/blocks/ImageBlock/ImageBlock.test.ts Outdated Show resolved Hide resolved
src/blocks/ImageBlock/ImageBlock.test.ts Outdated Show resolved Hide resolved
src/blocks/TextBlock/TextBlock.test.ts Outdated Show resolved Hide resolved
src/blocks/TextBlock/TextBlock.test.ts Outdated Show resolved Hide resolved
src/components/Breadcrumbs/Breadcrumbs.astro Outdated Show resolved Hide resolved
src/components/LocaleSelector/LocaleSelector.astro Outdated Show resolved Hide resolved
vitest.config.ts Show resolved Hide resolved
luukbrauckmann and others added 13 commits September 20, 2024 10:23
# Changes

- Adds sitelinks search box structured data

# Associated issue

Resolves #109 

# How to test

1. Copy preview link
2. Go to https://search.google.com/test/rich-results
3. Paste preview link in field

# Checklist

- [x] I have performed a self-review of my own code
- [x] I have made sure that my PR is easy to review (not too big,
includes comments)
- [x] I have made updated relevant documentation files (in project
README, docs/, etc)
- [x] I have added a decision log entry if the change affects the
architecture or changes a significant technology
- [x] I have notified a reviewer

<!-- Please strike through and check off all items that do not apply
(rather than removing them) -->

---------

Co-authored-by: Jasper Moelker <jasper@voorhoede.nl>
# Changes

- Trims trailing whitespace from anchor (text) content. This prevents an
underline from extending beyond the word boundary.


# How to test

1. Open preview link
2. Scroll to the hyperlinks example.
3. See that their link does not extend to the space after the last word.
4. Compare that with the current https://head-start.pages.dev/en/

# Checklist

- [x] I have performed a self-review of my own code
- [x] I have made sure that my PR is easy to review (not too big,
includes comments)
- ~~I have made updated relevant documentation files (in project README,
docs/, etc)~~
- ~~I have added a decision log entry if the change affects the
architecture or changes a significant technology~~
- [x] I have notified a reviewer

<!-- Please strike through and check off all items that do not apply
(rather than removing them) -->

---------

Co-authored-by: Jasper Moelker <jasper@voorhoede.nl>
# Changes

- Adds TS plugin for .astro files, so it won't be highlighted as an
error.

# Associated issue

Resolves #175 

# How to test

<!-- example:
1. Open a non VSCode editor (best is to test in Zed)
2. Checkout branch
3. Run `npm ci`
4. Open a .ts file which imports an .astro file. For example
src/components/Tabs/index.ts
5. Imports should not be highlighted as error.
-->

# Checklist

- [x] I have performed a self-review of my own code
- [x] I have made sure that my PR is easy to review (not too big,
includes comments)
- [x] I have made updated relevant documentation files (in project
README, docs/, etc)
- [x] I have added a decision log entry if the change affects the
architecture or changes a significant technology
- [x] I have notified a reviewer

<!-- Please strike through and check off all items that do not apply
(rather than removing them) -->

Co-authored-by: Jasper Moelker <jasper@voorhoede.nl>
<!-- example:
- Fixes wrong color in button
- Adds a new page
-->

- adds `test` and `unit-test` scripts
- adds unit tests for `i18n` lib function
- adds a `vitest.config.ts` so we can configure the testing suite
- adds new deps needed for testing
- adds `unit-tests` step to github action CI so we test each commit to
the repo from now on
- uses the `github actions reporter` to enable formatting and
highlighting of testing output in the CI pipeline
- adds documentation for testing setup
- fixes the following issues in the i18n lib function:
  - interpolation did not work in the `t` function
  - params and language props were not supported in `t` function

Part of #103

- verify that the tests in the CI were succesful

- [x] I have performed a self-review of my own code
- [x] I have made sure that my PR is easy to review (not too big,
includes comments)
- [x] I have made updated relevant documentation files (in project
README, docs/, etc)
- [x] I have added a decision log entry if the change affects the
architecture or changes a significant technology
- [x] I have notified a reviewer

<!-- Please strike through and check off all items that do not apply
(rather than removing them) -->
src/middleware.ts Outdated Show resolved Hide resolved
src/lib/datocms.ts Outdated Show resolved Hide resolved
src/lib/datocms.ts Outdated Show resolved Hide resolved
@luukbrauckmann luukbrauckmann force-pushed the feat/component-testing branch 2 times, most recently from 4f04c04 to 8b3d04e Compare September 24, 2024 11:33
Copy link
Contributor

@jurgenbelien jurgenbelien left a comment

Choose a reason for hiding this comment

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

Looks good! After removing the inactive code and console.log, I think it's time to merge it and move any enhancements to the tests to the issues.

src/components/LocaleSelector/LocaleSelector.astro Outdated Show resolved Hide resolved
vitest.config.ts Outdated Show resolved Hide resolved
@luukbrauckmann luukbrauckmann merged commit daf88a0 into main Sep 25, 2024
5 checks passed
@luukbrauckmann luukbrauckmann deleted the feat/component-testing branch September 25, 2024 07:50
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.

4 participants