Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mgunnerud committed Dec 13, 2024
1 parent b0d84f4 commit de5af30
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,10 @@
"policy_editor.access_package_all_packages": "Alle tilgangspakker",
"policy_editor.access_package_chosen_packages": "Valgte tilgangspakker",
"policy_editor.access_package_header": "Tilgangspakker",
"policy_editor.access_package_loading_services": "Laster tjenester",
"policy_editor.access_package_no_services": "Denne tilgangspakken inneholder ingen tjenester enda",
"policy_editor.access_package_remove": "fjern tilgangspakke {{packageName}}",
"policy_editor.access_package_search": "Søk i tilgangspakker",
"policy_editor.access_package_services": "Tjenester i denne tilgangspakken:",
"policy_editor.access_package_warning_body": "Altinn-rollene fases snart ut, og da vil rollene som er lagt til, ikke lenger være gyldig. Du må derfor legge til minst en Tilgangspakke for å unngå at regelen blir ugyldig.",
"policy_editor.access_package_warning_header": "Tilgangspakker tar over for Altinn-rollene",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const resource = {
organization: '974761076',
orgcode: 'skd',
},
logoUrl: 'https://altinncdn.no/orgs/skd/skd.png',
logoUrl: '',
};

describe('PolicyAccessPackageAccordion', () => {
Expand Down Expand Up @@ -69,7 +69,9 @@ describe('PolicyAccessPackageAccordion', () => {
const user = userEvent.setup();
const getAccessPackageServices = jest
.fn()
.mockImplementation(() => Promise.resolve([resource]));
.mockImplementation(() =>
Promise.resolve([{ ...resource, logoUrl: 'https://altinncdn.no/orgs/skd/skd.png' }]),
);

renderAccordion({ getAccessPackageServices });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export const PolicyAccessPackageAccordion = ({
extraHeaderContent={selectPackageElement}
onOpened={onOpenAccordion}
>
{isLoading && <StudioSpinner spinnerTitle='Laster tjenester...' />}
{isLoading && (
<StudioSpinner spinnerTitle={t('policy_editor.access_package_loading_services')} />
)}
{services?.length > 0 && (
<>
<div className={classes.serviceContainerHeader}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { queriesMock } from 'app-shared/mocks/queriesMock';
const skattPackage = {
id: 'urn:altinn:accesspackage:skatt',
urn: 'urn:altinn:accesspackage:skatt',
name: 'Sjøfart',
name: 'Skatt',
description: '',
};

Expand Down Expand Up @@ -114,6 +114,16 @@ describe('PolicyAccessPackages', () => {

expect(packageCheckbox).not.toBeChecked();
});

it('should filter list on search', async () => {
const user = userEvent.setup();
renderAccessPackages();

const searchField = screen.getByLabelText(textMock('policy_editor.access_package_search'));
await user.type(searchField, 'Sjø');

expect(screen.getByText('Sjøfart')).toBeInTheDocument();
});
});

const renderAccessPackages = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ export const PolicyAccessPackages = (): React.ReactElement => {
<StudioLabelAsParagraph size='sm' spacing>
{t('policy_editor.access_package_header')}
</StudioLabelAsParagraph>
<StudioTextfield
label='Søk'
size='small'
value={searchValue}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => handleSearch(event.target.value)}
/>
{chosenAccessPackages.length > 0 && (
<>
<StudioLabelAsParagraph size='xs' spacing>
Expand All @@ -143,6 +137,12 @@ export const PolicyAccessPackages = (): React.ReactElement => {
.map(renderAccessPackageAccordion)}
</>
)}
<StudioTextfield
label={t('policy_editor.access_package_search')}
size='small'
value={searchValue}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => handleSearch(event.target.value)}
/>
<StudioLabelAsParagraph size='xs' spacing>
{t('policy_editor.access_package_all_packages')}
</StudioLabelAsParagraph>
Expand Down

0 comments on commit de5af30

Please sign in to comment.