Skip to content

Commit

Permalink
Fix PDF generation when using subform (#2663)
Browse files Browse the repository at this point in the history
* fix subform pdf

* add cypress test for PDF with subform
  • Loading branch information
bjosttveit authored Oct 30, 2024
1 parent cd6ca96 commit c6f3e4c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/layout/Subform/Summary/SubformSummaryComponent2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const DoSummaryWrapper = ({
textResourceBindings={{ title }}
/>
<Heading
className='no-visual-testing'
spacing={false}
size={'sm'}
level={2}
Expand Down
4 changes: 0 additions & 4 deletions src/utils/layout/NodesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ function IndicateReadiness() {
// Doing this in a selector instead of a useEffect() so that we don't have to re-render
document.body.setAttribute('data-nodes-ready', ready.toString());

if (!GeneratorDebug.displayReadiness) {
return [null, null];
}

return [s.readiness, s.hiddenViaRulesRan];
});

Expand Down
34 changes: 34 additions & 0 deletions test/e2e/integration/subform-test/subform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,38 @@ describe('Subform test', () => {
cy.findByRole('button', { name: /neste/i }).should('be.visible');
cy.get(appFrontend.errorReport).should('not.exist');
});

it('PDF should include subforms', () => {
cy.findByRole('textbox', { name: /navn/i }).type('Per');
cy.findByRole('textbox', { name: /alder/i }).type('28');

cy.findByRole('button', { name: /legg til moped/i }).click();
cy.findByRole('textbox', { name: /registreringsnummer/i }).type('ABC123');
cy.findByRole('textbox', { name: /merke/i }).type('Digdir');
cy.findByRole('textbox', { name: /modell/i }).type('Scooter2000');
cy.findByRole('textbox', { name: /produksjonsår/i }).type('2024');
cy.findByRole('button', { name: /ferdig/i }).click();

cy.findByRole('button', { name: /legg til moped/i }).click();
cy.findByRole('textbox', { name: /registreringsnummer/i }).type('XYZ987');
cy.findByRole('textbox', { name: /merke/i }).type('Altinn');
cy.findByRole('textbox', { name: /modell/i }).type('3.0');
cy.findByRole('textbox', { name: /produksjonsår/i }).type('2030');
cy.findByRole('button', { name: /ferdig/i }).click();

cy.testPdf('subform', () => {
cy.getSummary('Navn').should('contain.text', 'Per');
cy.getSummary('Alder').should('contain.text', '28 år');

cy.getSummary('Registreringsnummer').eq(0).should('contain.text', 'ABC123');
cy.getSummary('Merke').eq(0).should('contain.text', 'Digdir');
cy.getSummary('Modell').eq(0).should('contain.text', 'Scooter2000');
cy.getSummary('Produksjonsår').eq(0).should('contain.text', '2024');

cy.getSummary('Registreringsnummer').eq(1).should('contain.text', 'XYZ987');
cy.getSummary('Merke').eq(1).should('contain.text', 'Altinn');
cy.getSummary('Modell').eq(1).should('contain.text', '3.0');
cy.getSummary('Produksjonsår').eq(1).should('contain.text', '2030');
});
});
});

0 comments on commit c6f3e4c

Please sign in to comment.