Skip to content

Commit

Permalink
feat: disabling feature for Github, OVH and Mattermost services (#565)
Browse files Browse the repository at this point in the history
* feat: disabling feature for Github service

* mattermost

* change api route

* remove old file

* import

* ovh

* return in disabled endpoint

* enable users for which we receive an account

* dead code comment

* refactor: disable accounts not users

* frontend

* tests

* webhook leave disabled user

* disable github webhook

* error response

* config talisman

* merge lockfile

* add react-toastify

* use toasts

* migrate to vitest

* handle some services

* chore: improve sentry setup (#603)

* lock version

* lock version

* remove debug log

* remove email

* revert file formatting

* fix: unused var

* fix: refresh data after request submit

* fix: sync onboarding request and form hooks

* chore: fix nextjs build

* chore: fix buttons width

* chore: add modal max width

* chore: remove comment

* chore: remove useless async

---------

Co-authored-by: Gary van Woerkens <[email protected]>
  • Loading branch information
matmut7 and gary-van-woerkens authored Dec 6, 2023
1 parent 00b30af commit 5e30e3e
Show file tree
Hide file tree
Showing 107 changed files with 4,207 additions and 3,468 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ coverage
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Sentry Config File
.sentryclirc
15 changes: 15 additions & 0 deletions .kontinuous/env/dev/templates/sentry.sealed-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: sentry
spec:
encryptedData:
SENTRY_AUTH_TOKEN: AgB0+vei/m71QPjqmuo6v9pfgHRy8U9LCuVK2PHzkH5ul8tmgs04r2afwRs877iu+EP4NB6OtjXKG6AFCFmPusi6p35xl/IpqjdA/GlBC9Vwx914YDd46Hn+QoVqqDMmtvNxfuMxuxs5Zwro/5tMJMb6sU31Qyl/8p4Rne18EA2gje/WVK1a91HCb75o2sB0t/M5HgP+oP8Fj1yw1sqbIbnxHaIn4arf7NTEB3DSGrL4NpLtNN1ToQfL8UXH9vCmbLUjinHVSDm5Fkd67hPBqen0HkIdBIheU+LU7ygiiA5Bb470IuKxV9BuCey2CxSKDVNZBDfLuQAZ3uqF8plBoEtPLCeZ4Tda6KOvTnQ72Maj1YE3CLdOaLMtKQTi/Lt3ZcoBJvUEbGck+hmpEQq3QjwZMhmba8ZZX4Y8ymVpQd/LoJYhBM0ftel4kpK4oBlYEC612phPa+d+LywVkv+Vb3QQX4VOynAWhiuS+larg27H3dZ95kHZlzEgKdnUJ0WxfupoZEnyE7EXQ9aA1b+6Jg8GvCFoSCRuBG3WM7VmTCCzI7n/yjbKHTaPRqcLKA0pgvYNqyKiBemuKCRb+i/gzK8LqsdO8bJb3ZYl/H7ysqdWTvz0JLblg6lIMd/dDDjTJ5CWjF1q/RZWKiWigarirlNgnYdkK2iRaQ666KBRb3DoiexpAiBxx2iAsUDLWiVdHsZ8g9HB5xIbZTbyEuJZ56cKywwZvoTZNHXCKY2Ki74ArsKu9H9NiOwf9shgoDghXQc5AZskxzL7wkOyqhSvpjKC
template:
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: sentry
type: Opaque
15 changes: 15 additions & 0 deletions .kontinuous/env/preprod/templates/sentry.sealed-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: sentry
spec:
encryptedData:
SENTRY_AUTH_TOKEN: AgB0+vei/m71QPjqmuo6v9pfgHRy8U9LCuVK2PHzkH5ul8tmgs04r2afwRs877iu+EP4NB6OtjXKG6AFCFmPusi6p35xl/IpqjdA/GlBC9Vwx914YDd46Hn+QoVqqDMmtvNxfuMxuxs5Zwro/5tMJMb6sU31Qyl/8p4Rne18EA2gje/WVK1a91HCb75o2sB0t/M5HgP+oP8Fj1yw1sqbIbnxHaIn4arf7NTEB3DSGrL4NpLtNN1ToQfL8UXH9vCmbLUjinHVSDm5Fkd67hPBqen0HkIdBIheU+LU7ygiiA5Bb470IuKxV9BuCey2CxSKDVNZBDfLuQAZ3uqF8plBoEtPLCeZ4Tda6KOvTnQ72Maj1YE3CLdOaLMtKQTi/Lt3ZcoBJvUEbGck+hmpEQq3QjwZMhmba8ZZX4Y8ymVpQd/LoJYhBM0ftel4kpK4oBlYEC612phPa+d+LywVkv+Vb3QQX4VOynAWhiuS+larg27H3dZ95kHZlzEgKdnUJ0WxfupoZEnyE7EXQ9aA1b+6Jg8GvCFoSCRuBG3WM7VmTCCzI7n/yjbKHTaPRqcLKA0pgvYNqyKiBemuKCRb+i/gzK8LqsdO8bJb3ZYl/H7ysqdWTvz0JLblg6lIMd/dDDjTJ5CWjF1q/RZWKiWigarirlNgnYdkK2iRaQ666KBRb3DoiexpAiBxx2iAsUDLWiVdHsZ8g9HB5xIbZTbyEuJZ56cKywwZvoTZNHXCKY2Ki74ArsKu9H9NiOwf9shgoDghXQc5AZskxzL7wkOyqhSvpjKC
template:
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: sentry
type: Opaque
16 changes: 16 additions & 0 deletions .kontinuous/env/prod/templates/sentry.sealed-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations:
sealedsecrets.bitnami.com/namespace-wide: 'true'
name: sentry
namespace: secretariat
spec:
encryptedData:
SENTRY_AUTH_TOKEN: AgCg6EpuN96oZQ1zbCfciq9w63htn3GtqMwQB5COwLocovcJTk42Z3c1aDp7zkZpDS0rVgUt5zcQuEVoWoZExQOyfmQPxRbFGQnXqbFGYTcekc9mZ1qRTr9Vzl26YQ7OsVegEv+tCX5Njzgm/vrGPHQCQBZQKtVNSzH5ihhu79UNS1G5U6gXhlYzOFEAjQAzKP9UfHcd1lkXfVx9bm0dpnJPyWPjMyJvC7RfAd9SGNJwDuGsGeUH/zbn5XuLHblqV6XvUD4YX/9cBxMvCzcHAwQCrruTxeogoLRXAzWXZye/RqSV/AQ4fPRP0fK+rxzF6sOumP3T7Zmb31/Rb0zv0kozbavdhcsX71nZbMUXJVFNuTqpT24JoMSJnsc/U9vNyya65IDjs18BVsJl2+x01Oc143W/irLzilh7lNriP+YqUcpjoZK9RHtNfyNTJ8ffFd/M3wlvE55WAmTvSzcTivV8oubvM3nREUDihaMGwRSsW24d84Gr3VBM8KlZlm7XEIazmeS7Xt62w/Xgj88b7UWP0+YLH5PlIZnMnoQPVDhnyAOIMAGmp97VVw4AogfuaqZqgQkn+LCTC/DTz68u7vpWSsNRxw835CxaEKB55GT4WpgtGbAvttufeDfvMMrPNswFv8uoI4Ae0a/lb5kKjZOlZIF/dYxu4vJScUFkic6df78NBMLIoX9aB5U/PQPOBLl92vlGDrPzckq+oQMDZmdT5rHPeogjFHHi3AQQOd3gqacq1TV8RGPGryK5vZu4c4Ddop2FK2roqqRabIwlzSI/
template:
metadata:
annotations:
sealedsecrets.bitnami.com/namespace-wide: 'true'
name: sentry
type: Opaque
1 change: 0 additions & 1 deletion .kontinuous/env/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ jobs:
with:
imagePackage: app
buildArgs:
NEXT_PUBLIC_HASURA_URL: "https://hasura-{{ .Values.global.host }}/v1/graphql"
NEXT_PUBLIC_MATOMO_SITE_ID: "82"
NEXT_PUBLIC_MATOMO_URL: "https://matomo.fabrique.social.gouv.fr/"
10 changes: 9 additions & 1 deletion .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ jobs:
with:
imagePackage: app
buildArgs:
NEXT_PUBLIC_HASURA_URL: "https://hasura-{{ .Values.global.host }}/v1/graphql"
NEXT_PUBLIC_HASURA_URL:
"https://hasura-{{ .Values.global.host }}/v1/graphql"
NEXT_PUBLIC_SENTRY_DSN: "https://[email protected]/85"
NEXT_PUBLIC_SENTRY_ENVIRONMENT: "{{ .Values.global.env }}"
NEXT_PUBLIC_SENTRY_RELEASE: "{{ .Values.global.imageTag }}"
secrets:
sentry_auth_token:
secretName: sentry
secretKey: SENTRY_AUTH_TOKEN

build-hasura:
use: build
Expand Down
82 changes: 22 additions & 60 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,66 +1,28 @@
fileignoreconfig:
- filename: .github/workflows/deactivate.yaml
checksum: e0f0138068d1f9a11721ad38ff8b892f8dfbf19854f741fe60ae1d7f291fff22
- filename: .github/workflows/preproduction.yaml
checksum: 852a71100a6bf940df9c77fb911b35e59ab280a4febfec67811f9d0a7f8f4676
- filename: .github/workflows/production.yaml
checksum: 7ae9af137671722308557d0881493f6c0302f6c44a9753696129403930d6169b
- filename: .github/workflows/review-auto.yaml
checksum: 3e14e4a3020b4f6e749ab6e607e08b1f8ea3c7cb445907e843d99909fc1dbb65
- filename: .github/workflows/review.yaml
checksum: 3209ade741c7176f01de5a3a3cdd3d8b852bd68c45755c785dcac68845b30405
- filename: .kontinuous/env/dev/templates/app.sealed-secret.yaml
checksum: fa80c5622c002c66ac217ec37a6f6b33935d42e98fcef60a008a234609c13344
- filename: .kontinuous/env/dev/values.yaml
checksum: 8e57dfc5e7e7fa5e4d6ca8a2174e2ea88ec66b80e165b705a442bc756e8c1a76
- filename: .kontinuous/env/preprod/templates/app.sealed-secret.yaml
checksum: 45302a0bf5121715c7abab561bdcaab85e67f57f4deb932aeeed383292c0cc4b
- filename: .kontinuous/env/preprod/templates/charon.sealed-secret.yaml
checksum: ed2e8250214389ddda47d74a8e27defd392245c4d64966240d6e8a6cb9bbe573
- filename: .kontinuous/env/prod/templates/cnpg-backup-credentials.yaml
checksum: 7eb76edfc4548e0973aa159fb11ca2a1887a114d00c32f498ad50c2f508b91f5
- filename: .kontinuous/env/prod/values.yaml
checksum: 832641aa7d11d88e5f5fb3b94fdf82587bc086ba77433a20b670caf67c8945ea
- filename: .yarn/plugins/@yarnpkg/plugin-fetch.cjs
checksum: d5c4610f916094d84cfcd7a372f3a9fb4cf5af733488bbe04684c384d846f53a
- filename: __tests__/components/__snapshots__/users.test.js.snap
checksum: 690d463633eb908fa7ed3eade9597d8aa9ded3c5d892206e3837596e35d88cd4
- filename: next.config.js
checksum: 855b09fc06f8388ba51dccbaaf7c76375f45c36a89ace9b51cd665d290f1d9f4
- filename: packages/hasura/migrations/default/1696938677969_alter_table_public_users_add_column_email/down.sql
checksum: 1e47fbc2dccbf99c13549c8d6e669c54815be24d7e42f0edd78219377fdc63f4
- filename: packages/hasura/migrations/default/1696938677969_alter_table_public_users_add_column_email/up.sql
checksum: c97a7b91dc05e94fca2ba43f8bc4bb743450cdbb552175bb0c10fee01fe86882
- filename: packages/hasura/migrations/default/1696938751031_alter_table_public_users_add_column_onboardind_request_id/down.sql
checksum: 3f27790c9d3f5c08440f56b3d238f90014352ecf5967b80a93a910459aa6e7b8
- filename: packages/hasura/migrations/default/1696938751031_alter_table_public_users_add_column_onboardind_request_id/up.sql
checksum: 3dbfd37ba006e639f12a4c375fa44626a04c27e2bb5d4356a1782576fff9b199
- filename: packages/hasura/migrations/default/1696938764795_alter_table_public_users_alter_column_email/down.sql
checksum: cc4f4de24bd74f2be73cbdc45f562a3d485826bcc2189b1becce143cde11ccb2
- filename: packages/hasura/migrations/default/1696938764795_alter_table_public_users_alter_column_email/up.sql
checksum: 7fc715964fdbc2fdd70a5316e0ec68dfc0f8255869682ec6abf31b2b71ce4948
- filename: packages/hasura/migrations/default/1696938864227_alter_table_public_users_alter_column_onboardind_request_id/down.sql
checksum: d4a7960f08d3af47c48d30cb3436fdb1739b38078bce92e18f394e2ea4bf9a86
- filename: packages/hasura/migrations/default/1696938864227_alter_table_public_users_alter_column_onboardind_request_id/up.sql
checksum: 623d5d32a6aabc5790d7ae05656b340f8a6c8a55e2d99b767194b98f4bf080f2
- filename: sentry.client.config.js
checksum: c099a2c12302135ea90b784b7f17827d985de03d2b667750551cb9f8cde0ea81
- filename: sentry.edge.config.js
checksum: 1944a74030b8a786b01906e52ee2d9c1304d3867aebe394df7828e98f057bce4
- filename: sentry.server.config.js
checksum: c45afaf7fe0822f1bf966627a0e5e166468d27f6d5151229990f293b37d4302b
- filename: src/components/onboarding/steps/services-accounts-statuses.tsx
checksum: b118715f8269bd92790bbe4019159567893d2517cad7ef2a639e456d924b88ca
- filename: .kontinuous/env/dev/templates/sentry.sealed-secret.yaml
checksum: 6b3eb493305a8c3d24402c99d7a20b01b6650e7fedb2782648c539a70adc4088
- filename: .kontinuous/env/preprod/templates/sentry.sealed-secret.yaml
checksum: fae95a0f658c5920845516eb04659cac883418d135a4bce54615236e47da8df1
- filename: .kontinuous/env/prod/templates/sentry.sealed-secret.yaml
checksum: ef7c23320a02ca66f8a10755bccabc2a487973e9581a4408ed3f4c8685f921f7
- filename: .kontinuous/values.yaml
checksum: 1d67b52046f6e850ff38f806000aa8bb1329cb1f7e6314fbec89bea2009709e3
- filename: Dockerfile
checksum: 14c30aedc55e0f61364c26cf84c28596973f6951f4e0322f2f2693ec84ff513c
- filename: packages/hasura/migrations/default/1691156416829_alter_table_public_users_add_column_disabled/down.sql
checksum: cac3e070c06c7c7fbd6821009fef546e452a38184ac6539ccca609be4a82bd8b
- filename: packages/hasura/migrations/default/1691156416829_alter_table_public_users_add_column_disabled/up.sql
checksum: 390c88e78b3e8bd3153e028403a3ffea2b5da636eeab22c307788cbddb86e096
- filename: src/components/users/toggle-account-modal.tsx
checksum: 2d0bd58b461814a6d2d934d96441ed7962a74f2d184e2581b38b4990562dde70
- filename: src/hooks/use-onboarding.ts
checksum: 84ace93b2abe1dbb750a311a6cee984e9b0392be6176871e7e49d7cdf948cef0
checksum: 004c4c33f375813231a10a7b6399cb7a1c03128ae6c84c6af5fefabff9cd8a81
- filename: src/services/disablers/ovh.ts
checksum: 390c9e51cf01b5db14a4af94a4182c3d55ccddeb7905462b21b0a5f23b8d24e9
- filename: src/services/enablers/ovh.ts
checksum: 5e2adf5acd6e8f769a465b573cd9149226526bbce8402abf3c0cc8d6f5520a3a
- filename: src/services/send-email.ts
checksum: f8e6673f08300673626ad8ce310cfce4037f5feec086d4ce5808e40c09766992
- filename: src/services/sync.ts
checksum: ae6aef4a72d66a3ad64e55a6a9bdd96dea9cdcb55809d1ac1b8bc7adb3d99b07
- filename: src/utils/env.ts
checksum: d7acba9f2c4fb7fc16b2d3b35440e9f0105d299a3b3b499f912b580e7096d25d
- filename: yarn.lock
checksum: b9128943e69440b534f82c27472f838bfea5567d0af222e4e681746eb74a9486
checksum: 0562c88a33c18be479847c12d3c05dfc00b6edea18ffd61b97bc389536d41cb1
scopeconfig:
- scope: node
version: "1.0"
26 changes: 17 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@ WORKDIR /app

# Rebuild the source code only when needed
FROM base AS builder

# install deps
COPY yarn.lock .yarnrc.yml ./
COPY .yarn .yarn
RUN yarn fetch --immutable

COPY . .

# build time args
ARG NEXT_PUBLIC_HASURA_URL
ENV NEXT_PUBLIC_HASURA_URL $NEXT_PUBLIC_HASURA_URL
ARG NEXT_PUBLIC_MATOMO_URL
ENV NEXT_PUBLIC_MATOMO_URL $NEXT_PUBLIC_MATOMO_URL
ARG NEXT_PUBLIC_MATOMO_SITE_ID
ENV NEXT_PUBLIC_MATOMO_SITE_ID $NEXT_PUBLIC_MATOMO_SITE_ID
ARG NEXT_PUBLIC_SENTRY_ENVIRONMENT
ENV NEXT_PUBLIC_SENTRY_ENVIRONMENT $NEXT_PUBLIC_SENTRY_ENVIRONMENT
ARG NEXT_PUBLIC_SENTRY_RELEASE
ENV NEXT_PUBLIC_SENTRY_RELEASE $NEXT_PUBLIC_SENTRY_RELEASE
ARG NEXT_PUBLIC_SENTRY_DSN
ENV NEXT_PUBLIC_SENTRY_DSN $NEXT_PUBLIC_SENTRY_DSN
ENV NEXT_TELEMETRY_DISABLED 1

# install deps
COPY yarn.lock .yarnrc.yml ./
COPY .yarn .yarn
RUN yarn fetch --immutable

# build
COPY . .
RUN yarn build
RUN --mount=type=secret,id=sentry_auth_token export SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token)"; \
yarn build

# Production image, copy all the files and run next
FROM base AS runner
Expand All @@ -30,11 +40,9 @@ ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`when accounts page renders displays login form if session is invalid 1`] = `
exports[`displays login form if session is invalid 1`] = `
<div>
<main>
<div
Expand All @@ -20,7 +20,7 @@ exports[`when accounts page renders displays login form if session is invalid 1`
</div>
`;

exports[`when accounts page renders displays users list if session is valid 1`] = `
exports[`displays users list if session is valid 1`] = `
<div>
<main>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`renders home page 1`] = `
<div>
Expand Down Expand Up @@ -60,8 +60,8 @@ exports[`renders home page 1`] = `
data-nimg="fill"
decoding="async"
sizes="100vw"
src="/_next/image?url=%2Fimg.jpg&w=3840&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=640&q=75 640w, /_next/image?url=%2Fimg.jpg&w=750&q=75 750w, /_next/image?url=%2Fimg.jpg&w=828&q=75 828w, /_next/image?url=%2Fimg.jpg&w=1080&q=75 1080w, /_next/image?url=%2Fimg.jpg&w=1200&q=75 1200w, /_next/image?url=%2Fimg.jpg&w=1920&q=75 1920w, /_next/image?url=%2Fimg.jpg&w=2048&q=75 2048w, /_next/image?url=%2Fimg.jpg&w=3840&q=75 3840w"
src="/public/images/home.svg"
srcset="/public/images/home.svg 640w, /public/images/home.svg 750w, /public/images/home.svg 828w, /public/images/home.svg 1080w, /public/images/home.svg 1200w, /public/images/home.svg 1920w, /public/images/home.svg 2048w, /public/images/home.svg 3840w"
style="position: absolute; top: 0px; left: 0px; bottom: 0px; right: 0px; box-sizing: border-box; padding: 0px; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"
/>
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`renders onboarding page 1`] = `
<div>
Expand Down
25 changes: 0 additions & 25 deletions __tests__/accounts.test.js

This file was deleted.

19 changes: 19 additions & 0 deletions __tests__/accounts.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { render } from "@testing-library/react"
import Accounts from "../src/pages/accounts"
import { vi, it, expect } from "vitest"
import { session } from "../src/mocks/data"

const useSession = vi.hoisted(() => vi.fn())
vi.mock("next-auth/react", () => ({ useSession }))

it("displays login form if session is invalid", () => {
useSession.mockReturnValue({ data: null, status: "unauthenticated" })
const { container } = render(<Accounts />)
expect(container).toMatchSnapshot()
})

it("displays users list if session is valid", () => {
useSession.mockReturnValue({ data: session, status: "authenticated" })
const { container } = render(<Accounts />)
expect(container).toMatchSnapshot()
})
35 changes: 20 additions & 15 deletions __tests__/api/onboarding/confirm.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { createMocks } from "node-mocks-http"
import handleConfirm from "@/pages/api/onboarding/confirm"
import { graphql } from "msw"
import { graphql, HttpResponse } from "msw"
import { sendConfirmMail } from "@/services/send-email"
import { server } from "@/mocks/server"
import { vi, it, expect } from "vitest"

jest.mock("@/utils/log-action", () => jest.fn())
jest.mock("@/utils/jwt", () => ({ getJwt: jest.fn() }))
jest.mock("@/services/send-email", () => ({ sendConfirmMail: jest.fn() }))
jest.mock("@/utils/env", () => ({
ONBOARDING_NOTIFICATION_EMAILS: "mail",
NEXTAUTH_URL: "http://fake.fr",
NEXT_PUBLIC_HASURA_URL: "http://fake.fr",
}))
vi.mock("@/utils/log-action", () => ({ default: vi.fn() }))
vi.mock("@/utils/jwt", () => ({ getJwt: vi.fn() }))
vi.mock("@/services/send-email", () => ({ sendConfirmMail: vi.fn() }))
vi.mock("@/utils/env", async () => {
const actual = await vi.importActual("@/utils/env")
return {
...actual,
ONBOARDING_NOTIFICATION_EMAILS: "mail",
NEXTAUTH_URL: "http://fake.fr",
NEXT_PUBLIC_HASURA_URL: "http://fake.fr",
}
})

it("should confirm request and send email", async () => {
const { req, res } = createMocks({
Expand All @@ -29,15 +34,15 @@ it("should not confirm multiple times", async () => {
query: { id: "fakeId" },
})
server.use(
graphql.mutation("confirmOnboardingRequest", (_req, res, ctx) => {
return res(
ctx.data({
graphql.mutation("confirmOnboardingRequest", () =>
HttpResponse.json({
data: {
update_onboarding_requests: {
affected_rows: 0,
},
})
)
})
},
})
)
)
await handleConfirm(req, res)
expect(res._getStatusCode(200))
Expand Down
Loading

0 comments on commit 5e30e3e

Please sign in to comment.