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

fix: Remove Service Account from Zitadel when API key is deleted. #3908

Merged
merged 66 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3b67e16
wip
bryan-robitaille Jun 4, 2024
ae0bbd8
reanme key files
bryan-robitaille Jun 14, 2024
b2d43fd
use hosted cloud versoin for PoC
bryan-robitaille Jun 14, 2024
2da31eb
Merge branch 'develop' into feature/service_account
bryan-robitaille Jun 14, 2024
d5eec05
remove hardcoded form id in utility script
bryan-robitaille Jun 19, 2024
b8e1d7b
Merge branch 'develop' into feature/service_account
bryan-robitaille Jun 26, 2024
7e839f0
Add setting for zitadel administration key
bryan-robitaille Jun 26, 2024
faa290c
Allow for encrypted settings
bryan-robitaille Jun 27, 2024
67177d0
use new encrypted setting for zitadel admin account
bryan-robitaille Jun 27, 2024
bc75e61
Ensure session storage is only checked on client
bryan-robitaille Jun 28, 2024
d9c6f74
wip - api settings only / no login with zitadel
bryan-robitaille Jul 2, 2024
fb01f36
revert to use nextauth react signout
bryan-robitaille Jul 2, 2024
7ef322c
Merge branch 'develop' into feature/service_account
bryan-robitaille Jul 8, 2024
c9caab5
update yarn package manager to 4.3.1
bryan-robitaille Jul 8, 2024
e5c556a
Merge branch 'develop' into feature/service_account
bryan-robitaille Jul 8, 2024
ae2e75e
Merge branch 'develop' into feature/service_account
bryan-robitaille Jul 8, 2024
cd18c86
update mock for encrypted in test
bryan-robitaille Jul 8, 2024
cd4ae98
Merge branch 'feature/service_account' of https://github.com/cds-snc/…
bryan-robitaille Jul 8, 2024
583d63f
make route not routable for retrival example
bryan-robitaille Jul 8, 2024
6a09bcc
Merge branch 'develop' of https://github.com/cds-snc/platform-forms-c…
bryan-robitaille Jul 9, 2024
e66509b
fix migrations after merge in from develop
bryan-robitaille Jul 10, 2024
3567324
Add audit logging on api service user CRUD
bryan-robitaille Jul 10, 2024
6543919
Merge branch 'develop' into feature/service_account
bryan-robitaille Jul 10, 2024
e7ac357
enable filtering on next-auth endpoint
bryan-robitaille Jul 10, 2024
d2ddfea
Add error check for missing env var
bryan-robitaille Jul 10, 2024
e094fa2
bump next and next-auth
bryan-robitaille Jul 10, 2024
8c3618c
remove logMessage
bryan-robitaille Jul 10, 2024
1afdb3b
Add a flag check for Settings API page and redirect
bryan-robitaille Jul 10, 2024
ba8cfab
move line back to where it was
bryan-robitaille Jul 10, 2024
f3d0ae6
remove temporary env vars from docker file
bryan-robitaille Jul 10, 2024
2946316
remove old conversion script
bryan-robitaille Jul 10, 2024
7043a41
Add new setting for zitadel provider
bryan-robitaille Jul 10, 2024
23b372f
Merge branch 'develop' into feature/service_account
bryan-robitaille Jul 10, 2024
4864cb2
Merge branch 'feature/service_account' of https://github.com/cds-snc/…
bryan-robitaille Jul 10, 2024
4dea145
add zitadel node sdk
bryan-robitaille Jul 11, 2024
5a642a3
wip
bryan-robitaille Jul 12, 2024
6cdf2e9
Merge branch 'develop' into feature/service_account
bryan-robitaille Aug 20, 2024
8b8f31d
refactor prisma migrations to align for merge timeline
bryan-robitaille Aug 20, 2024
460c27a
reset back to what it should be without encrypted settings
bryan-robitaille Aug 21, 2024
8510c6b
remove encrypted settings from this branch
bryan-robitaille Aug 21, 2024
23aae70
remove change from other feature
bryan-robitaille Aug 22, 2024
753e125
Remove changes that were part of prototyping
bryan-robitaille Aug 22, 2024
53fe6e1
fix changelog formatting
bryan-robitaille Aug 22, 2024
98d7f37
rework api actions to delete user
bryan-robitaille Aug 22, 2024
60d2482
remove utility script. it will be hosted in the api repo instead
bryan-robitaille Aug 22, 2024
b5bc981
Merge branch 'develop' into feature/service_account
bryan-robitaille Aug 22, 2024
96f5b2d
refactoring and delete key on form deletion
bryan-robitaille Aug 23, 2024
2bc701a
add flag check
bryan-robitaille Aug 26, 2024
189cfbb
update yarn again
bryan-robitaille Aug 26, 2024
e3c76c3
globally mock redis
bryan-robitaille Aug 26, 2024
2aefe14
Need to add check for Zitadel flag when deleting a form
bryan-robitaille Aug 26, 2024
112c63e
artifact from updating yarn to 4.4.1
bryan-robitaille Aug 26, 2024
bf928f0
Merge branch 'develop' into feature/service_account
bryan-robitaille Aug 26, 2024
d797469
small prisma fixes from leftover refactors in the past
bryan-robitaille Aug 26, 2024
04653ff
wip tests for service account lib
bryan-robitaille Aug 26, 2024
8fe2725
Merge branch 'feature/service_account' of https://github.com/cds-snc/…
bryan-robitaille Aug 26, 2024
b1ddca9
wip, fix overriding mock on auth
bryan-robitaille Aug 26, 2024
68d55a3
switch jest env to node and ensure prisma is only run on node
bryan-robitaille Aug 27, 2024
4fe295b
finished up jest tests
bryan-robitaille Aug 27, 2024
5eb9aba
remove unrequired mock
bryan-robitaille Aug 27, 2024
ed2cb92
remove unused import
bryan-robitaille Aug 27, 2024
c61fd53
Merge branch 'develop' into feature/service_account
bryan-robitaille Aug 28, 2024
13f74fc
Merge branch 'develop' into feature/service_account
bryan-robitaille Sep 16, 2024
2367297
add missing line break on import
bryan-robitaille Sep 16, 2024
35f603b
remove debug logs from api key module
bryan-robitaille Sep 16, 2024
6f1727f
use right flag
bryan-robitaille Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.1.1.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.4.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.1.cjs
yarnPath: .yarn/releases/yarn-4.4.1.cjs
43 changes: 18 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.19.0](https://github.com/cds-snc/platform-forms-client/compare/v3.18.2...v3.19.0) (2024-08-14)


### Features

* Enable Zitadel Integration for API Authentication ([#4147](https://github.com/cds-snc/platform-forms-client/issues/4147)) ([200ab05](https://github.com/cds-snc/platform-forms-client/commit/200ab05b1199bdf5a1f8acf8a6d4fe0067fc9fde))

- Enable Zitadel Integration for API Authentication ([#4147](https://github.com/cds-snc/platform-forms-client/issues/4147)) ([200ab05](https://github.com/cds-snc/platform-forms-client/commit/200ab05b1199bdf5a1f8acf8a6d4fe0067fc9fde))

### Bug Fixes

* FileInput max upload size for all files ([#4173](https://github.com/cds-snc/platform-forms-client/issues/4173)) ([ba5d89e](https://github.com/cds-snc/platform-forms-client/commit/ba5d89e36664279524675142b622b798c580848d))
* Handle repeatingSets that include more than just fileInputs ([#4193](https://github.com/cds-snc/platform-forms-client/issues/4193)) ([8612909](https://github.com/cds-snc/platform-forms-client/commit/861290910e40d9577e5f8626680a59a939223946))
* Multiple fileInputs in a repeatingSet ([#4188](https://github.com/cds-snc/platform-forms-client/issues/4188)) ([2d665f8](https://github.com/cds-snc/platform-forms-client/commit/2d665f8151103525956964556f7534573f0c27a9))

- FileInput max upload size for all files ([#4173](https://github.com/cds-snc/platform-forms-client/issues/4173)) ([ba5d89e](https://github.com/cds-snc/platform-forms-client/commit/ba5d89e36664279524675142b622b798c580848d))
- Handle repeatingSets that include more than just fileInputs ([#4193](https://github.com/cds-snc/platform-forms-client/issues/4193)) ([8612909](https://github.com/cds-snc/platform-forms-client/commit/861290910e40d9577e5f8626680a59a939223946))
- Multiple fileInputs in a repeatingSet ([#4188](https://github.com/cds-snc/platform-forms-client/issues/4188)) ([2d665f8](https://github.com/cds-snc/platform-forms-client/commit/2d665f8151103525956964556f7534573f0c27a9))

### Code Refactoring

* update confirm api to a server action ([#4042](https://github.com/cds-snc/platform-forms-client/issues/4042)) ([23052aa](https://github.com/cds-snc/platform-forms-client/commit/23052aa0817e2045c308955dbfb469c0e7d912f7))
- update confirm api to a server action ([#4042](https://github.com/cds-snc/platform-forms-client/issues/4042)) ([23052aa](https://github.com/cds-snc/platform-forms-client/commit/23052aa0817e2045c308955dbfb469c0e7d912f7))

## [3.18.2](https://github.com/cds-snc/platform-forms-client/compare/v3.18.1...v3.18.2) (2024-08-08)


### Bug Fixes

* Adjust next action choice rules when option removed ([#4180](https://github.com/cds-snc/platform-forms-client/issues/4180)) ([da5f70f](https://github.com/cds-snc/platform-forms-client/commit/da5f70fb03d91ff6a28dcc014fdfca2d55ba847f))
* Move redirects from server to client on Contact and Support ([1c79684](https://github.com/cds-snc/platform-forms-client/commit/1c79684d6ff17f11a25053679d274df1bd2d3c8b))
* Move redirects from server to client on Contact and Support ([3b53550](https://github.com/cds-snc/platform-forms-client/commit/3b53550710731476df021cd9740bd475ed318712))

- Adjust next action choice rules when option removed ([#4180](https://github.com/cds-snc/platform-forms-client/issues/4180)) ([da5f70f](https://github.com/cds-snc/platform-forms-client/commit/da5f70fb03d91ff6a28dcc014fdfca2d55ba847f))
- Move redirects from server to client on Contact and Support ([1c79684](https://github.com/cds-snc/platform-forms-client/commit/1c79684d6ff17f11a25053679d274df1bd2d3c8b))
- Move redirects from server to client on Contact and Support ([3b53550](https://github.com/cds-snc/platform-forms-client/commit/3b53550710731476df021cd9740bd475ed318712))

### Miscellaneous Chores

* Add National Defence & Public Service Commission of Canada branding ([#4174](https://github.com/cds-snc/platform-forms-client/issues/4174)) ([8e16820](https://github.com/cds-snc/platform-forms-client/commit/8e16820ca0c4c4f5a5e9810652715655d789b4b0))
- Add National Defence & Public Service Commission of Canada branding ([#4174](https://github.com/cds-snc/platform-forms-client/issues/4174)) ([8e16820](https://github.com/cds-snc/platform-forms-client/commit/8e16820ca0c4c4f5a5e9810652715655d789b4b0))

## [3.18.1](https://github.com/cds-snc/platform-forms-client/compare/v3.18.0...v3.18.1) (2024-08-08)


### Bug Fixes

* Adjust ChoiceId indexes when an option is removed. ([#4153](https://github.com/cds-snc/platform-forms-client/issues/4153)) ([6844053](https://github.com/cds-snc/platform-forms-client/commit/6844053779485b5084c8f72e905665928db85f71))
* only delete form viewer task definitions ([#4168](https://github.com/cds-snc/platform-forms-client/issues/4168)) ([382ad49](https://github.com/cds-snc/platform-forms-client/commit/382ad491988746abd0314a8b641c6f5d94bc4687))
* release-please configuration in v4 ([#4162](https://github.com/cds-snc/platform-forms-client/issues/4162)) ([6245c27](https://github.com/cds-snc/platform-forms-client/commit/6245c270857b52b1b0a7a3f2c88fb41ef1b23860))
* small typo in terms of use ([#4176](https://github.com/cds-snc/platform-forms-client/issues/4176)) ([e4170bb](https://github.com/cds-snc/platform-forms-client/commit/e4170bbb196776be35a91a58f9d9cb93ec7e9ca2))

- Adjust ChoiceId indexes when an option is removed. ([#4153](https://github.com/cds-snc/platform-forms-client/issues/4153)) ([6844053](https://github.com/cds-snc/platform-forms-client/commit/6844053779485b5084c8f72e905665928db85f71))
- only delete form viewer task definitions ([#4168](https://github.com/cds-snc/platform-forms-client/issues/4168)) ([382ad49](https://github.com/cds-snc/platform-forms-client/commit/382ad491988746abd0314a8b641c6f5d94bc4687))
- release-please configuration in v4 ([#4162](https://github.com/cds-snc/platform-forms-client/issues/4162)) ([6245c27](https://github.com/cds-snc/platform-forms-client/commit/6245c270857b52b1b0a7a3f2c88fb41ef1b23860))
- small typo in terms of use ([#4176](https://github.com/cds-snc/platform-forms-client/issues/4176)) ([e4170bb](https://github.com/cds-snc/platform-forms-client/commit/e4170bbb196776be35a91a58f9d9cb93ec7e9ca2))

### Miscellaneous Chores

* upgrade to Next-Auth 5.0.0 beta 20. Goal is to fix the error log we get when someone enters a wrong 2FA code ([#4161](https://github.com/cds-snc/platform-forms-client/issues/4161)) ([eb18e7d](https://github.com/cds-snc/platform-forms-client/commit/eb18e7d93fb75b10594897452cb7ed8785dc1862))
- upgrade to Next-Auth 5.0.0 beta 20. Goal is to fix the error log we get when someone enters a wrong 2FA code ([#4161](https://github.com/cds-snc/platform-forms-client/issues/4161)) ([eb18e7d](https://github.com/cds-snc/platform-forms-client/commit/eb18e7d93fb75b10594897452cb7ed8785dc1862))

## [3.18.0](https://github.com/cds-snc/platform-forms-client/compare/v3.17.0...v3.18.0) (2024-08-06)

Expand Down Expand Up @@ -924,7 +917,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [BREAKING]: Modified the Prisma schema for the "User" table; removing the `admin` column, and adding the `role` column. After migrating, at least one user role will need to manually be set to `administrator` in order to login the Admin portion of the site. [#906](https://github.com/cds-snc/platform-forms-client/pull/906)
- Added file attachments to retrieval API [#909](https://github.com/cds-snc/platform-forms-client/pull/909)
- New login lockout mechanism plugged on existing temporary token API [#872](https://github.com/cds-snc/platform-forms-client/issues/872)
- Logout Page [#847] (https://github.com/cds-snc/platform-forms-client/issues/870)
- Logout Page [#847] (<https://github.com/cds-snc/platform-forms-client/issues/870>)
- Admin feature to assign users to template [#1203](https://github.com/cds-snc/platform-forms-client/issues/1203)
- New API path to request publishing permission [#1226](https://github.com/cds-snc/platform-forms-client/issues/1226)
- Dynamic footer with SLA and Support links on admin and form builder related pages [#1080](https://github.com/cds-snc/platform-forms-client/issues/1080)
Expand Down Expand Up @@ -992,7 +985,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [BREAKING]: Modified the Prisma schema for the "User" table; removing the `admin` column, and adding the `role` column. After migrating, at least one user role will need to manually be set to `administrator` in order to login the Admin portion of the site. [#906](https://github.com/cds-snc/platform-forms-client/pull/906)
- Added file attachments to retrieval API [#909](https://github.com/cds-snc/platform-forms-client/pull/909)
- New login lockout mechanism plugged on existing temporary token API [#872](https://github.com/cds-snc/platform-forms-client/issues/872)
- Logout Page [#847] (https://github.com/cds-snc/platform-forms-client/issues/870)
- Logout Page [#847] (<https://github.com/cds-snc/platform-forms-client/issues/870>)
bryan-robitaille marked this conversation as resolved.
Show resolved Hide resolved
- Admin feature to assign users to template [#1203](https://github.com/cds-snc/platform-forms-client/issues/1203)
- New API path to request publishing permission [#1226](https://github.com/cds-snc/platform-forms-client/issues/1226)
- Dynamic footer with SLA and Support links on admin and form builder related pages [#1080](https://github.com/cds-snc/platform-forms-client/issues/1080)
Expand Down Expand Up @@ -1040,14 +1033,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Logging admin activity in database [#700](https://github.com/cds-snc/platform-forms-client/issues/700)
- Add Cross-Site Request Forgery (CSRF) [#716] (https://github.com/cds-snc/platform-forms-client/issues/716)
- Add Cross-Site Request Forgery (CSRF) [#716] (<https://github.com/cds-snc/platform-forms-client/issues/716>)
- Data classification attributes. [#701](https://github.com/cds-snc/platform-forms-client/issues/701)

### Fixed

- Fixed retrieval API not returning all existing responses
- Removed the security attribute from the viewport.
- Added CSRF token requirement to `api/log` endpoint [#835]((https://github.com/cds-snc/platform-forms-client/pull/835)
- Added CSRF token requirement to `api/log` endpoint [#835]((<https://github.com/cds-snc/platform-forms-client/pull/835>)

### Changed

Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/acceptable-use.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

import { createMocks } from "node-mocks-http";
import acceptableUse from "old_pages/api/acceptableuse";
import { setAcceptableUse } from "@lib/cache/acceptableUseCache";
Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/account/confirmpassword.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import { getCsrfToken } from "@lib/client/csrfToken";
Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/account/forgotpassword.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import { getCsrfToken } from "@lib/client/csrfToken";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/account/register.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import { getCsrfToken } from "@lib/client/csrfToken";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/account/submissions/overdue.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import Redis from "ioredis-mock";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/flags.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
import { createMocks } from "node-mocks-http";
import { getServerSession } from "next-auth/next";
import enable from "old_pages/api/flags/[key]/enable";
Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/id/form/apiUsers.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

/* eslint-disable @typescript-eslint/no-explicit-any */

import { createMocks, RequestMethod } from "node-mocks-http";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/id/form/submission/confirm.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import confirm from "old_pages/api/id/[form]/submission/confirm";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/id/form/submission/report.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import report from "old_pages/api/id/[form]/submission/report";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/notify-callbacks.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
import { createMocks } from "node-mocks-http";
import notifyCallback from "../../pages/api/notify-callback";
import { SQSClient } from "@aws-sdk/client-sqs";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/request/publish.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import publish from "old_pages/api/request/publish";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/request/support.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import support from "old_pages/api/request/support";
Expand Down
3 changes: 0 additions & 3 deletions __tests__/api/settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @jest-environment node
*/
import { createMocks, RequestMethod } from "node-mocks-http";
import settings from "old_pages/api/settings/[settingId]";
import settingsRoot from "old_pages/api/settings/index";
Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/templates.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks, RequestMethod } from "node-mocks-http";
import Redis from "ioredis-mock";
Expand Down
4 changes: 0 additions & 4 deletions __tests__/api/users.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import { createMocks } from "node-mocks-http";
import Redis from "ioredis-mock";
Expand Down
8 changes: 8 additions & 0 deletions __utils__/mocks/redis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Redis from "ioredis-mock";

jest.mock("@lib/integration/redisConnector", () => {
const redis = new Redis();
return {
getRedisInstance: jest.fn(async () => redis),
};
});
27 changes: 17 additions & 10 deletions __utils__/prismaConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ export const {
} = Prisma;

jest.mock("@lib/integration/prismaConnector", () => {
const originalModule = jest.requireActual("@lib/integration/prismaConnector");
return {
__esModule: true,
...originalModule,
prisma: mockDeep<PrismaClient>(),
};
});

beforeEach(() => {
mockReset(prismaMock);
// Only mock prisma when were running in the Node jest environment
if (typeof window === "undefined") {
const originalModule = jest.requireActual("@lib/integration/prismaConnector");
return {
__esModule: true,
...originalModule,
prisma: mockDeep<PrismaClient>(),
};
} else {
return {};
}
});
// Only mock prisma when were running in the Node jest environment
if (typeof window === "undefined") {
beforeEach(() => {
mockReset(prismaMock);
});
}

export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>;
5 changes: 0 additions & 5 deletions __utils__/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ jest.mock("@i18n", () => {
};
});

jest.mock("@lib/integration/redisConnector", () => ({
__esModule: true,
getRedisInstance: () => jest.fn(),
}));

jest.mock("@lib/auditLogs", () => ({
__esModule: true,
logEvent: jest.fn(jest.fn(async () => undefined)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render } from "@testing-library/react";
import { AddElementButton } from "../AddElementButton";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render, fireEvent } from "@testing-library/react";
import { ElementDialog } from "../ElementDialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, screen, render, act, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render, act } from "@testing-library/react";
import { Option } from "../Option";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render, waitFor } from "@testing-library/react";
import { Options } from "../Options";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render, act, waitFor } from "@testing-library/react";
import { Question } from "../question/Question";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup, render, act } from "@testing-library/react";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup } from "@testing-library/react";
import { RichTextLocked } from "../RichTextLocked";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { cleanup } from "@testing-library/react";
import { ShortAnswer } from "../ShortAnswer";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { render, cleanup, act } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { render, waitFor, waitForElementToBeRemoved } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { render, cleanup } from "@testing-library/react";
import { LineItem } from "../LineItem";
Expand All @@ -24,6 +27,9 @@ describe("LineItem", () => {
await userEvent.click(removeButtons[0]);
expect(mockCallback).toHaveBeenCalledTimes(1);
expect(mockCallback).toHaveBeenCalledWith("31-12-XCRV");
expect(removeButtons[0]).toHaveAttribute("aria-label", "downloadResponsesModals.lineItemEntries.remove 31-12-XCRV");
expect(removeButtons[0]).toHaveAttribute(
"aria-label",
"downloadResponsesModals.lineItemEntries.remove 31-12-XCRV"
);
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React, { useState } from "react";
import { render, cleanup } from "@testing-library/react";
import { LineItemEntries } from "../LineItemEntries";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { render, cleanup } from "@testing-library/react";
import { LineItems } from "../LineItems";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import React from "react";
import { act, render } from "@testing-library/react";
import { DownloadTable } from "../DownloadTable";
Expand Down
Loading
Loading