From a038d6f57665f4b004bb4804af9d481f49783d7f Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 11:19:24 +0000 Subject: [PATCH] [TS-106] e2e tests (Old-age-pension) --- .../mocks/nationalRegistry.mocks.ts | 162 ++++++++++ .../acceptance/mocks/parentalLeave.mock.ts | 264 ++++++++++++++++ .../socialInsuranceAdministration.mock.ts | 74 +++++ .../acceptance/old-age-pension.spec.ts | 278 +++++++++++++++++ .../acceptance/setup-xroad.mocks.ts | 291 +----------------- .../src/forms/OldAgePensionForm.ts | 1 + .../src/forms/Prerequisites.ts | 3 + 7 files changed, 793 insertions(+), 280 deletions(-) create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mocks.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/parentalLeave.mock.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/socialInsuranceAdministration.mock.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mocks.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mocks.ts new file mode 100644 index 000000000000..e6230479794a --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mocks.ts @@ -0,0 +1,162 @@ +import { Response } from '@anev/ts-mountebank' +import { NationalRegistry } from '../../../../../../../../infra/src/dsl/xroad' +import { addXroadMock } from '../../../../../support/wire-mocks' + +export const loadNationalRegistryXroadMocks = async () => { + /* Gervimaður Afríka */ + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitala: '0101303019', + nafn: 'Gervimaður Afríka', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'Afríka', + fulltNafn: 'Gervimaður Afríka', + kynkodi: '1', + bannmerking: false, + faedingardagur: new Date('1930-01-01T00:00:00'), + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/hjuskapur', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitalaMaka: '0101307789', + nafnMaka: 'Gervimaður útlönd', + hjuskaparkodi: '1', + breytt: '2021-05-26T22:23:40.513', + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/rikisfang', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kodi: 'IS', + land: 'Ísland', + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/buseta', + prefixType: 'only-base-path', + response: new Response().withJSONBody([ + { + huskodi: '000031440040', + fasteignanumer: '', + heimilisfang: 'Gullengi 4', + postnumer: '112', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + landakodi: 'IS', + breytt: '2022-07-04T00:00:00', + }, + { + huskodi: '99XT00000000', + fasteignanumer: '', + heimilisfang: 'Afríka ótilgreint', + postnumer: null, + stadur: 'Afríka ótilgreint', + sveitarfelagsnumer: null, + landakodi: 'XT', + breytt: '1992-11-16T00:00:00', + }, + ]), + }) + + /* Gervimaður útlönd */ + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101307789', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitala: '0101307789', + nafn: 'Gervimaður útlönd', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'útlönd', + fulltNafn: 'Gervimaður útlönd', + kynkodi: '1', + bannmerking: false, + faedingardagur: new Date('1930-01-01T00:00:00'), + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101307789/hjuskapur', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitalaMaka: '0101303019', + nafnMaka: 'Gervimaður Afríka', + hjuskaparkodi: '1', + breytt: '2021-05-26T22:23:40.513', + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101307789/rikisfang', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kodi: 'IS', + land: 'Ísland', + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101307789/faedingarstadur', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + sveitarfelagsnumer: '0000', + stadur: 'Reykjavík', + faedingardagur: '1930-01-01T00:00:00', + }), + }) + + /* Lyklar */ + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/lyklar/hjuskaparkodar/1/1', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kodi: '1', + lysing: 'Ógiftur', + }), + }) +} diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/parentalLeave.mock.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/parentalLeave.mock.ts new file mode 100644 index 000000000000..8b122fee172a --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/parentalLeave.mock.ts @@ -0,0 +1,264 @@ +import { HttpMethod, Response } from '@anev/ts-mountebank' +import addDays from 'date-fns/addDays' +import addMonths from 'date-fns/addMonths' +import formatISO from 'date-fns/formatISO' +import { + Labor, + NationalRegistry, +} from '../../../../../../../../infra/src/dsl/xroad' +import { addXroadMock } from '../../../../../support/wire-mocks' + +export const loadParentalLeaveXroadMocks = async () => { + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitala: '0101303019', + nafn: 'Gervimaður Afríka', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'Afríka', + fulltNafn: 'Gervimaður Afríka', + kynkodi: '1', + bannmerking: false, + faedingardagur: new Date('1930-01-01T00:00:00'), + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/1111111119', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitala: '1111111119', + nafn: 'Stubbur Maack', + eiginnafn: 'Stubbur', + millinafn: null, + kenninafn: 'Maack', + fulltNafn: 'Stubbur Maack', + kynkodi: '3', + bannmerking: false, + faedingardagur: new Date('2011-11-11T00:00:00'), + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101307789', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitala: '0101307789', + nafn: 'Gervimaður útlönd', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'útlönd', + fulltNafn: 'Gervimaður útlönd', + kynkodi: '1', + bannmerking: false, + faedingardagur: new Date('1930-01-01T00:00:00'), + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/forsja', + prefixType: 'only-base-path', + response: new Response().withJSONBody(['1111111119']), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/forsja/1111111119', + prefixType: 'only-base-path', + response: new Response().withJSONBody(['0101307789']), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/hjuskapur', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + kennitalaMaka: '0101307789', + nafnMaka: 'Gervimaður útlönd', + hjuskaparkodi: '3', + breytt: '2021-05-26T22:23:40.513', + }), + }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/fjolskyldumedlimir', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + fjolskyldunumer: '0101303019', + einstaklingar: [ + { + kennitala: '0101303019', + nafn: 'Gervimaður Afríka', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'Afríka', + fulltNafn: 'Gervimaður Afríka', + kynkodi: '1', + bannmerking: false, + faedingardagur: '1930-01-01T00:00:00', + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }, + { + kennitala: '0101307789', + nafn: 'Gervimaður útlönd', + eiginnafn: 'Gervimaður', + millinafn: null, + kenninafn: 'útlönd', + fulltNafn: 'Gervimaður útlönd', + kynkodi: '1', + bannmerking: false, + faedingardagur: '1930-01-01T00:00:00', + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }, + { + kennitala: '1111111119', + nafn: 'Stubbur Maack', + eiginnafn: 'Stubbur', + millinafn: null, + kenninafn: 'Maack', + fulltNafn: 'Stubbur Maack', + kynkodi: '3', + bannmerking: false, + faedingardagur: '2011-11-11T00:00:00', + logheimili: { + heiti: 'Engihjalli 3', + postnumer: '200', + stadur: 'Kópavogur', + sveitarfelagsnumer: '1000', + }, + adsetur: { + heiti: 'Fellsmúli 2', + postnumer: '108', + stadur: 'Reykjavík', + sveitarfelagsnumer: '0000', + }, + }, + ], + }), + }) + await addXroadMock({ + config: Labor, + prefix: 'XROAD_VMST_API_PATH', + apiPath: '/users/0101303019/parental-leaves/periods/length', + response: new Response().withJSONBody({ + periodLength: 98, + }), + prefixType: 'base-path-with-env', + serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', + }) + await addXroadMock({ + config: Labor, + prefix: 'XROAD_VMST_API_PATH', + serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', + apiPath: '/users/0101303019/parental-leaves', + response: [ + new Response().withJSONBody({ + status: 'TestOK', + }), + new Response().withJSONBody({ + status: 'OK', + id: '23234', + }), + ], + prefixType: 'base-path-with-env', + method: HttpMethod.POST, + }) + await addXroadMock({ + config: Labor, + prefix: 'XROAD_VMST_API_PATH', + serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', + apiPath: '/users/0101303019/parental-leaves', + response: [ + new Response().withJSONBody({ + parentalLeaves: [], + }), + ], + prefixType: 'base-path-with-env', + method: HttpMethod.GET, + }) + const babyBDayRandomFactor = Math.ceil(Math.random() * 85) + await addXroadMock({ + config: Labor, + prefix: 'XROAD_VMST_API_PATH', + serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', + apiPath: '/users/0101303019/pregnancy-status', + response: [ + new Response().withJSONBody({ + hasActivePregnancy: true, + expectedDateOfBirth: formatISO( + addDays(addMonths(new Date(), 6), babyBDayRandomFactor), + { + representation: 'date', + }, + ), + }), + ], + prefixType: 'base-path-with-env', + }) +} diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/socialInsuranceAdministration.mock.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/socialInsuranceAdministration.mock.ts new file mode 100644 index 000000000000..2186b7ed3b4c --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/socialInsuranceAdministration.mock.ts @@ -0,0 +1,74 @@ +import { HttpMethod, Response } from '@anev/ts-mountebank' +import { SocialInsuranceAdministration } from '../../../../../../../../infra/src/dsl/xroad' +import { addXroadMock } from '../../../../../support/wire-mocks' + +export const loadSocialInsuranceAdministrationXroadMocks = async () => { + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/General/currencies', + prefixType: 'only-base-path', + response: new Response().withJSONBody([ + 'ZAR', + 'AUD', + 'CAD', + 'CHF', + 'DKK', + 'EUR', + 'GBP', + 'NOK', + 'PLN', + 'SEK', + 'USD', + 'LVL', + 'CZK', + 'SKK', + 'IKR', + 'LTL', + 'VND', + 'BGN', + 'RUB', + 'CNY', + 'ALL', + 'LEI', + 'UAH', + 'HUF', + ]), + }) + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/Applicant', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + emailAddress: 'mail@mail.is', + phoneNumber: null, + bankAccount: { + bank: '2222', + ledger: '00', + accountNumber: '123456', + }, + }), + }) + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/Applicant/oldagepension/eligible', + prefixType: 'only-base-path', + response: new Response().withJSONBody({ + isEligible: true, + reason: null, + reasonCode: null, + }), + }) + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/Application/oldagepension', + response: new Response().withJSONBody({ + applicationLineId: 1234567, + }), + prefixType: 'only-base-path', + method: HttpMethod.POST, + }) +} diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts new file mode 100644 index 000000000000..56f973e863c3 --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts @@ -0,0 +1,278 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { oldAgePensionFormMessage } from '@island.is/application/templates/social-insurance-administration/old-age-pension' +import { test as base, expect, Page } from '@playwright/test' +import { + disableI18n, + disablePreviousApplications, +} from '../../../../support/disablers' +import { label } from '../../../../support/i18n' +import { helpers } from '../../../../support/locator-helpers' +import { session } from '../../../../support/session' +import { setupXroadMocks } from './setup-xroad.mocks' + +const homeUrl = '/umsoknir/ellilifeyrir' + +const applicationTest = base.extend<{ applicationPage: Page }>({ + applicationPage: async ({ browser }, use) => { + const applicationContext = await session({ + browser, + homeUrl, + phoneNumber: '0103019', // Gervimaður Afríka + idsLoginOn: true, + }) + + const applicationPage = await applicationContext.newPage() + await disablePreviousApplications(applicationPage) + await disableI18n(applicationPage) + await applicationPage.goto(homeUrl) + await expect(applicationPage).toBeApplication() + await setupXroadMocks() + await use(applicationPage) + + await applicationPage.close() + await applicationContext.close() + }, +}) + +applicationTest.describe('Old Age Pension', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + await applicationTest.step('Select type of application', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.pre.applicationTypeTitle), + }), + ).toBeVisible() + await page.getByTestId('old-age-pension').click() + await proceed() + }) + + await applicationTest.step('Agree to data providers', async () => { + await expect( + page.getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.pre.externalDataSection, + ), + }), + ).toBeVisible() + await page.getByTestId('agree-to-data-providers').click() + await proceed() + }) + + await applicationTest.step( + 'Answer pension fund question and start application', + async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.pre.questionTitle), + }), + ).toBeVisible() + await page + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.yes), + }) + .click() + await page + .getByRole('button', { + name: label( + socialInsuranceAdministrationMessage.pre.startApplication, + ), + }) + .click() + }, + ) + + await applicationTest.step('Fill in applicant info', async () => { + await expect( + page.getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.info.infoSubSectionTitle, + ), + }), + ).toBeVisible() + + const phoneNumber = page.getByRole('textbox', { + name: label( + socialInsuranceAdministrationMessage.info.applicantPhonenumber, + ), + }) + await phoneNumber.selectText() + await phoneNumber.fill('6555555') + await proceed() + }) + + await applicationTest.step('Fill in payment information', async () => { + await expect( + page.getByRole('heading', { + name: label(socialInsuranceAdministrationMessage.payment.title), + }), + ).toBeVisible() + const paymentBank = page.getByRole('textbox', { + name: label(socialInsuranceAdministrationMessage.payment.bank), + }) + await paymentBank.selectText() + await paymentBank.fill('051226054678') + + await page + .getByRole('region', { + name: label( + socialInsuranceAdministrationMessage.payment.personalAllowance, + ), + }) + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.yes), + }) + .click() + + const personalAllowance = page.getByTestId('personal-allowance-usage') + await personalAllowance.selectText() + await personalAllowance.fill('100') + + await page + .getByRole('region', { + name: label(socialInsuranceAdministrationMessage.payment.taxLevel), + }) + .getByRole('radio', { + name: label( + socialInsuranceAdministrationMessage.payment.taxIncomeLevel, + ), + }) + .click() + await proceed() + }) + + await applicationTest.step('One payment per year', async () => { + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.onePaymentPerYear.onePaymentPerYearTitle, + ), + }), + ).toBeVisible() + await page + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.no), + }) + .click() + await proceed() + }) + + await applicationTest.step('View residence history', async () => { + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.residence.residenceHistoryTitle, + ), + }), + ).toBeVisible() + await proceed() + }) + + await applicationTest.step('Select period', async () => { + await expect( + page.getByRole('heading', { + name: label(socialInsuranceAdministrationMessage.period.title), + }), + ).toBeVisible() + + await page.getByTestId('select-period.year').click() + await page.keyboard.press('Enter') + + // TODO: Need to look into this, it may happen that a month is not valid + await page.getByTestId('select-period.month').click() + await page.keyboard.press('ArrowUp') + await page.keyboard.press('Enter') + await proceed() + }) + + await applicationTest.step( + 'Upload attachments for pension payments', + async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.fileUpload.pensionFileTitle), + }), + ).toBeVisible() + await proceed() + }, + ) + + await applicationTest.step( + 'Check that additional documents header is visible', + async () => { + await expect( + page.getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.fileUpload + .additionalFileTitle, + ), + }), + ).toBeVisible() + await proceed() + }, + ) + + await applicationTest.step('Write comment', async () => { + await expect( + page.getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.additionalInfo + .commentSection, + ), + }), + ).toBeVisible() + await page + .getByPlaceholder( + label( + socialInsuranceAdministrationMessage.additionalInfo + .commentPlaceholder, + ), + ) + .fill( + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vehicula malesuada augue, sit amet pulvinar tortor pellentesque at. Nulla facilisi. Nunc vel mi ac mi commodo rhoncus sit amet ut neque.', + ) + await proceed() + }) + + await applicationTest.step('Submit application', async () => { + await expect( + page + .locator('form') + .getByRole('paragraph') + .filter({ + hasText: label( + socialInsuranceAdministrationMessage.confirm.overviewTitle, + ), + }), + ).toBeVisible() + await page + .getByRole('button', { + name: label( + socialInsuranceAdministrationMessage.confirm.submitButton, + ), + }) + .click() + }) + + await applicationTest.step( + 'Check that conclusion screen header is visible', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedAwaitingIncomePlanTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) + }, + ) +}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/setup-xroad.mocks.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/setup-xroad.mocks.ts index 7cc248b10d7d..b697f6cfa07c 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/setup-xroad.mocks.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/setup-xroad.mocks.ts @@ -1,288 +1,20 @@ -import { - addXroadMock, - resetMocks, - wildcard, -} from '../../../../support/wire-mocks' -import { HttpMethod, Response } from '@anev/ts-mountebank' -import { EinstaklingsupplysingarToJSON } from '@island.is/clients/national-registry-v2' -import { - Base, - Labor, - NationalRegistry, -} from '../../../../../../../infra/src/dsl/xroad' -import { PostParentalLeaveResponseToJSON } from '@island.is/clients/vmst' -import formatISO from 'date-fns/formatISO' -import addDays from 'date-fns/addDays' -import addMonths from 'date-fns/addMonths' import { getEnvVariables } from '../../../../../../../infra/src/dsl/service-to-environment/pre-process-service' -import { env } from '../../../../support/urls' import { EnvironmentConfig } from '../../../../../../../infra/src/dsl/types/charts' +import { Base } from '../../../../../../../infra/src/dsl/xroad' +import { env } from '../../../../support/urls' +import { resetMocks, wildcard } from '../../../../support/wire-mocks' +import { loadParentalLeaveXroadMocks } from './mocks/parentalLeave.mock' +import { loadSocialInsuranceAdministrationXroadMocks } from './mocks/socialInsuranceAdministration.mock' +import { loadNationalRegistryXroadMocks } from './mocks/nationalRegistry.mocks' export const setupXroadMocks = async () => { await resetMocks() - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101303019', - prefixType: 'only-base-path', - response: new Response().withJSONBody( - EinstaklingsupplysingarToJSON({ - kennitala: '0101303019', - nafn: 'Gervimaður Afríka', - eiginnafn: 'Gervimaður', - millinafn: null, - kenninafn: 'Afríka', - fulltNafn: 'Gervimaður Afríka', - kynkodi: '1', - bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }), - ), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/1111111119', - prefixType: 'only-base-path', - response: new Response().withJSONBody( - EinstaklingsupplysingarToJSON({ - kennitala: '1111111119', - nafn: 'Stubbur Maack', - eiginnafn: 'Stubbur', - millinafn: null, - kenninafn: 'Maack', - fulltNafn: 'Stubbur Maack', - kynkodi: '3', - bannmerking: false, - faedingardagur: new Date('2011-11-11T00:00:00'), - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }), - ), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101307789', - prefixType: 'only-base-path', - response: new Response().withJSONBody( - EinstaklingsupplysingarToJSON({ - kennitala: '0101307789', - nafn: 'Gervimaður útlönd', - eiginnafn: 'Gervimaður', - millinafn: null, - kenninafn: 'útlönd', - fulltNafn: 'Gervimaður útlönd', - kynkodi: '1', - bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }), - ), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101303019/forsja', - prefixType: 'only-base-path', - response: new Response().withJSONBody(['1111111119']), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101303019/forsja/1111111119', - prefixType: 'only-base-path', - response: new Response().withJSONBody(['0101307789']), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101303019/hjuskapur', - prefixType: 'only-base-path', - response: new Response().withJSONBody({ - kennitalaMaka: '0101307789', - nafnMaka: 'Gervimaður útlönd', - hjuskaparkodi: '3', - breytt: '2021-05-26T22:23:40.513', - }), - }) - await addXroadMock({ - config: NationalRegistry, - prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', - apiPath: '/api/v1/einstaklingar/0101303019/fjolskyldumedlimir', - prefixType: 'only-base-path', - response: new Response().withJSONBody({ - fjolskyldunumer: '0101303019', - einstaklingar: [ - { - kennitala: '0101303019', - nafn: 'Gervimaður Afríka', - eiginnafn: 'Gervimaður', - millinafn: null, - kenninafn: 'Afríka', - fulltNafn: 'Gervimaður Afríka', - kynkodi: '1', - bannmerking: false, - faedingardagur: '1930-01-01T00:00:00', - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }, - { - kennitala: '0101307789', - nafn: 'Gervimaður útlönd', - eiginnafn: 'Gervimaður', - millinafn: null, - kenninafn: 'útlönd', - fulltNafn: 'Gervimaður útlönd', - kynkodi: '1', - bannmerking: false, - faedingardagur: '1930-01-01T00:00:00', - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }, - { - kennitala: '1111111119', - nafn: 'Stubbur Maack', - eiginnafn: 'Stubbur', - millinafn: null, - kenninafn: 'Maack', - fulltNafn: 'Stubbur Maack', - kynkodi: '3', - bannmerking: false, - faedingardagur: '2011-11-11T00:00:00', - logheimili: { - heiti: 'Engihjalli 3', - postnumer: '200', - stadur: 'Kópavogur', - sveitarfelagsnumer: '1000', - }, - adsetur: { - heiti: 'Fellsmúli 2', - postnumer: '108', - stadur: 'Reykjavík', - sveitarfelagsnumer: '0000', - }, - }, - ], - }), - }) - await addXroadMock({ - config: Labor, - prefix: 'XROAD_VMST_API_PATH', - apiPath: '/users/0101303019/parental-leaves/periods/length', - response: new Response().withJSONBody({ - periodLength: 98, - }), - prefixType: 'base-path-with-env', - serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', - }) - await addXroadMock({ - config: Labor, - prefix: 'XROAD_VMST_API_PATH', - serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', - apiPath: '/users/0101303019/parental-leaves', - response: [ - new Response().withJSONBody( - PostParentalLeaveResponseToJSON({ - status: 'TestOK', - }), - ), - new Response().withJSONBody( - PostParentalLeaveResponseToJSON({ - status: 'OK', - id: '23234', - }), - ), - ], - prefixType: 'base-path-with-env', - method: HttpMethod.POST, - }) - await addXroadMock({ - config: Labor, - prefix: 'XROAD_VMST_API_PATH', - serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', - apiPath: '/users/0101303019/parental-leaves', - response: [ - new Response().withJSONBody({ - parentalLeaves: [], - }), - ], - prefixType: 'base-path-with-env', - method: HttpMethod.GET, - }) - const babyBDayRandomFactor = Math.ceil(Math.random() * 85) - await addXroadMock({ - config: Labor, - prefix: 'XROAD_VMST_API_PATH', - serviceMemberCode: 'XROAD_VMST_MEMBER_CODE', - apiPath: '/users/0101303019/pregnancy-status', - response: [ - new Response().withJSONBody({ - hasActivePregnancy: true, - expectedDateOfBirth: formatISO( - addDays(addMonths(new Date(), 6), babyBDayRandomFactor), - { - representation: 'date', - }, - ), - }), - ], - prefixType: 'base-path-with-env', - }) + /* Xroad mocks */ + await loadParentalLeaveXroadMocks() + await loadSocialInsuranceAdministrationXroadMocks() + await loadNationalRegistryXroadMocks() + const { envs } = getEnvVariables(Base.getEnv(), 'system-e2e', env) const xroadBasePath = envs['XROAD_BASE_PATH'] const path = @@ -294,6 +26,5 @@ export const setupXroadMocks = async () => { }, env: {} as EnvironmentConfig, }) - await wildcard(path) } diff --git a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts index ef95ccb8fbfe..e54267247f75 100644 --- a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts +++ b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/OldAgePensionForm.ts @@ -292,6 +292,7 @@ export const OldAgePensionForm: Form = buildForm({ socialInsuranceAdministrationMessage.payment .personalAllowancePercentage, suffix: '%', + dataTestId: 'personal-allowance-usage', condition: (answers) => { const { personalAllowance } = getApplicationAnswers(answers) return personalAllowance === YES diff --git a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/Prerequisites.ts b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/Prerequisites.ts index 0999301b21c9..e614d43380c3 100644 --- a/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/Prerequisites.ts +++ b/libs/application/templates/social-insurance-administration/old-age-pension/src/forms/Prerequisites.ts @@ -61,6 +61,7 @@ export const PrerequisitesForm: Form = buildForm({ options: [ { value: ApplicationType.OLD_AGE_PENSION, + dataTestId: 'old-age-pension', label: oldAgePensionFormMessage.shared.applicationTitle, subLabel: oldAgePensionFormMessage.pre @@ -68,6 +69,7 @@ export const PrerequisitesForm: Form = buildForm({ }, { value: ApplicationType.HALF_OLD_AGE_PENSION, + dataTestId: 'half-old-age-pension', label: oldAgePensionFormMessage.pre .halfRetirementPensionApplicationTitle, @@ -77,6 +79,7 @@ export const PrerequisitesForm: Form = buildForm({ }, { value: ApplicationType.SAILOR_PENSION, + dataTestId: 'sailor-pension', label: oldAgePensionFormMessage.pre.fishermenApplicationTitle, subLabel: oldAgePensionFormMessage.pre