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

Ungdomsytelsen #2577

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/ungdomsytelse-deltaker/api-mock/mock-server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const mockPath = `${__dirname}/data`;
const soker = 'søker1';

const søkerFileName = `søker-mock.json`;
const barnFileName = `barn-mock.json`;
const innvilgetVedtakFileName = `innvilget-vedtak-mock.json`;
const ikkeInnvilgetVedtakFileName = `ikke-innvilget-vedtak-mock.json`;

Expand All @@ -79,13 +80,19 @@ const startExpressServer = () => {
}, 250);
});

server.get('/oppslag/barn', (req, res) => {
setTimeout(() => {
readMockFile(barnFileName, res);
}, 250);
});

server.get('/deltakelse/register/hent/alle', (req, res) => {
const response = [
{
id: '123',
programperiodeFraOgMed: '2024-07-01',
programperiodeTilOgMed: '2025-06-30',
harSøkt: true,
harSøkt: false,
rapporteringsPerioder: [
{
fraOgMed: '2024-07-01',
Expand Down
4 changes: 4 additions & 0 deletions apps/ungdomsytelse-deltaker/mock/msw/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { setupWorker } from 'msw/browser';
import { handlers } from './handlers/handlers';

export const worker = setupWorker(...handlers);
50 changes: 50 additions & 0 deletions apps/ungdomsytelse-deltaker/mock/msw/handlers/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { delay, http, HttpResponse } from 'msw';
import { søker1Mock } from '../mocks/soker1';
import { deltakelserIkkeSøkt } from '../mocks/soker1/deltakelser/ikkeSøkt';
import { deltakelserHarSøkt } from '../mocks/soker1/deltakelser/harSøkt';

const MellomlagringStorageKey = 'mellomlagring-ungdomsytelse-deltaker-soknad';

export const handlers = [
http.post('*amplitude*', () => new HttpResponse(null, { status: 200 })),
http.post('*hotjar*', () => new HttpResponse(null, { status: 200 })),
http.get('**/oppslag/soker', () => {
return HttpResponse.json(søker1Mock.søker);
}),
http.get('**/oppslag/barn', () => {
return HttpResponse.json(søker1Mock.barn);
}),
http.get('**/oppslag/arbeidsgiver', () => {
return HttpResponse.json(søker1Mock.arbeidsgiver);
}),
http.post('**/soknad/innsending', () => {
return HttpResponse.json({});
}),
http.get('**/deltakelse/register/hent/alle', () => {
const harSøkt = false;
return HttpResponse.json(harSøkt ? deltakelserHarSøkt : deltakelserIkkeSøkt);
}),
http.get('**/person/personopplysninger-api/personalia', () => {
return HttpResponse.json(søker1Mock.personalia);
}),
http.get(`**/mellomlagring/UNGDOMSYTELSE_DELTAKER_SOKNAD`, async () => {
const data = localStorage.getItem(MellomlagringStorageKey);
const jsonData = JSON.parse(JSON.stringify(data) || '{}');
await delay(350);
return new HttpResponse(jsonData, { status: 200 });
}),
http.post(`**/mellomlagring/UNGDOMSYTELSE_DELTAKER_SOKNAD`, async ({ request }) => {
const data = await request.text();
localStorage.setItem(MellomlagringStorageKey, data);
return new HttpResponse(null, { status: 200 });
}),
http.put(`**/mellomlagring/UNGDOMSYTELSE_DELTAKER_SOKNAD`, async ({ request }) => {
const data = await request.text();
localStorage.setItem(MellomlagringStorageKey, data);
return new HttpResponse(null, { status: 200 });
}),
http.delete(`**/mellomlagring/UNGDOMSYTELSE_DELTAKER_SOKNAD`, () => {
localStorage.setItem(MellomlagringStorageKey, '');
return new HttpResponse(null, { status: 200 });
}),
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const arbeidsgiverMock = {
organisasjoner: [
{
navn: 'HAUGEN AS',
organisasjonsnummer: '123451234',
ansattFom: '2019-09-25',
ansattTom: null,
},
],
};
11 changes: 11 additions & 0 deletions apps/ungdomsytelse-deltaker/mock/msw/mocks/soker1/barnMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const barnMock = {
barn: [
{
fornavn: 'ALFABETISK',
etternavn: 'TURLØYPE',
aktørId: '2811762539343',
fødselsdato: '2019-06-08',
fødselsnummer: '08861999573',
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export const deltakelserHarSøkt = [
{
id: '123',
programperiodeFraOgMed: '2024-07-01',
programperiodeTilOgMed: '2025-06-30',
harSøkt: true,
rapporteringsPerioder: [
{
fraOgMed: '2024-07-01',
tilOgMed: '2024-07-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-08-01',
tilOgMed: '2024-08-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-09-01',
tilOgMed: '2024-09-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-10-01',
tilOgMed: '2024-10-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-11-01',
tilOgMed: '2024-11-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-12-01',
tilOgMed: '2024-12-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-01-01',
tilOgMed: '2025-01-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-02-01',
tilOgMed: '2025-02-28',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-03-01',
tilOgMed: '2025-03-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-04-01',
tilOgMed: '2025-04-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-05-01',
tilOgMed: '2025-05-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-06-01',
tilOgMed: '2025-06-30',
harRapportert: false,
inntekt: null,
},
],
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export const deltakelserIkkeSøkt = [
{
id: '123',
programperiodeFraOgMed: '2024-07-01',
programperiodeTilOgMed: '2025-06-30',
harSøkt: false,
rapporteringsPerioder: [
{
fraOgMed: '2024-07-01',
tilOgMed: '2024-07-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-08-01',
tilOgMed: '2024-08-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-09-01',
tilOgMed: '2024-09-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-10-01',
tilOgMed: '2024-10-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-11-01',
tilOgMed: '2024-11-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-12-01',
tilOgMed: '2024-12-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-01-01',
tilOgMed: '2025-01-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-02-01',
tilOgMed: '2025-02-28',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-03-01',
tilOgMed: '2025-03-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-04-01',
tilOgMed: '2025-04-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-05-01',
tilOgMed: '2025-05-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-06-01',
tilOgMed: '2025-06-30',
harRapportert: false,
inntekt: null,
},
],
},
];
82 changes: 82 additions & 0 deletions apps/ungdomsytelse-deltaker/mock/msw/mocks/soker1/hentAlle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export const hentAlleResponse = [
{
id: '123',
programperiodeFraOgMed: '2024-07-01',
programperiodeTilOgMed: '2025-06-30',
harSøkt: false,
rapporteringsPerioder: [
{
fraOgMed: '2024-07-01',
tilOgMed: '2024-07-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-08-01',
tilOgMed: '2024-08-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-09-01',
tilOgMed: '2024-09-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-10-01',
tilOgMed: '2024-10-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-11-01',
tilOgMed: '2024-11-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2024-12-01',
tilOgMed: '2024-12-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-01-01',
tilOgMed: '2025-01-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-02-01',
tilOgMed: '2025-02-28',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-03-01',
tilOgMed: '2025-03-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-04-01',
tilOgMed: '2025-04-30',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-05-01',
tilOgMed: '2025-05-31',
harRapportert: false,
inntekt: null,
},
{
fraOgMed: '2025-06-01',
tilOgMed: '2025-06-30',
harRapportert: false,
inntekt: null,
},
],
},
];
11 changes: 11 additions & 0 deletions apps/ungdomsytelse-deltaker/mock/msw/mocks/soker1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { arbeidsgiverMock } from './arbeidsgiverMock';
import { barnMock } from './barnMock';
import { personaliaMock } from './personaliaMock';
import { søkerMock } from './søkerMock';

export const søker1Mock = {
barn: barnMock,
søker: søkerMock,
arbeidsgiver: arbeidsgiverMock,
personalia: personaliaMock,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { PersonaliaApiData } from '../../../../src/api/types';

export const personaliaMock: PersonaliaApiData = {
personalia: {
kontoregisterStatus: 'FAILURE',
kontonr: '97105351740',
utenlandskbank: null,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const søkerMock = {
aktørId: '2320509955297',
fødselsdato: '2005-06-02',
fødselsnummer: '02869599258',
fornavn: 'Test',
mellomnavn: null,
etternavn: 'Brukeresen',
};
Loading
Loading