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

Slår av skrivetilgang #260

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28d75ac
Slår av skrivetilgang
MrFjellstad Sep 13, 2023
e40d77e
Setter rettigheter på en annen måte
MrFjellstad Sep 20, 2023
963fd20
Sonar fikser (#261)
MrFjellstad Sep 13, 2023
27e7f07
Fix refusjon arbeidsgiverperiode (#262)
MrFjellstad Sep 13, 2023
0492317
Tillater ikke negative tall (#263)
MrFjellstad Sep 13, 2023
1aede0d
Riktige mockdata
MrFjellstad Sep 13, 2023
b908e62
Bruker ny parserIso
MrFjellstad Sep 13, 2023
701859e
v0.2.8
MrFjellstad Sep 14, 2023
10cb7fb
Sonar (#264)
MrFjellstad Sep 15, 2023
9ee3990
logger litt anderledes (#265)
MrFjellstad Sep 18, 2023
9e2e197
v0.2.9
MrFjellstad Sep 18, 2023
5c7b850
Kvittering andre system (#274)
MrFjellstad Sep 19, 2023
51d9050
Bump docker/login-action from 2 to 3 (#266)
dependabot[bot] Sep 19, 2023
674a90d
Bump docker/setup-buildx-action from 2 to 3 (#267)
dependabot[bot] Sep 19, 2023
60cd9a4
Bump @vitest/ui from 0.33.0 to 0.34.4 (#269)
dependabot[bot] Sep 19, 2023
3cdc009
Bump docker/build-push-action from 4 to 5 (#268)
dependabot[bot] Sep 19, 2023
ef9ab45
Bump @types/node from 20.6.0 to 20.6.2 (#270)
dependabot[bot] Sep 19, 2023
4bca773
Bump @grafana/faro-web-tracing from 1.1.4 to 1.2.0 (#273)
dependabot[bot] Sep 19, 2023
57e39a4
Bump @testing-library/cypress from 9.0.0 to 10.0.1 (#271)
dependabot[bot] Sep 19, 2023
5a8c59b
Bump @testing-library/user-event from 14.4.3 to 14.5.1 (#272)
dependabot[bot] Sep 19, 2023
126fe94
v0.2.10
MrFjellstad Sep 19, 2023
b99a0f1
Venter med å gjøre knappen tilgjengelig til dokumentet er sendt inn, …
MrFjellstad Sep 20, 2023
1c15a9f
v0.2.11
MrFjellstad Sep 20, 2023
e815dd0
Utkommentert kode
MrFjellstad Sep 20, 2023
47e094a
Mode fix
MrFjellstad Sep 20, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '20.x'
Expand All @@ -81,13 +81,13 @@ jobs:
# path: build
#
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '20.x'
Expand All @@ -81,13 +81,13 @@ jobs:
# path: build
#
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc ./
RUN --mount=type=secret,id=NODE_AUTH_TOKEN \
echo '//npm.pkg.github.com/:_authToken='$(cat /run/secrets/NODE_AUTH_TOKEN) >> .npmrc

# RUN npm config set always-auth true # Er ikke støttet lengre, men kan den bare slettes?

RUN yarn --frozen-lockfile --ignore-scripts


Expand Down Expand Up @@ -58,8 +56,10 @@ COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs --chmod=444 /app/.next/standalone ./

COPY --from=builder --chown=nextjs:nodejs --chmod=444 /app/.next/static ./.next/static


USER nextjs

Expand Down
259 changes: 259 additions & 0 deletions __tests__/components/Aarsaksvelger.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Aarsaksvelger from '../../components/Bruttoinntekt/Aarsaksvelger';
import { vi } from 'vitest';
import parseIsoDate from '../../utils/parseIsoDate';

// Mock the ResizeObserver
const ResizeObserverMock = vi.fn(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn()
}));

// Stub the global ResizeObserver
vi.stubGlobal('ResizeObserver', ResizeObserverMock);

const IntersectionObserverMock = vi.fn(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
takeRecords: vi.fn(),
unobserve: vi.fn()
}));

vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
vi.stubGlobal('ResizeObserver', IntersectionObserverMock);

describe('Aarsaksvelger', () => {
const changeMaanedsintektHandler = vi.fn();
const changeBegrunnelseHandler = vi.fn();
const clickTilbakestillMaanedsinntekt = vi.fn();
const setTariffEndringsdato = vi.fn();
const setTariffKjentdato = vi.fn();
const visFeilmeldingsTekst = vi.fn();

it('renders the component', () => {
render(
<Aarsaksvelger
bruttoinntekt={undefined}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);
expect(screen.getByLabelText('Månedsinntekt')).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: /Tilbakestill/i
})
).toBeInTheDocument();
});

it('calls the changeMaanedsintektHandler function when the input value changes', async () => {
render(
<Aarsaksvelger
bruttoinntekt={undefined}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);
const user = userEvent.setup();
const input = screen.getByLabelText(/edsinntekt/);
await user.type(input, '20000');
expect(changeMaanedsintektHandler).toHaveBeenCalledTimes(5);
});

it('calls the changeBegrunnelseHandler function when the select value changes', async () => {
render(
<Aarsaksvelger
bruttoinntekt={undefined}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);
const user = userEvent.setup();

const select = screen.getByLabelText('Velg endringsårsak');
await user.selectOptions(select, 'Bonus');
expect(changeBegrunnelseHandler).toHaveBeenCalledTimes(1);
expect(changeBegrunnelseHandler).toHaveBeenCalledWith('Bonus');
});

it('calls the clickTilbakestillMaanedsinntekt function when the button is clicked', () => {
render(
<Aarsaksvelger
bruttoinntekt={undefined}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);
const button = screen.getByRole('button', {
name: /Tilbakestill/i
});
button.click();
expect(clickTilbakestillMaanedsinntekt).toHaveBeenCalledTimes(1);
});

it('calls the changeBegrunnelseHandler function when the Varig lønnsendring is selected', async () => {
render(
<Aarsaksvelger
bruttoinntekt={undefined}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);

const user = userEvent.setup();
const select = screen.getByLabelText('Velg endringsårsak');

await user.selectOptions(select, 'Varig lønnsendring');

expect(changeBegrunnelseHandler).toHaveBeenCalledWith('VarigLonnsendring');
});

it('calls the setTariffKjentdato function when the TariffendringDato component is used', async () => {
render(
<Aarsaksvelger
bruttoinntekt={{ bruttoInntekt: 1000, endringsaarsak: 'Tariffendring', manueltKorrigert: false }}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={vi.fn}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
/>
);

const user = userEvent.setup();

await waitFor(() => screen.getByLabelText('Dato tariffendring ble kjent'));
const input = screen.getByLabelText('Dato tariffendring ble kjent');
userEvent.clear(input);
userEvent.type(input, '2022-01-01');
expect(setTariffKjentdato).toHaveBeenCalledTimes(1);

const inputGjelderFra = screen.getByLabelText('Tariffendring gjelder fra');
userEvent.clear(inputGjelderFra);
userEvent.type(inputGjelderFra, '2022-01-01');
expect(setTariffEndringsdato).toHaveBeenCalledTimes(1);
});

it.skip('calls the setFeriePeriode function when the endringsaarsak is ferie', async () => {
const setFeriePeriode = vi.fn();

render(
<Aarsaksvelger
bruttoinntekt={{ bruttoInntekt: 1000, endringsaarsak: 'Ferie', manueltKorrigert: false }}
changeMaanedsintektHandler={changeMaanedsintektHandler}
changeBegrunnelseHandler={changeBegrunnelseHandler}
clickTilbakestillMaanedsinntekt={clickTilbakestillMaanedsinntekt}
tariffendringsdato={new Date()}
tariffkjentdato={new Date()}
setTariffEndringsdato={setTariffEndringsdato}
setTariffKjentdato={setTariffKjentdato}
visFeilmeldingsTekst={visFeilmeldingsTekst}
setFeriePeriode={setFeriePeriode}
setPermisjonPeriode={vi.fn}
setPermitteringPeriode={vi.fn}
setNyStillingDato={vi.fn}
setNyStillingsprosentDato={vi.fn}
setLonnsendringDato={vi.fn}
setSykefravaerPeriode={vi.fn}
nyInnsending={false}
ferie={[{ fom: undefined, tom: undefined, id: '1' }]}
/>
);

const user = userEvent.setup();

const input = screen.getByLabelText('Fra');
await user.clear(input);
await user.type(input, '02.02.2022');
expect(setFeriePeriode).toHaveBeenCalledWith([
{
fom: parseIsoDate('2022-02-02'),
id: '1',
tom: undefined
}
]);
});
});
37 changes: 37 additions & 0 deletions __tests__/components/KvitteringAnnetSystem.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { render } from '@testing-library/react';
import KvitteringAnnetSystem from '../../components/KvitteringAnnetSystem/KvitteringAnnetSystem';

describe('KvitteringAnnetSystem', () => {
it('should render the component with the correct props', () => {
const props = {
arkivreferanse: '123456',
lenkeTilKvittering: 'Kvittering',
lenkeTilKvitteringHref: 'https://example.com/kvittering',
eksterntSystem: 'Eksternt system',
mottattDato: '2022-01-01'
};

const { getByText } = render(<KvitteringAnnetSystem {...props} />);

expect(getByText('Mottatt inntektsmelding')).toBeInTheDocument();
expect(getByText('Denne inntektsmeldingen er mottatt fra et eksternt system')).toBeInTheDocument();
expect(getByText(/Vi har mottatt denne inntektsmeldingen fra Eksternt system/)).toBeInTheDocument();
expect(getByText(`Arkivreferanse: [${props.arkivreferanse}]`)).toBeInTheDocument();
expect(getByText(props.lenkeTilKvittering)).toHaveAttribute('href', props.lenkeTilKvitteringHref);
});

it('should render the component without optional props', () => {
const props = {
eksterntSystem: 'Eksternt system'
};

const { getByText, queryByText } = render(<KvitteringAnnetSystem {...props} />);

expect(getByText('Mottatt inntektsmelding')).toBeInTheDocument();
expect(getByText('Denne inntektsmeldingen er mottatt fra et eksternt system')).toBeInTheDocument();
expect(getByText(/Vi har mottatt denne inntektsmeldingen fra Eksternt system/)).toBeInTheDocument();
expect(queryByText('Arkivreferanse:')).toBeNull();
expect(queryByText('Eventuell lenke til kvittering')).toBeNull();
});
});
Loading
Loading