From 70a5e630e7791af8bfc8899371114e54618b17fe Mon Sep 17 00:00:00 2001 From: Arthur L-Brjc Date: Wed, 14 Sep 2022 11:11:46 +0200 Subject: [PATCH] fix: restrict next.js version due to swc bug https://github.com/vercel/next.js/issues/40399 resolved by https://github.com/vercel/next.js/pull/40292 --- components/jeune/AjouterJeuneButton.tsx | 42 ++++-- package.json | 5 +- pages/mes-jeunes.tsx | 20 +-- tests/pages/MesJeunes.page.test.tsx | 39 ++---- yarn.lock | 166 ++++++++++++------------ 5 files changed, 128 insertions(+), 144 deletions(-) diff --git a/components/jeune/AjouterJeuneButton.tsx b/components/jeune/AjouterJeuneButton.tsx index 04d6d6d2b..ffa0b2aff 100644 --- a/components/jeune/AjouterJeuneButton.tsx +++ b/components/jeune/AjouterJeuneButton.tsx @@ -1,22 +1,36 @@ -import Button from 'components/ui/Button/Button' +import { useMemo } from 'react' + +import ButtonLink from 'components/ui/Button/ButtonLink' import IconComponent, { IconName } from 'components/ui/IconComponent' +import { StructureConseiller } from 'interfaces/conseiller' interface AjouterJeuneButtonProps { - handleAddJeune: () => void + structure?: StructureConseiller } -export const AjouterJeuneButton = ({ - handleAddJeune, -}: AjouterJeuneButtonProps) => { +export const AjouterJeuneButton = ({ structure }: AjouterJeuneButtonProps) => { + const href = useMemo(() => { + switch (structure) { + case StructureConseiller.MILO: + return '/mes-jeunes/milo/creation-jeune' + case StructureConseiller.POLE_EMPLOI: + return '/mes-jeunes/pole-emploi/creation-jeune' + } + }, [structure]) + return ( - + <> + {href && ( + + + )} + ) } diff --git a/package.json b/package.json index e1883e0d7..9488f1a92 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "dev": "node server.js | pino-pretty", + "watch": "yarn dev", "build": "next build", "start": "NODE_ENV=production node server.js", "lint": "next lint", @@ -29,7 +30,7 @@ "jsonwebtoken": "8.5.1", "luxon": "3.0.3", "matomo-tracker": "2.2.4", - "next": "12.3.0", + "next": "~12.2.0", "next-auth": "4.10.3", "next-logger": "3.0.1", "pino": "8.5.0", @@ -60,7 +61,7 @@ "autoprefixer": "^10.4.9", "css-loader": "^6.7.1", "eslint": "~8.22.0", - "eslint-config-next": "^12.3.0", + "eslint-config-next": "~12.2.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-storybook": "^0.6.4", diff --git a/pages/mes-jeunes.tsx b/pages/mes-jeunes.tsx index d6cc788c7..39382cc7a 100644 --- a/pages/mes-jeunes.tsx +++ b/pages/mes-jeunes.tsx @@ -78,19 +78,6 @@ function MesJeunes({ if (messageEnvoiGroupeSuccess) initialTracking += ' - Succès envoi message' const [trackingTitle, setTrackingTitle] = useState(initialTracking) - const handleAddJeune = async () => { - switch (conseiller?.structure) { - case StructureConseiller.MILO: - await router.push('/mes-jeunes/milo/creation-jeune') - break - case StructureConseiller.POLE_EMPLOI: - await router.push('/mes-jeunes/pole-emploi/creation-jeune') - break - default: - break - } - } - async function closeAjoutAgenceSuccessMessage(): Promise { setShowAjoutAgenceSuccess(false) await router.replace('/mes-jeunes', undefined, { shallow: true }) @@ -200,10 +187,7 @@ function MesJeunes({ {conseillerJeunes.length > 0 && (
- {(conseiller?.structure === StructureConseiller.MILO || - conseiller?.structure === StructureConseiller.POLE_EMPLOI) && ( - - )} +
)} @@ -219,7 +203,7 @@ function MesJeunes({ Vous n'avez pas encore intégré de jeunes.

- + )} diff --git a/tests/pages/MesJeunes.page.test.tsx b/tests/pages/MesJeunes.page.test.tsx index 6f455373f..bc7cb462b 100644 --- a/tests/pages/MesJeunes.page.test.tsx +++ b/tests/pages/MesJeunes.page.test.tsx @@ -37,15 +37,12 @@ jest.mock('utils/injectionDependances/withDependance') describe('Mes Jeunes', () => { describe('client side', () => { - let routerPush: Function let routerReplace: Function let dependances: Pick const jeunes = desJeunesAvecActionsNonTerminees() beforeEach(() => { - routerPush = jest.fn() routerReplace = jest.fn() ;(useRouter as jest.Mock).mockReturnValue({ - push: routerPush, replace: routerReplace, }) @@ -203,19 +200,13 @@ describe('Mes Jeunes', () => { }) }) - it('redirige vers la page de création jeune MILO', async () => { - // GIVEN - const addButton = screen.getByRole('button', { - name: 'Ajouter un bénéficiaire', - }) - - //WHEN - await userEvent.click(addButton) - + it('permer de créer un jeune MILO', async () => { //THEN - expect(routerPush).toHaveBeenCalledWith( - '/mes-jeunes/milo/creation-jeune' - ) + expect( + screen.getByRole('link', { + name: 'Ajouter un bénéficiaire', + }) + ).toHaveAttribute('href', '/mes-jeunes/milo/creation-jeune') }) it("affiche la colonne nombre d'actions des jeunes", () => { @@ -253,19 +244,13 @@ describe('Mes Jeunes', () => { }) }) - it('redirige vers la page de création jeune PE', async () => { - // GIVEN - const addButton = screen.getByRole('button', { - name: 'Ajouter un bénéficiaire', - }) - - //WHEN - await userEvent.click(addButton) - + it('permer de créer un jeune PE', async () => { //THEN - expect(routerPush).toHaveBeenCalledWith( - '/mes-jeunes/pole-emploi/creation-jeune' - ) + expect( + screen.getByRole('link', { + name: 'Ajouter un bénéficiaire', + }) + ).toHaveAttribute('href', '/mes-jeunes/pole-emploi/creation-jeune') }) it("n'affiche pas le nombre d'actions des jeunes", () => { diff --git a/yarn.lock b/yarn.lock index b381301a5..c20be2986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2810,109 +2810,109 @@ __metadata: languageName: node linkType: hard -"@next/env@npm:12.3.0": - version: 12.3.0 - resolution: "@next/env@npm:12.3.0" - checksum: 9f5d0894de00f8827f887dc737b0beebc1f268cc6809dc0f49acbcc035f4398f2af1dccb2c2f470f2ac31ef450ff5214a1a63ddd5c906b3ea52960824a2552be +"@next/env@npm:12.2.5": + version: 12.2.5 + resolution: "@next/env@npm:12.2.5" + checksum: a44939e59b46d5951831529a43dba9daa2e4e467e8680ea96e21ae127d1bf7f11757aaf3a6cff8a51273abfe7af782903e1304405a481361c7ba3e66d47e3238 languageName: node linkType: hard -"@next/eslint-plugin-next@npm:12.3.0": - version: 12.3.0 - resolution: "@next/eslint-plugin-next@npm:12.3.0" +"@next/eslint-plugin-next@npm:12.2.5": + version: 12.2.5 + resolution: "@next/eslint-plugin-next@npm:12.2.5" dependencies: glob: 7.1.7 - checksum: f08582b36ff01a776183b3c33d6d81be3a110c1c3c39c81a33aff91277ea822aa4a952d4f2271a08ce56692ca5c58c9e958aaf4e08348c10cc45a85213b208f0 + checksum: 0d6faf895d4952fc2a5da3f2e86a9e1903f37b44201e7fabfcc994f6989dfceb974f354a7abb1779b318f14ada57925d82eb6c22628265c7f6b36f232edc93ee languageName: node linkType: hard -"@next/swc-android-arm-eabi@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-android-arm-eabi@npm:12.3.0" +"@next/swc-android-arm-eabi@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-android-arm-eabi@npm:12.2.5" conditions: os=android & cpu=arm languageName: node linkType: hard -"@next/swc-android-arm64@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-android-arm64@npm:12.3.0" +"@next/swc-android-arm64@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-android-arm64@npm:12.2.5" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@next/swc-darwin-arm64@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-darwin-arm64@npm:12.3.0" +"@next/swc-darwin-arm64@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-darwin-arm64@npm:12.2.5" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@next/swc-darwin-x64@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-darwin-x64@npm:12.3.0" +"@next/swc-darwin-x64@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-darwin-x64@npm:12.2.5" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@next/swc-freebsd-x64@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-freebsd-x64@npm:12.3.0" +"@next/swc-freebsd-x64@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-freebsd-x64@npm:12.2.5" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@next/swc-linux-arm-gnueabihf@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-linux-arm-gnueabihf@npm:12.3.0" +"@next/swc-linux-arm-gnueabihf@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-linux-arm-gnueabihf@npm:12.2.5" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@next/swc-linux-arm64-gnu@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-linux-arm64-gnu@npm:12.3.0" +"@next/swc-linux-arm64-gnu@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-linux-arm64-gnu@npm:12.2.5" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-arm64-musl@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-linux-arm64-musl@npm:12.3.0" +"@next/swc-linux-arm64-musl@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-linux-arm64-musl@npm:12.2.5" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@next/swc-linux-x64-gnu@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-linux-x64-gnu@npm:12.3.0" +"@next/swc-linux-x64-gnu@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-linux-x64-gnu@npm:12.2.5" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-x64-musl@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-linux-x64-musl@npm:12.3.0" +"@next/swc-linux-x64-musl@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-linux-x64-musl@npm:12.2.5" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-win32-arm64-msvc@npm:12.3.0" +"@next/swc-win32-arm64-msvc@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-win32-arm64-msvc@npm:12.2.5" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@next/swc-win32-ia32-msvc@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-win32-ia32-msvc@npm:12.3.0" +"@next/swc-win32-ia32-msvc@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-win32-ia32-msvc@npm:12.2.5" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@next/swc-win32-x64-msvc@npm:12.3.0": - version: 12.3.0 - resolution: "@next/swc-win32-x64-msvc@npm:12.3.0" +"@next/swc-win32-x64-msvc@npm:12.2.5": + version: 12.2.5 + resolution: "@next/swc-win32-x64-msvc@npm:12.2.5" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -4780,12 +4780,12 @@ __metadata: languageName: node linkType: hard -"@swc/helpers@npm:0.4.11": - version: 0.4.11 - resolution: "@swc/helpers@npm:0.4.11" +"@swc/helpers@npm:0.4.3": + version: 0.4.3 + resolution: "@swc/helpers@npm:0.4.3" dependencies: tslib: ^2.4.0 - checksum: 736857d524b41a8a4db81094e9b027f554004e0fa3e86325d85bdb38f7e6459ce022db079edb6c61ba0f46fe8583b3e663e95f7acbd13e51b8da6c34e45bba2e + checksum: 5c2f173e950dd3929d84ae48b3586a274d5a874e7cf2013b3d8081e4f8c723fa3a4d4e63b263e84bb7f06431f87b640e91a12655410463c81a3dc2bbc15eceda languageName: node linkType: hard @@ -9104,11 +9104,11 @@ __metadata: languageName: node linkType: hard -"eslint-config-next@npm:^12.3.0": - version: 12.3.0 - resolution: "eslint-config-next@npm:12.3.0" +"eslint-config-next@npm:~12.2.0": + version: 12.2.5 + resolution: "eslint-config-next@npm:12.2.5" dependencies: - "@next/eslint-plugin-next": 12.3.0 + "@next/eslint-plugin-next": 12.2.5 "@rushstack/eslint-patch": ^1.1.3 "@typescript-eslint/parser": ^5.21.0 eslint-import-resolver-node: ^0.3.6 @@ -9123,7 +9123,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 50a2e43c515350c689cd848973b953c1d058303b84e05ecba5b5bf0f8feffe3935011de3b574ba35d48de8a5d7d5c42567d21d1a17f02189a701edeb6d76a8e0 + checksum: 21f14cda6c28670e09267c9fc28fe17f9480487c85a322928507bbf61f072c62401bb7d8e79992b176d6a0d64a86419cbd69e475098b083aa5089bb6b572b8e0 languageName: node linkType: hard @@ -13921,28 +13921,28 @@ __metadata: languageName: node linkType: hard -"next@npm:12.3.0": - version: 12.3.0 - resolution: "next@npm:12.3.0" - dependencies: - "@next/env": 12.3.0 - "@next/swc-android-arm-eabi": 12.3.0 - "@next/swc-android-arm64": 12.3.0 - "@next/swc-darwin-arm64": 12.3.0 - "@next/swc-darwin-x64": 12.3.0 - "@next/swc-freebsd-x64": 12.3.0 - "@next/swc-linux-arm-gnueabihf": 12.3.0 - "@next/swc-linux-arm64-gnu": 12.3.0 - "@next/swc-linux-arm64-musl": 12.3.0 - "@next/swc-linux-x64-gnu": 12.3.0 - "@next/swc-linux-x64-musl": 12.3.0 - "@next/swc-win32-arm64-msvc": 12.3.0 - "@next/swc-win32-ia32-msvc": 12.3.0 - "@next/swc-win32-x64-msvc": 12.3.0 - "@swc/helpers": 0.4.11 +"next@npm:~12.2.0": + version: 12.2.5 + resolution: "next@npm:12.2.5" + dependencies: + "@next/env": 12.2.5 + "@next/swc-android-arm-eabi": 12.2.5 + "@next/swc-android-arm64": 12.2.5 + "@next/swc-darwin-arm64": 12.2.5 + "@next/swc-darwin-x64": 12.2.5 + "@next/swc-freebsd-x64": 12.2.5 + "@next/swc-linux-arm-gnueabihf": 12.2.5 + "@next/swc-linux-arm64-gnu": 12.2.5 + "@next/swc-linux-arm64-musl": 12.2.5 + "@next/swc-linux-x64-gnu": 12.2.5 + "@next/swc-linux-x64-musl": 12.2.5 + "@next/swc-win32-arm64-msvc": 12.2.5 + "@next/swc-win32-ia32-msvc": 12.2.5 + "@next/swc-win32-x64-msvc": 12.2.5 + "@swc/helpers": 0.4.3 caniuse-lite: ^1.0.30001332 postcss: 8.4.14 - styled-jsx: 5.0.6 + styled-jsx: 5.0.4 use-sync-external-store: 1.2.0 peerDependencies: fibers: ">= 3.1.0" @@ -13986,7 +13986,7 @@ __metadata: optional: true bin: next: dist/bin/next - checksum: eafed4732d1d3cfdc4ccfdd6e1047d24b29f0d19587a03d46581e77988e4a081d206ad373de98858dfbc7109308fe1ad39d0b8443ea19276fb11fa5634080841 + checksum: e8fcbd93d74fda81640fd174a9d380f22db404d3ce0893730db3db806317ae18c86d1dbb502e63e47c92fb21a93812de62639c2f1204330cb569fdac4d3d0573 languageName: node linkType: hard @@ -14858,7 +14858,7 @@ __metadata: dotenv: 16.0.2 elastic-apm-node: 3.38.0 eslint: ~8.22.0 - eslint-config-next: ^12.3.0 + eslint-config-next: ~12.2.0 eslint-config-prettier: ^8.5.0 eslint-plugin-prettier: ^4.2.1 eslint-plugin-storybook: ^0.6.4 @@ -14869,7 +14869,7 @@ __metadata: jsonwebtoken: 8.5.1 luxon: 3.0.3 matomo-tracker: 2.2.4 - next: 12.3.0 + next: ~12.2.0 next-auth: 4.10.3 next-logger: 3.0.1 node-mocks-http: ^1.11.0 @@ -17755,9 +17755,9 @@ __metadata: languageName: node linkType: hard -"styled-jsx@npm:5.0.6": - version: 5.0.6 - resolution: "styled-jsx@npm:5.0.6" +"styled-jsx@npm:5.0.4": + version: 5.0.4 + resolution: "styled-jsx@npm:5.0.4" peerDependencies: react: ">= 16.8.0 || 17.x.x || ^18.0.0-0" peerDependenciesMeta: @@ -17765,7 +17765,7 @@ __metadata: optional: true babel-plugin-macros: optional: true - checksum: 9e41cb6958fcb980dbfcfee2fb133de61cc0873df9304d2476ab35930679fc3b3c1d968a503c9b0afa459f243c288119e35d0fd31cf3066c2ba0e130c4d2f87e + checksum: db7530155626e5eebc9d80ca117ea5aed6219b0a65469196b0b5727550fbe743117d7eea1499d80511ccb312d31f4a1027a58d1f94a83f0986c9acfdcce8bdd1 languageName: node linkType: hard