Skip to content

Commit

Permalink
Merge pull request #569 from navikt/fikser-feil-ved-start-lokalt
Browse files Browse the repository at this point in the history
Fikser feil ved start lokalt
  • Loading branch information
terjeofnorway authored Jan 5, 2025
2 parents 3c3f738 + 3a7a6e0 commit 2cfa037
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 79 deletions.
61 changes: 16 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 16 additions & 33 deletions src/clients/apiMock/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
}),
}),
);
};

Expand Down

0 comments on commit 2cfa037

Please sign in to comment.