diff --git a/test/e2e/integration/component-library/address.ts b/test/e2e/integration/component-library/address.ts index 1aabb1a3c..ce79753c6 100644 --- a/test/e2e/integration/component-library/address.ts +++ b/test/e2e/integration/component-library/address.ts @@ -1,36 +1,8 @@ +import { fillInAddressAndVerify } from 'test/e2e/integration/component-library/utils/fillAddressAndVerify'; import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; const appFrontend = new AppFrontend(); -export const fillInAddressAndVerify = (address: string, co: string, zip: string, houseNumber: string) => { - cy.gotoNavPage('Adresse'); - cy.get('#address_address_AddressPage-Address').type(address); - cy.get('#address_care_of_AddressPage-Address').type(co); - cy.get('#address_zip_code_AddressPage-Address').type(zip); - cy.get('#address_house_number_AddressPage-Address').type(houseNumber); - - // Verify Gateadresse (Street address) - cy.get('[data-testid="summary-single-value-component"]') - .eq(0) - .find('span.fds-paragraph') - .should('have.text', address); - - // Verify C/O eller annan tilleggsadresse (C/O or additional address) - cy.get('[data-testid="summary-single-value-component"]').eq(1).find('span.fds-paragraph').should('have.text', co); - - // Verify Postnr (Postal code) - cy.get('[data-testid="summary-single-value-component"]').eq(2).find('span.fds-paragraph').should('have.text', zip); - - // Verify Poststad (City) - cy.get('[data-testid="summary-single-value-component"]').eq(3).find('span.fds-paragraph').should('have.text', 'OSLO'); - - // Verify Bustadnummer (House number) - cy.get('[data-testid="summary-single-value-component"]') - .eq(4) - .find('span.fds-paragraph') - .should('have.text', houseNumber); -}; - describe('Address component', () => { it('Should focus the correct element when navigating from an error', () => { cy.startAppInstance(appFrontend.apps.componentLibrary, { authenticationLevel: '2' }); diff --git a/test/e2e/integration/component-library/dropdown.ts b/test/e2e/integration/component-library/dropdown.ts index d830aff9c..684e642fc 100644 --- a/test/e2e/integration/component-library/dropdown.ts +++ b/test/e2e/integration/component-library/dropdown.ts @@ -7,7 +7,7 @@ describe('Dropdown component', () => { const testText = 'Moped'; cy.startAppInstance(appFrontend.apps.componentLibrary, { authenticationLevel: '2' }); - cy.gotoNavPage('DropdownPage'); + cy.gotoNavPage('Dropdown'); cy.get('#form-content-DropdownPage-RadioButtons').click(); cy.get('div[role="listbox"]').contains('span', testText).click(); cy.get('[data-testid="summary-single-value-component"]') diff --git a/test/e2e/integration/component-library/fileupload.ts b/test/e2e/integration/component-library/fileupload.ts index d743af9f0..17a6dfc45 100644 --- a/test/e2e/integration/component-library/fileupload.ts +++ b/test/e2e/integration/component-library/fileupload.ts @@ -1,52 +1,11 @@ +import { + uploadFileAndVerify, + uploadFileWithTagAndVerify, +} from 'test/e2e/integration/component-library/utils/uploadFileAndVerify'; import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; const appFrontend = new AppFrontend(); -const makeTestFile = (fileName: string) => ({ - fileName, - mimeType: 'application/pdf', - lastModified: Date.now(), - contents: Cypress.Buffer.from('hello world'), -}); - -export const uploadFileAndVerify = (fileName: string) => { - cy.gotoNavPage('FileUploadPage'); - cy.get('[data-componenttype="FileUpload"]').first().should('be.visible'); - - cy.get('[data-componenttype="FileUpload"]') - .first() - .find('input[type="file"]') - .selectFile(makeTestFile(fileName), { force: true }); - - cy.get('[data-testid="file-upload-table-summary"]').first().should('be.visible'); - cy.get('[data-testid="file-upload-table-summary"]') - .first() - .find('tr') - .find('td') - .contains('td', 'uploadThis.pdf') - .should('exist'); -}; - -export const uploadFileWithTagAndVerify = (fileName: string, fileType: string) => { - cy.gotoNavPage('FileUploadPage'); - cy.get('[data-componenttype="FileUploadWithTag"]').first().should('be.visible'); - cy.get('[data-componenttype="FileUploadWithTag"]') - .first() - .find('input[type="file"]') - .selectFile(makeTestFile(fileName), { force: true }); - cy.contains('label', 'Filtype').click(); - cy.get('div[role="listbox"]').contains('span', fileType).click(); - cy.get('input[id^="attachment-tag-dropdown-"]').should(($input) => { - expect($input.val()).to.eq(fileType); - }); - cy.get('button[id^=attachment-save-tag-button]').click(); - - cy.get('[data-testid="tagFile-summary"]').first().should('be.visible'); - cy.get('[data-testid="tagFile-summary"]').first().find('tr').find('td').contains('td', fileName).should('exist'); - - cy.get('[data-testid="tagFile-summary"]').first().find('tr').find('td').contains('td', fileType).should('exist'); -}; - describe('FileUpload summary test', () => { beforeEach(() => { cy.startAppInstance(appFrontend.apps.componentLibrary, { authenticationLevel: '2' }); diff --git a/test/e2e/integration/component-library/input.ts b/test/e2e/integration/component-library/input.ts index 3f89c2c63..91fd72e9e 100644 --- a/test/e2e/integration/component-library/input.ts +++ b/test/e2e/integration/component-library/input.ts @@ -1,13 +1,8 @@ +import { fillInInputAndVerify } from 'test/e2e/integration/component-library/utils/inputAndVerify'; import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; const appFrontend = new AppFrontend(); -export const fillInInputAndVerify = (text: string) => { - cy.gotoNavPage('Kort svar'); - cy.get('#InputPage-Input').type(text); - cy.get('[data-testid="summary-single-value-component"]').eq(0).find('span.fds-paragraph').should('have.text', text); -}; - describe('Input component', () => { it('Renders the summary2 component with correct text', () => { cy.startAppInstance(appFrontend.apps.componentLibrary, { authenticationLevel: '2' }); diff --git a/test/e2e/integration/component-library/multiple-select.ts b/test/e2e/integration/component-library/multiple-select.ts index 961fe7f2b..542dfd64d 100644 --- a/test/e2e/integration/component-library/multiple-select.ts +++ b/test/e2e/integration/component-library/multiple-select.ts @@ -5,7 +5,7 @@ const appFrontend = new AppFrontend(); describe('Multiple select component', () => { it('Renders the summary2 component with correct text for MultipleSelext', () => { cy.startAppInstance(appFrontend.apps.componentLibrary, { authenticationLevel: '2' }); - cy.gotoNavPage('MultipleSelectPage'); + cy.gotoNavPage('Flervalg'); // Define the text for the last three checkboxes diff --git a/test/e2e/integration/component-library/summary-of-previous-task.ts b/test/e2e/integration/component-library/summary-of-previous-task.ts index 2486384cd..1bbab6b98 100644 --- a/test/e2e/integration/component-library/summary-of-previous-task.ts +++ b/test/e2e/integration/component-library/summary-of-previous-task.ts @@ -1,6 +1,9 @@ -import { fillInAddressAndVerify } from 'test/e2e/integration/component-library/address'; -import { uploadFileAndVerify, uploadFileWithTagAndVerify } from 'test/e2e/integration/component-library/fileupload'; -import { fillInInputAndVerify } from 'test/e2e/integration/component-library/input'; +import { fillInAddressAndVerify } from 'test/e2e/integration/component-library/utils/fillAddressAndVerify'; +import { fillInInputAndVerify } from 'test/e2e/integration/component-library/utils/inputAndVerify'; +import { + uploadFileAndVerify, + uploadFileWithTagAndVerify, +} from 'test/e2e/integration/component-library/utils/uploadFileAndVerify'; import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; const appFrontend = new AppFrontend(); @@ -23,7 +26,7 @@ describe('Render summary of previous task', () => { uploadFileAndVerify(fileName); uploadFileWithTagAndVerify(fileName, fileType); - cy.get('#navigation-menu').find('button').contains('15. Oppsummering 2.0').click(); + cy.get('#navigation-menu').find('button').contains('16. Oppsummering 2.0').click(); cy.contains('button', 'Send inn').click(); diff --git a/test/e2e/integration/component-library/utils/fillAddressAndVerify.ts b/test/e2e/integration/component-library/utils/fillAddressAndVerify.ts new file mode 100644 index 000000000..c81d54e4e --- /dev/null +++ b/test/e2e/integration/component-library/utils/fillAddressAndVerify.ts @@ -0,0 +1,28 @@ +export const fillInAddressAndVerify = (address: string, co: string, zip: string, houseNumber: string) => { + cy.gotoNavPage('Adresse'); + cy.get('#address_address_AddressPage-Address').type(address); + cy.get('#address_care_of_AddressPage-Address').type(co); + cy.get('#address_zip_code_AddressPage-Address').type(zip); + cy.get('#address_house_number_AddressPage-Address').type(houseNumber); + + // Verify Gateadresse (Street address) + cy.get('[data-testid="summary-single-value-component"]') + .eq(0) + .find('span.fds-paragraph') + .should('have.text', address); + + // Verify C/O eller annan tilleggsadresse (C/O or additional address) + cy.get('[data-testid="summary-single-value-component"]').eq(1).find('span.fds-paragraph').should('have.text', co); + + // Verify Postnr (Postal code) + cy.get('[data-testid="summary-single-value-component"]').eq(2).find('span.fds-paragraph').should('have.text', zip); + + // Verify Poststad (City) + cy.get('[data-testid="summary-single-value-component"]').eq(3).find('span.fds-paragraph').should('have.text', 'OSLO'); + + // Verify Bustadnummer (House number) + cy.get('[data-testid="summary-single-value-component"]') + .eq(4) + .find('span.fds-paragraph') + .should('have.text', houseNumber); +}; diff --git a/test/e2e/integration/component-library/utils/inputAndVerify.ts b/test/e2e/integration/component-library/utils/inputAndVerify.ts new file mode 100644 index 000000000..fd52474c4 --- /dev/null +++ b/test/e2e/integration/component-library/utils/inputAndVerify.ts @@ -0,0 +1,5 @@ +export const fillInInputAndVerify = (text: string) => { + cy.gotoNavPage('Kort svar'); + cy.get('#InputPage-Input').type(text); + cy.get('[data-testid="summary-single-value-component"]').eq(0).find('span.fds-paragraph').should('have.text', text); +}; diff --git a/test/e2e/integration/component-library/utils/uploadFileAndVerify.ts b/test/e2e/integration/component-library/utils/uploadFileAndVerify.ts new file mode 100644 index 000000000..a26cbfcb6 --- /dev/null +++ b/test/e2e/integration/component-library/utils/uploadFileAndVerify.ts @@ -0,0 +1,44 @@ +export const makeTestFile = (fileName: string) => ({ + fileName, + mimeType: 'application/pdf', + lastModified: Date.now(), + contents: Cypress.Buffer.from('hello world'), +}); + +export const uploadFileAndVerify = (fileName: string) => { + cy.gotoNavPage('Filopplasting'); + cy.get('[data-componenttype="FileUpload"]').first().should('be.visible'); + + cy.get('[data-componenttype="FileUpload"]') + .first() + .find('input[type="file"]') + .selectFile(makeTestFile(fileName), { force: true }); + + cy.get('[data-testid="file-upload-table-summary"]').first().should('be.visible'); + cy.get('[data-testid="file-upload-table-summary"]') + .first() + .find('tr') + .find('td') + .contains('td', 'uploadThis.pdf') + .should('exist'); +}; + +export const uploadFileWithTagAndVerify = (fileName: string, fileType: string) => { + cy.gotoNavPage('Filopplasting'); + cy.get('[data-componenttype="FileUploadWithTag"]').first().should('be.visible'); + cy.get('[data-componenttype="FileUploadWithTag"]') + .first() + .find('input[type="file"]') + .selectFile(makeTestFile(fileName), { force: true }); + cy.contains('label', 'Filtype').click(); + cy.get('div[role="listbox"]').contains('span', fileType).click(); + cy.get('input[id^="attachment-tag-dropdown-"]').should(($input) => { + expect($input.val()).to.eq(fileType); + }); + cy.get('button[id^=attachment-save-tag-button]').click(); + + cy.get('[data-testid="tagFile-summary"]').first().should('be.visible'); + cy.get('[data-testid="tagFile-summary"]').first().find('tr').find('td').contains('td', fileName).should('exist'); + + cy.get('[data-testid="tagFile-summary"]').first().find('tr').find('td').contains('td', fileType).should('exist'); +};