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

feat: migrate from CRA4 to Vite, Storybook to v8, jest to Vitest #7285

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5b27bc3
feat: add initial vite config and new eslint rules
karrui Apr 23, 2024
a005e34
feat: replace CRA variables with Vite variables
karrui Apr 24, 2024
94ee411
feat: update ts-config
karrui Apr 24, 2024
b62caaf
feat: remove craco, fix webpack -> esbuild errors
karrui Apr 24, 2024
557f9fd
feat: update vite config for proxy and node polyfills
karrui Apr 24, 2024
f1cf08c
feat: make decryption workers work on Vite
karrui Apr 24, 2024
4012c62
fix: theme typing generation script
karrui Apr 24, 2024
772d2a9
fix: bundle worker as es
karrui Apr 24, 2024
b3f5493
fix: update storybook to work with vite
karrui Apr 24, 2024
cc6f2e1
feat: upgrade to storybook v8 package with vite builder
karrui Apr 24, 2024
5c850dc
fix: remove deprecated turbo-build storybook addon
karrui Apr 24, 2024
18a3390
fix: add missing node-stdlib-browser package
karrui Apr 24, 2024
0e0ea4f
feat: switch to vitest, fix storybook test invocations
karrui Apr 26, 2024
a14a151
feat: format and lint
karrui Apr 26, 2024
e3e4109
feat: update msw package (to v1 latest, not v2 yet)
karrui Apr 26, 2024
ebf0b1b
fix: set svgr loader to not inject default dimensions
karrui Apr 26, 2024
0ef58c2
fix: regression in storybook 7 that removes 100% height from stories
karrui Apr 26, 2024
be17c25
fix: remove preview changes from `.storybook/main.ts`
karrui Apr 26, 2024
da276f9
fix(test): use expect instead of just awaiting canvas.findByText
karrui Apr 26, 2024
cc655c5
fix: flakey toast test due to multiple tests running at the same time
karrui Apr 29, 2024
1f1d89e
fix: modal bounding box for chromatic stories
karrui Apr 29, 2024
fdfcb2d
feat: reuse old github secret env var instead of renaming to VITE_APP
karrui Apr 30, 2024
fbbd1e4
feat: remove unused .builtime-env
karrui Apr 30, 2024
b3c93c0
fix: misrenamed import
karrui Apr 30, 2024
3687d5b
feat: load datadog-chunk as separate script from main react app
karrui Apr 30, 2024
f2a558a
chore: remove unused cmds, update cmds
KenLSM May 20, 2024
2db7cf4
feat: upgrade to react 18 and chakra v2 (#7292)
karrui Jul 30, 2024
1345be1
feat: upgrade typescript to 5.4.5 across app (#7305)
karrui Jul 30, 2024
759cb2e
Merge remote-tracking branch 'origin/develop' into 04-23-feat_add_ini…
KenLSM Jul 30, 2024
379f745
fix: typing errors on setHasSingleSubmissionValidationError for preview
KenLSM Jul 30, 2024
a860902
fix: add partialdeep typing on non-en i18n
KenLSM Jul 30, 2024
a2e7658
fix: additional typing errors on stories
KenLSM Jul 30, 2024
f37bb65
test: remove global playwright timeout, use individual test timeouts
KenLSM Jul 30, 2024
002f140
fix: inifite mounting for StripePaymentContainer
KenLSM Sep 3, 2024
6ff9366
refactor: remove unrendered text
KenLSM Sep 3, 2024
7e780bc
fix: frm-1818 scroll lock trapping
KenLSM Sep 3, 2024
5f348af
fix: frm-1821 folder icon focus border clashing with folder text
KenLSM Sep 5, 2024
55d6f7c
fix: frm-1820 sharpen focus border n calendar
KenLSM Sep 5, 2024
10cf995
fix: frm-1817 insufficient padding between charts and icon
KenLSM Sep 6, 2024
0ceb51d
Merge remote-tracking branch 'origin/develop' into 04-23-feat_add_ini…
KenLSM Sep 13, 2024
a88630a
fix: ts typing, ts config, test config
KenLSM Sep 13, 2024
ec01fc5
fix: missing variable post-merge conflict resolution
KenLSM Sep 18, 2024
2aee35d
fix: fe lint-sort
KenLSM Sep 18, 2024
971c6d9
fix: circular deps warning by rollup
KenLSM Sep 18, 2024
f8514e4
Merge remote-tracking branch 'origin/develop' into 04-23-feat_add_ini…
KenLSM Sep 18, 2024
2998079
fix: FRM-1819 add custom detection element addon flag
KenLSM Sep 18, 2024
dabcfa1
try no logs
KenLSM Sep 18, 2024
380f738
mute all logs
KenLSM Sep 18, 2024
4561bf8
add missing tweetnacl module
KenLSM Sep 18, 2024
bc974ce
revert test code
KenLSM Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 9 additions & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ jobs:
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -64,7 +66,13 @@ jobs:
exitOnceUploaded: true
onlyChanged: true
storybookBaseDir: frontend
allowConsoleErrors: true
logFile: 'chromatic.log'
# Skip running Chromatic on dependabot PRs
skip: dependabot/**
# Only run when the frontend directory has changes
untraced: '!(frontend)/**'
# temp debug options
# debug: true
# diagnosticsFile: true
# logFile: true
28 changes: 14 additions & 14 deletions .github/workflows/deploy-eb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ jobs:
echo "APP_VERSION=$(jq -r .version package.json)-$(echo ${GITHUB_REF##*/})-$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
- name: Inject frontend build env vars
env:
REACT_APP_DD_RUM_APP_ID: ${{ secrets.DD_RUM_APP_ID }}
REACT_APP_DD_RUM_CLIENT_TOKEN: ${{ secrets.DD_RUM_CLIENT_TOKEN }}
REACT_APP_DD_RUM_ENV: ${{ secrets.DD_ENV }}
REACT_APP_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
REACT_APP_GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
REACT_APP_FORMSG_SDK_MODE: ${{ secrets.REACT_APP_FORMSG_SDK_MODE }}
REACT_APP_URL: ${{ secrets.APP_URL }}
VITE_APP_DD_RUM_APP_ID: ${{ secrets.DD_RUM_APP_ID }}
VITE_APP_DD_RUM_CLIENT_TOKEN: ${{ secrets.DD_RUM_CLIENT_TOKEN }}
VITE_APP_DD_RUM_ENV: ${{ secrets.DD_ENV }}
VITE_APP_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
VITE_APP_GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
VITE_APP_FORMSG_SDK_MODE: ${{ secrets.REACT_APP_FORMSG_SDK_MODE }}
VITE_APP_URL: ${{ secrets.APP_URL }}
run: |
sed -i -e "s|@REACT_APP_URL|${{secrets.APP_URL}}|g" -e "s/@REACT_APP_DD_RUM_APP_ID/$REACT_APP_DD_RUM_APP_ID/g" -e "s/@REACT_APP_DD_RUM_CLIENT_TOKEN/$REACT_APP_DD_RUM_CLIENT_TOKEN/g" -e "s/@REACT_APP_DD_RUM_ENV/$REACT_APP_DD_RUM_ENV/g" -e "s/@REACT_APP_VERSION/${{env.APP_VERSION}}/g" -e "s/@REACT_APP_DD_SAMPLE_RATE/$REACT_APP_DD_SAMPLE_RATE/g" frontend/datadog-chunk.ts
echo REACT_APP_VERSION=${{env.APP_VERSION}} > frontend/.env
echo REACT_APP_URL=$REACT_APP_URL > frontend/.env
echo REACT_APP_GA_TRACKING_ID=$REACT_APP_GA_TRACKING_ID >> frontend/.env
echo REACT_APP_FORMSG_SDK_MODE=$REACT_APP_FORMSG_SDK_MODE >> frontend/.env
echo REACT_APP_DD_RUM_CLIENT_TOKEN=$REACT_APP_DD_RUM_CLIENT_TOKEN >> frontend/.env
echo REACT_APP_DD_RUM_ENV=$REACT_APP_DD_RUM_ENV >> frontend/.env
sed -i -e "s|@VITE_APP_URL|${{secrets.APP_URL}}|g" -e "s/@VITE_APP_DD_RUM_APP_ID/$VITE_APP_DD_RUM_APP_ID/g" -e "s/@VITE_APP_DD_RUM_CLIENT_TOKEN/$VITE_APP_DD_RUM_CLIENT_TOKEN/g" -e "s/@VITE_APP_DD_RUM_ENV/$VITE_APP_DD_RUM_ENV/g" -e "s/@VITE_APP_VERSION/${{env.APP_VERSION}}/g" -e "s/@VITE_APP_DD_SAMPLE_RATE/$VITE_APP_DD_SAMPLE_RATE/g" frontend/datadog-chunk.ts
echo VITE_APP_VERSION=${{env.APP_VERSION}} > frontend/.env
echo VITE_APP_URL=$VITE_APP_URL > frontend/.env
echo VITE_APP_GA_TRACKING_ID=$VITE_APP_GA_TRACKING_ID >> frontend/.env
echo VITE_APP_FORMSG_SDK_MODE=$VITE_APP_FORMSG_SDK_MODE >> frontend/.env
echo VITE_APP_DD_RUM_CLIENT_TOKEN=$VITE_APP_DD_RUM_CLIENT_TOKEN >> frontend/.env
echo VITE_APP_DD_RUM_ENV=$VITE_APP_DD_RUM_ENV >> frontend/.env

- name: Configure AWS credentials
uses: aws-actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build
env:
NODE_OPTIONS: --max-old-space-size=4096 --openssl-legacy-provider -r ${{ env.DD_TRACE_PACKAGE }}
REACT_APP_FORMSG_SDK_MODE: 'test'
VITE_APP_FORMSG_SDK_MODE: 'test'
run: npm run build
- name: Run Playwright tests (login)
env:
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ WORKDIR /build
COPY package.json package-lock.json ./
COPY shared/package.json shared/package-lock.json ./shared/
COPY frontend/package.json frontend/package-lock.json ./frontend/
COPY frontend/patches ./frontend/patches

# Allow running of postinstall scripts
# RUN npm config set unsafe-perm true
Expand Down
7 changes: 7 additions & 0 deletions __tests__/e2e/email-submission.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable playwright/expect-expect -- assertions are in helper */
import mongoose from 'mongoose'
import {
BasicField,
Expand Down Expand Up @@ -55,6 +56,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with all fields', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -71,6 +73,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with all fields optional', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS.map((ff) =>
createBlankVersion(createOptionalVersion(ff)),
Expand Down Expand Up @@ -148,6 +151,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with Singpass authentication', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -166,6 +170,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with Corppass authentication', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -184,6 +189,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with SGID authentication', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand Down Expand Up @@ -231,6 +237,7 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with all fields shown by logic', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const { formFields, formLogics } = TEST_ALL_FIELDS_SHOWN_BY_LOGIC
const formSettings = getEmailSettings()
Expand Down
4 changes: 4 additions & 0 deletions __tests__/e2e/encrypt-submission.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable playwright/expect-expect -- assertions are in helper */
import mongoose from 'mongoose'
import {
BasicField,
Expand Down Expand Up @@ -58,6 +59,7 @@ test.describe('Storage form submission', () => {
test('Create and submit storage mode form with all fields', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -74,6 +76,7 @@ test.describe('Storage form submission', () => {
test('Create and submit storage mode form with all fields optional', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const formFields = ALL_FIELDS.map((ff) =>
createBlankVersion(createOptionalVersion(ff)),
Expand All @@ -92,6 +95,7 @@ test.describe('Storage form submission', () => {
test('Create and submit storage mode form with all fields shown by logic', async ({
page,
}) => {
test.setTimeout(60 * 1000)
// Define
const { formFields, formLogics } = TEST_ALL_FIELDS_SHOWN_BY_LOGIC
const formSettings = getEncryptSettings()
Expand Down
2 changes: 1 addition & 1 deletion __tests__/e2e/helpers/createForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const addSettings = async (
// Open the form as the last thing to do!
if (formSettings.status === FormStatus.Public) {
// Go back to general settings, to open the form if necessary!
await page.getByRole('tab', { name: 'General' }).click()
await page.getByRole('tab', { name: 'General' }).dispatchEvent('click')

// Ensure that we are on the general settings page
await expect(
Expand Down
6 changes: 3 additions & 3 deletions __tests__/e2e/helpers/submitForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const authForm = async (
formSettings.authType === FormAuthType.CP
? ' (Corporate)'
: formSettings.authType === FormAuthType.SGID
? ' app'
: ''
? ' app'
: ''
}`,
})
.click()
Expand Down Expand Up @@ -235,7 +235,7 @@ const fillFields = async (
for (let i = 0; i < vals.length; i++) {
if (optionNums[i] === -1) {
// Click and fill "Others", which is always the last element.
await options.last().click()
await options.last().dispatchEvent('click')
await page
.locator(`[name="${field._id}.othersInput"]`)
.fill(vals[i])
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ services:
# Bearer token API key format
- API_KEY_VERSION=v1
# env vars for growthbook
- GROWTHBOOK_CLIENT_KEY
- GROWTHBOOK_CLIENT_KEY=growthbook_client_key
# env vars for virus scanner
- VIRUS_SCANNER_LAMBDA_FUNCTION_NAME=function
- WOGAA_SECRET_KEY
Expand Down
6 changes: 3 additions & 3 deletions docs/DEPLOYMENT_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ Forms can be protected with [recaptcha](https://www.google.com/recaptcha/about/)

[Google Analytics](https://analytics.google.com/analytics/web) is used to track website traffic. Examples of events include number of visits to various forms, number of successful submissions and number of submission failures.

| Variable | Description |
| :------------------------- | ----------------------------- |
| `REACT_APP_GA_TRACKING_ID` | Google Analytics tracking ID. |
| Variable | Description |
| :------------------------ | ----------------------------- |
| `VITE_APP_GA_TRACKING_ID` | Google Analytics tracking ID. |

#### SMS with Twilio

Expand Down
10 changes: 0 additions & 10 deletions frontend/.buildtime-env

This file was deleted.

4 changes: 3 additions & 1 deletion frontend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

node_modules

CREDITS.md
CREDITS.md

!.storybook
86 changes: 0 additions & 86 deletions frontend/.eslintrc

This file was deleted.

Loading
Loading