From c6f3e4c2c53f2e2511413a2c29303ee4bb9cf931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20=C3=98sttveit?= <47412359+bjosttveit@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:11:00 +0100 Subject: [PATCH] Fix PDF generation when using subform (#2663) * fix subform pdf * add cypress test for PDF with subform --- .../Summary/SubformSummaryComponent2.tsx | 1 + src/utils/layout/NodesContext.tsx | 4 --- test/e2e/integration/subform-test/subform.ts | 34 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/layout/Subform/Summary/SubformSummaryComponent2.tsx b/src/layout/Subform/Summary/SubformSummaryComponent2.tsx index b0036fb08c..6f5a1ee6cd 100644 --- a/src/layout/Subform/Summary/SubformSummaryComponent2.tsx +++ b/src/layout/Subform/Summary/SubformSummaryComponent2.tsx @@ -96,6 +96,7 @@ const DoSummaryWrapper = ({ textResourceBindings={{ title }} /> { 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'); + }); + }); });