Граф коммитов

12 Коммитов

Автор SHA1 Сообщение Дата
Vincent cda0f5a570 Remove AppConstants
To make the migration as safe as possible, in places where it was
used to access environment variables that were absolutely required,
I replaced it with a function that forces the caller to explicitly
enumerate the environment variables they specifically expect,
allows them to access them in a type-safe way, and throws if the
named environment variables aren't set. (This is slightly different
than the previous behaviour, where AppConstants would only log the
missing variable without throwing, but I checked that all these
variables should be set in production.)
2024-09-16 11:40:30 +01:00
Vincent df2b6980e6 Explicitly set up IntersectionObserver mocking
For some reason, upstream react-intersection-observer switched from
`beforeEach` to `beforeAll` in v9.12.0:
- https://github.com/thebuilder/react-intersection-observer/pull/690/files#diff-26d4dc52e61d263a4256bed7c9ae3a9044b18a52f96f4f6840ca46336fb9216fL23-L24
- https://github.com/thebuilder/react-intersection-observer/releases/tag/v9.12.0

This led to errors on our side:

    Error: Uncaught [TypeError: observer.observe is not a function]

I'm not entirely sure what the reason is (it looks like the mock
gets unset every test?), but this restores it to its previous
behaviour, and in a way that doesn't look particularly likely for
upstream to break, so I think that's fine for now.

Initially I also set
https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
to import from `react-intersection-observer/test-utils`, but that
caused issues elsewhere (in particular when importing from
`@mozilla/glean/web`), so I reverted that since our tests aren't
type-checked anyway. I did make a couple of adjustments elsewhere
to be compatible with both that setting and the previous value.
2024-08-05 14:45:21 +00:00
Vincent e7261bc8ca Adopt .env.local file
This makes it clearer what variables actually need to be set
locally, and which have been forgotten. It also makes the build
simpler, by removing the need to copy the .env-dist file.

This should be safe to apply, since .env-dist already got loaded by
default, just like .env now is. And it is still the case that
actual environment variables overwrite the ones in the .env file.

For non-Next.js setups (e.g. cron jobs or database migrations), I
switched to dotenv-flow. The regular dotenv explicitly avoids
inheritance [1], because it wants environment variables to be
specific to an environment. That was already not the case with most
of our environment variables, so the switch makes sense for us.

Next steps could be to remove unused variables from .env, and
possibly moving variables with local/stage-specific values to
.env.local.example, though that riskier, since environments might
depend on those being present.

[1]
https://www.npmjs.com/package/dotenv#should-i-have-multiple-env-files
2024-07-09 10:58:25 +02:00
Vincent 35af70a6cd Also suppress non-error logs in tests
This makes it easier to debug issues when they do arise.
2024-01-05 13:16:56 +01:00
Vincent 3c7b495992 Remove workaround for incomplete jest-axe typings
.toHaveNoViolations() wasn't properly typed when `expect` was
imported from `@jest/globals`, but our upstream fix was merged, so
the workaround is no longer necessary:
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/67495
2023-11-27 14:40:10 +01:00
Florian Zia c700533a87
Update jest.setup.ts
Co-authored-by: Vincent <Vinnl@users.noreply.github.com>
2023-11-24 14:44:07 +01:00
Florian Zia a70da5fe04
chore: Add matcher for toHaveNoViolations 2023-11-21 19:01:07 +01:00
Florian Zia 642cd2c15e
fix: Linter in tests 2023-11-21 16:40:26 +01:00
dependabot[bot] 29dd0dab1e
Bump pg from 8.10.0 to 8.11.3 (#3458)
* Bump pg from 8.10.0 to 8.11.3

Bumps [pg](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg) from 8.10.0 to 8.11.3.
- [Changelog](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md)
- [Commits](https://github.com/brianc/node-postgres/commits/pg@8.11.3/packages/pg)

---
updated-dependencies:
- dependency-name: pg
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* jsdom environment not provide TextEncoder https://github.com/jsdom/jsdom/issues/2524

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Helmer <rhelmer@mozilla.com>
2023-10-03 11:36:11 -07:00
Vincent 78f2ddbc2a Prevent superfluous logs in tests
This does add another devDependency; we could also simulate this
ourselves by e.g. augmenting the console methods in jest.setup.ts
to throw Errors - however, this gives us a nice error message that
gives some pointers on how to proceed if you do expect the console,
the package is pretty widely used, and is not part of the final
bundle.
2023-09-07 12:01:57 +02:00
Vincent e95c3af684
Fix warnings about wrapping tests in act() (#3314)
* Fix warnings about wrapping tests in act()

For full details on what this fix entails, see
https://www.benmvp.com/blog/avoiding-react-act-warning-when-accessibility-testing-next-link-jest-axe/

* fix buttonProps errors

* fix lint

---------

Co-authored-by: Kaitlyn <kandres@mozilla.com>
2023-08-29 13:34:23 -04:00
Vincent dc98deeddd Add first screen of the onboarding flow 2023-07-07 18:15:09 +02:00