diff --git a/package-lock.json b/package-lock.json index 21e4d1cd..82ef7e7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@grafana/faro-web-sdk": "1.12.2", "@grafana/faro-web-tracing": "1.12.2", "@navikt/aksel-icons": "7.8.0", - "@navikt/arbeidsforhold": "4.1.2-beta.1", + "@navikt/arbeidsforhold": "4.1.3", "@navikt/ds-css": "7.8.0", "@navikt/ds-react": "7.8.0", "@navikt/fnrvalidator": "2.1.5", @@ -1337,12 +1337,12 @@ "license": "MIT" }, "node_modules/@navikt/arbeidsforhold": { - "version": "4.1.2-beta.1", - "resolved": "https://npm.pkg.github.com/download/@navikt/arbeidsforhold/4.1.2-beta.1/caccfbfef856171e6c585a047cf5dc30af2fc202", - "integrity": "sha512-98SNBv9KfjVyslqo2vbTjL22zzRINpgUjpCDQRcgCJDPBUeSLiZg80mPzU0GKSvcLpLFzbnUXF6IU83TwfB0bQ==", + "version": "4.1.3", + "resolved": "https://npm.pkg.github.com/download/@navikt/arbeidsforhold/4.1.3/f5e860dacd7f34cb3c8fcc2d660231b7c272b622", + "integrity": "sha512-7ddbVQ6INLs9PCILgfyo1THwZkJ7sIKqPgDQAsIfVCUqBlTdv7Q2yNDQGyQ4t1alTVAvuOjTO8uyWccrkOsVow==", "license": "MIT", "dependencies": { - "fetch-mock": "^10.1.0", + "fetch-mock": "^12.2.0", "react-router-dom": "^6.26.2" }, "engines": { @@ -1350,37 +1350,16 @@ "npm": ">=5" }, "peerDependencies": { - "@navikt/aksel-icons": "^7", - "@navikt/ds-css": "^7", - "@navikt/ds-react": "^7", - "@navikt/fnrvalidator": "^2", + "@navikt/aksel-icons": "7", + "@navikt/ds-css": "7", + "@navikt/ds-react": "7", + "@navikt/fnrvalidator": "2", "@react-pdf/renderer": "3.4.4", - "classnames": "^2", - "dayjs": "^1", - "lodash.throttle": "^4", - "react": "^18", - "react-modal": "^3" - } - }, - "node_modules/@navikt/arbeidsforhold/node_modules/fetch-mock": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-10.1.1.tgz", - "integrity": "sha512-R6MwxuGwlUe0K6GzdLY1Wa9voX/GbUBDZjNHBsvlBhrpXurCYpQN4EW0iFCmtWddDTuS0ubR93OtFSgy9E/L2A==", - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "dequal": "^2.0.3", - "globrex": "^0.1.2", - "is-subset": "^0.1.1", - "regexparam": "^3.0.0" - }, - "engines": { - "node": ">=8.0.0" - }, - "peerDependenciesMeta": { - "node-fetch": { - "optional": true - } + "classnames": "2", + "dayjs": "1", + "lodash.throttle": "4", + "react": "18", + "react-modal": "3" } }, "node_modules/@navikt/arbeidsforhold/node_modules/react-router": { @@ -2690,7 +2669,6 @@ "version": "0.4.4", "resolved": "https://registry.npmjs.org/@types/glob-to-regexp/-/glob-to-regexp-0.4.4.tgz", "integrity": "sha512-nDKoaKJYbnn1MZxUY0cA1bPmmgZbg0cTq7Rh13d0KWYNOiKbqoR+2d89SnRPszGh7ROzSwZ/GOjZ4jPbmmZ6Eg==", - "dev": true, "license": "MIT" }, "node_modules/@types/history": { @@ -5535,7 +5513,6 @@ "version": "12.2.0", "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-12.2.0.tgz", "integrity": "sha512-XjgxM582kB0SzPOqH2UdGTwSqga8A8aBPjxcYr0wTeOlCWpZoK6zBrPzltECUTu6Zt3VTWafmKF599LN9BRN5Q==", - "dev": true, "license": "MIT", "dependencies": { "@types/glob-to-regexp": "^0.4.4", @@ -5819,7 +5796,6 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", - "dev": true, "license": "BSD-2-Clause" }, "node_modules/global": { @@ -5857,7 +5833,8 @@ "node_modules/globrex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", - "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==" + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", + "dev": true }, "node_modules/gonzales-pe": { "version": "4.3.0", @@ -6629,16 +6606,11 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-subset": { - "version": "0.1.1", - "license": "MIT" - }, "node_modules/is-subset-of": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/is-subset-of/-/is-subset-of-3.1.10.tgz", "integrity": "sha512-avvaYgVmYWyaZ1NDFiv4y9JGkrE2je3op1Po4VYKKJKR8H2qVPsg1GZuuXl5elCTxTlwAIsrAjWAs4BVrISFRw==", "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, "license": "MIT", "dependencies": { "typedescriptor": "3.0.2" @@ -9868,7 +9840,6 @@ "resolved": "https://registry.npmjs.org/typedescriptor/-/typedescriptor-3.0.2.tgz", "integrity": "sha512-hyVbaCUd18UiXk656g/imaBLMogpdijIEpnhWYrSda9rhvO4gOU16n2nh7xG5lv/rjumnZzGOdz0CEGTmFe0fQ==", "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, "license": "MIT" }, "node_modules/typescript": { diff --git a/package.json b/package.json index a6ffbea5..eae58289 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@grafana/faro-web-sdk": "1.12.2", "@grafana/faro-web-tracing": "1.12.2", "@navikt/aksel-icons": "7.8.0", - "@navikt/arbeidsforhold": "4.1.2-beta.1", + "@navikt/arbeidsforhold": "4.1.3", "@navikt/ds-css": "7.8.0", "@navikt/ds-react": "7.8.0", "@navikt/fnrvalidator": "2.1.5", diff --git a/src/clients/apiMock/index.ts b/src/clients/apiMock/index.ts index 00115e8b..e15dd5a4 100644 --- a/src/clients/apiMock/index.ts +++ b/src/clients/apiMock/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions */ import fetchMock from 'fetch-mock'; import Cookies from 'js-cookie'; import personInformasjon from './app/fetch/person-info.json'; @@ -15,48 +14,32 @@ import auth from './app/fetch/auth.json'; const { VITE_API_URL, VITE_DSOP_URL, VITE_INNLOGGINGSSTATUS_URL } = import.meta.env; -const mockFetchKontaktinfo = true; -const mockFetchPersonalia = true; -const mockFetchDsopInfo = true; -const mockFetchRetningsnumre = true; -const mockFetchLand = true; -const mockFetchValutaer = true; -const mockFetchPostnummer = true; -const mockFetchInst = true; -const mockFetchMedl = true; -const mockFetchAuth = true; - -const mockPostGateadresse = true; -const mockPostSlettTlfnr = true; -const mockPostEndreTelefonnr = true; -const mockPostEndreKontonummer = true; - export const setUpMock = async () => { /* Fetch */ - mockFetchKontaktinfo && fetchMock.get(`${VITE_API_URL}/kontaktinformasjon`, () => delay(200, 750).then(() => kontaktInformasjon)); - mockFetchPersonalia && fetchMock.get(`${VITE_API_URL}/personalia`, () => delay(200, 750).then(() => personInformasjon)); - mockFetchRetningsnumre && fetchMock.get(`${VITE_API_URL}/retningsnumre`, () => delay(400, 500).then(() => retningsnumre)); - mockFetchPostnummer && fetchMock.get(`${VITE_API_URL}/postnummer`, () => delay(10, 50).then(() => postnummer)); - mockFetchValutaer && fetchMock.get(`${VITE_API_URL}/valuta`, () => delay(100, 200).then(() => valutaer)); - mockFetchDsopInfo && fetchMock.get(`${VITE_DSOP_URL}/get`, () => delay(1000, 1500).then(() => dsopInfo)); - mockFetchLand && fetchMock.get(`${VITE_API_URL}/land`, () => delay(1000, 2000).then(() => landInfo)); - mockFetchInst && fetchMock.get(`${VITE_API_URL}/institusjonsopphold`, () => delay(1000, 2000).then(() => instInfo)); - mockFetchMedl && fetchMock.get(`${VITE_API_URL}/medl`, () => delay(1000, 2000).then(() => medlInfo)); - mockFetchAuth && fetchMock.get(`${VITE_INNLOGGINGSSTATUS_URL}`, () => delay(1000, 2000).then(() => auth)); + const globalMock = fetchMock.mockGlobal(); + globalMock.get(`${VITE_INNLOGGINGSSTATUS_URL}`, () => delay(1000, 2000).then(() => auth)); + globalMock.get(`${VITE_API_URL}/kontaktinformasjon`, () => delay(200, 750).then(() => kontaktInformasjon)); + globalMock.get(`${VITE_API_URL}/personalia`, () => delay(200, 750).then(() => personInformasjon)); + globalMock.get(`${VITE_API_URL}/retningsnumre`, () => delay(400, 500).then(() => retningsnumre)); + globalMock.get(`${VITE_API_URL}/postnummer`, () => delay(10, 50).then(() => postnummer)); + globalMock.get(`${VITE_API_URL}/valuta`, () => delay(100, 200).then(() => valutaer)); + globalMock.get(`${VITE_DSOP_URL}/get`, () => delay(1000, 1500).then(() => dsopInfo)); + globalMock.get(`${VITE_API_URL}/land`, () => delay(1000, 2000).then(() => landInfo)); + globalMock.get(`${VITE_API_URL}/institusjonsopphold`, () => delay(1000, 2000).then(() => instInfo)); + globalMock.get(`${VITE_API_URL}/medl`, () => delay(1000, 2000).then(() => medlInfo)); /* POST */ - mockPostGateadresse && fetchMock.post(`${VITE_API_URL}/endreGateadresse`, () => delay(2000, 3000).then(() => ({ statusType: 'PENDING' }))); - mockPostEndreTelefonnr && fetchMock.post(`${VITE_API_URL}/endreTelefonnummer`, () => delay(2000, 3000).then(() => ({ statusType: 'REJECTED' }))); - mockPostSlettTlfnr && fetchMock.post(`${VITE_API_URL}/slettTelefonnummer`, () => delay(2000, 3000).then(() => ({ statusType: 'OK' }))); - mockPostEndreKontonummer && - fetchMock.post(`${VITE_API_URL}/endreKontonummer`, () => + globalMock.post(`${VITE_API_URL}/endreGateadresse`, () => delay(2000, 3000).then(() => ({ statusType: 'PENDING' }))); + globalMock.post(`${VITE_API_URL}/endreTelefonnummer`, () => delay(2000, 3000).then(() => ({ statusType: 'REJECTED' }))); + globalMock.post(`${VITE_API_URL}/slettTelefonnummer`, () => delay(2000, 3000).then(() => ({ statusType: 'OK' }))); + globalMock.post(`${VITE_API_URL}/endreKontonummer`, () => delay(200, 500).then(() => { Cookies.set('kontonr-result', 'success'); return endreKontonr; - }), + }), ); };