From a038d6f57665f4b004bb4804af9d481f49783d7f Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 11:19:24 +0000 Subject: [PATCH 01/17] [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 From 5bfdcfdfe78f47ec7cc2662b03b8378576187fff Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 11:36:52 +0000 Subject: [PATCH 02/17] [TS-319] e2e tests (Additional-support-for-the-elderly) --- ...additional-support-for-the-elderly.spec.ts | 212 ++++++++++++++++++ .../socialInsuranceAdministration.mock.ts | 26 +++ .../AdditionalSupportForTheElderlyForm.ts | 1 + 3 files changed, 239 insertions(+) create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts new file mode 100644 index 000000000000..a0d82324756b --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts @@ -0,0 +1,212 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +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/felagslegur-vidbotarstudningur' + +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( + 'felagslegur-vidbotarstudningur', + ) + await setupXroadMocks() + await use(applicationPage) + + await applicationPage.close() + await applicationContext.close() + }, +}) + +applicationTest.describe('Additional support for the elderly', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + 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 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('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( + '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/mocks/socialInsuranceAdministration.mock.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/socialInsuranceAdministration.mock.ts index 2186b7ed3b4c..c061cc3b7f22 100644 --- 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 @@ -50,6 +50,8 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { }, }), }) + + /* Old-age pension */ await addXroadMock({ config: SocialInsuranceAdministration, prefix: 'XROAD_TR_PATH', @@ -71,4 +73,28 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { prefixType: 'only-base-path', method: HttpMethod.POST, }) + + /* Additional support for the elderly */ + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: + '/api/protected/v1/Applicant/additionalsupportfortheelderly/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/additionalsupportfortheelderly', + response: new Response().withJSONBody({ + applicationLineId: 1234567, + }), + prefixType: 'only-base-path', + method: HttpMethod.POST, + }) } diff --git a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts index 964f8df4af14..447428a9d306 100644 --- a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts +++ b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts @@ -287,6 +287,7 @@ export const AdditionalSupportForTheElderlyForm: Form = buildForm({ socialInsuranceAdministrationMessage.payment .personalAllowancePercentage, suffix: '%', + dataTestId: 'personal-allowance-usage', condition: (answers) => { const { personalAllowance } = getApplicationAnswers(answers) return personalAllowance === YES From a8137ca795dfaaed8f1969e92cc1295288e6130d Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 12:13:41 +0000 Subject: [PATCH 03/17] Fixed typo in nationalRegistry.mock file after coderabbit review --- .../{nationalRegistry.mocks.ts => nationalRegistry.mock.ts} | 0 .../islandis/application-system/acceptance/setup-xroad.mocks.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/{nationalRegistry.mocks.ts => nationalRegistry.mock.ts} (100%) 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.mock.ts similarity index 100% rename from apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mocks.ts rename to apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts 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 b697f6cfa07c..f5f0475faa59 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 @@ -5,7 +5,7 @@ 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' +import { loadNationalRegistryXroadMocks } from './mocks/nationalRegistry.mock' export const setupXroadMocks = async () => { await resetMocks() From 8e1bec7f189d4245d28528a5e19d17ca08f329f9 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 12:33:03 +0000 Subject: [PATCH 04/17] [TS-156] e2e tests (Pension-supplement) --- .../socialInsuranceAdministration.mock.ts | 24 ++ .../acceptance/pension-supplement.spec.ts | 206 ++++++++++++++++++ .../pension-supplement/src/index.ts | 1 + 3 files changed, 231 insertions(+) create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts 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 index c061cc3b7f22..0f871477b794 100644 --- 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 @@ -97,4 +97,28 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { prefixType: 'only-base-path', method: HttpMethod.POST, }) + + /* Pension supplement */ + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: + '/api/protected/v1/Applicant/pensionsupplement/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/pensionsupplement', + 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/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts new file mode 100644 index 000000000000..978735de78ca --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts @@ -0,0 +1,206 @@ +import { expect, test as base, Page } from '@playwright/test' +import { + disableI18n, + disablePreviousApplications, +} from '../../../../support/disablers' +import { session } from '../../../../support/session' +import { helpers } from '../../../../support/locator-helpers' +import { pensionSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/pension-supplement' +import { label } from '../../../../support/i18n' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { setupXroadMocks } from './setup-xroad.mocks' + +const homeUrl = '/umsoknir/uppbot-a-lifeyri' + +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('uppbot-a-lifeyri') + await setupXroadMocks() + await use(applicationPage) + + await applicationPage.close() + await applicationContext.close() + }, +}) + +applicationTest.describe('Pension Supplement', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + 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 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 proceed() + }) + + await applicationTest.step('Select application reason', async () => { + await expect( + page.getByRole('heading', { + name: label(pensionSupplementFormMessage.applicationReason.title), + }), + ).toBeVisible() + + await page + .getByRole('region', { + name: label(pensionSupplementFormMessage.applicationReason.title), + }) + .getByRole('checkbox', { + name: label( + pensionSupplementFormMessage.applicationReason.medicineCost, + ), + }) + .click() + + 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( + '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 to view the application', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) + }, + ) +}) diff --git a/libs/application/templates/social-insurance-administration/pension-supplement/src/index.ts b/libs/application/templates/social-insurance-administration/pension-supplement/src/index.ts index a615305578e7..29cfff9c42cf 100644 --- a/libs/application/templates/social-insurance-administration/pension-supplement/src/index.ts +++ b/libs/application/templates/social-insurance-administration/pension-supplement/src/index.ts @@ -6,3 +6,4 @@ export const getFields = () => import('./fields') export default template export * from './lib/pensionSupplementUtils' +export * from './lib/messages' From f15ef350c2da9266e1db1d6e5158121bc979b477 Mon Sep 17 00:00:00 2001 From: andes-it Date: Tue, 15 Oct 2024 12:38:20 +0000 Subject: [PATCH 05/17] chore: nx format:write update dirty files --- .../acceptance/mocks/socialInsuranceAdministration.mock.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 index 0f871477b794..595362e90501 100644 --- 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 @@ -102,8 +102,7 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { await addXroadMock({ config: SocialInsuranceAdministration, prefix: 'XROAD_TR_PATH', - apiPath: - '/api/protected/v1/Applicant/pensionsupplement/eligible', + apiPath: '/api/protected/v1/Applicant/pensionsupplement/eligible', prefixType: 'only-base-path', response: new Response().withJSONBody({ isEligible: true, From bc3698614cc483442e6ee66caba59547b21f6525 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 13:12:21 +0000 Subject: [PATCH 06/17] [TS-155] e2e tests (Household-supplement) --- .../acceptance/household-supplement.spec.ts | 222 ++++++++++++++++++ .../acceptance/mocks/nationalRegistry.mock.ts | 7 + .../socialInsuranceAdministration.mock.ts | 26 +- .../acceptance/pension-supplement.spec.ts | 10 +- 4 files changed, 258 insertions(+), 7 deletions(-) create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts new file mode 100644 index 000000000000..6d3efbe435c3 --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts @@ -0,0 +1,222 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { householdSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/household-supplement' +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/heimilisuppbot' + +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('Household Supplement', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + 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 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.type('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 proceed() + }) + + await applicationTest.step('Household supplement', async () => { + await expect( + page.getByRole('heading', { + name: label( + householdSupplementFormMessage.shared.householdSupplement, + ), + }), + ).toBeVisible() + + await page + .getByRole('region', { + name: label( + householdSupplementFormMessage.info.householdSupplementHousing, + ), + }) + .getByRole('radio', { + name: label( + householdSupplementFormMessage.info + .householdSupplementHousingOwner, + ), + }) + .click() + + await page + .getByRole('region', { + name: label( + householdSupplementFormMessage.info + .householdSupplementChildrenBetween18And25, + ), + }) + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.no), + }) + .click() + 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( + '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 to view the application', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) + }, + ) +}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts index e6230479794a..91ff121893ca 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts @@ -83,6 +83,13 @@ export const loadNationalRegistryXroadMocks = async () => { }, ]), }) + await addXroadMock({ + config: NationalRegistry, + prefix: 'XROAD_NATIONAL_REGISTRY_SERVICE_PATH', + apiPath: '/api/v1/einstaklingar/0101303019/samibuar', + prefixType: 'only-base-path', + response: new Response().withJSONBody(['0101303019']), + }) /* Gervimaður útlönd */ await addXroadMock({ 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 index 0f871477b794..ccc3f66e7a2f 100644 --- 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 @@ -102,8 +102,7 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { await addXroadMock({ config: SocialInsuranceAdministration, prefix: 'XROAD_TR_PATH', - apiPath: - '/api/protected/v1/Applicant/pensionsupplement/eligible', + apiPath: '/api/protected/v1/Applicant/pensionsupplement/eligible', prefixType: 'only-base-path', response: new Response().withJSONBody({ isEligible: true, @@ -121,4 +120,27 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { prefixType: 'only-base-path', method: HttpMethod.POST, }) + + /* Household supplement */ + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/Applicant/householdsupplement/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/householdsupplement', + 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/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts index 978735de78ca..24504cdbc5ca 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts @@ -1,13 +1,13 @@ -import { expect, test as base, Page } from '@playwright/test' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { pensionSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/pension-supplement' +import { test as base, expect, Page } from '@playwright/test' import { disableI18n, disablePreviousApplications, } from '../../../../support/disablers' -import { session } from '../../../../support/session' -import { helpers } from '../../../../support/locator-helpers' -import { pensionSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/pension-supplement' import { label } from '../../../../support/i18n' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { helpers } from '../../../../support/locator-helpers' +import { session } from '../../../../support/session' import { setupXroadMocks } from './setup-xroad.mocks' const homeUrl = '/umsoknir/uppbot-a-lifeyri' From 6e527fe4c8c17a84616b13b40e46404f58b9387f Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 14:38:08 +0000 Subject: [PATCH 07/17] [TS-324] e2e test for 1/2 old age pension --- .../socialInsuranceAdministration.mock.ts | 23 ++ .../acceptance/old-age-pension.spec.ts | 298 +++++++++++++++++- 2 files changed, 320 insertions(+), 1 deletion(-) 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 index ccc3f66e7a2f..de5bd629d2eb 100644 --- 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 @@ -74,6 +74,29 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { method: HttpMethod.POST, }) + /* Half Old-age pension */ + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: '/api/protected/v1/Applicant/halfoldagepension/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/halfoldagepension', + response: new Response().withJSONBody({ + applicationLineId: 1234567, + }), + prefixType: 'only-base-path', + method: HttpMethod.POST, + }) + /* Additional support for the elderly */ await addXroadMock({ config: SocialInsuranceAdministration, 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 index 56f973e863c3..9b7bad42d3c6 100644 --- 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 @@ -190,7 +190,303 @@ applicationTest.describe('Old Age Pension', () => { }) await applicationTest.step( - 'Upload attachments for pension payments', + 'Check that attachments for pension payments header is visible', + 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() + }, + ) + }, + ) +}) + +applicationTest.describe('Half 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('half-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('Self-employed or employee', async () => { + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, + ), + }), + ).toBeVisible() + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.employee), + }) + .click() + await proceed() + }) + + await applicationTest.step('Employer registration', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.registrationTitle), + }), + ).toBeVisible() + + const employerEmail = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.email), + }) + await employerEmail.selectText() + await employerEmail.fill('mockEmail@mail.is') + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.ratioYearly), + }) + .click() + + const employmentRatio = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.ratio), + }) + await employmentRatio.selectText() + await employmentRatio.fill('50') + await proceed() + }) + + await applicationTest.step('Employers', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.employerTitle), + }), + ).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( + 'Check that attachments for pension payments header is visible', async () => { await expect( page.getByRole('heading', { From f5defe60b7cda4a77589e1a46d9e13fc4a584fa1 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 15:05:34 +0000 Subject: [PATCH 08/17] Added a helper function that mocks each type of SIA application - coderabbit --- .../socialInsuranceAdministration.mock.ts | 145 ++++-------------- 1 file changed, 30 insertions(+), 115 deletions(-) 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 index de5bd629d2eb..974d07e9eeae 100644 --- 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 @@ -2,6 +2,31 @@ import { HttpMethod, Response } from '@anev/ts-mountebank' import { SocialInsuranceAdministration } from '../../../../../../../../infra/src/dsl/xroad' import { addXroadMock } from '../../../../../support/wire-mocks' +const setupApplicationMocks = async (applicationType: string) => { + await addXroadMock({ + config: SocialInsuranceAdministration, + prefix: 'XROAD_TR_PATH', + apiPath: `/api/protected/v1/Applicant/${applicationType}/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/${applicationType}`, + response: new Response().withJSONBody({ + applicationLineId: 1234567, + }), + prefixType: 'only-base-path', + method: HttpMethod.POST, + }) +} + export const loadSocialInsuranceAdministrationXroadMocks = async () => { await addXroadMock({ config: SocialInsuranceAdministration, @@ -51,119 +76,9 @@ export const loadSocialInsuranceAdministrationXroadMocks = async () => { }), }) - /* Old-age pension */ - 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, - }) - - /* Half Old-age pension */ - await addXroadMock({ - config: SocialInsuranceAdministration, - prefix: 'XROAD_TR_PATH', - apiPath: '/api/protected/v1/Applicant/halfoldagepension/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/halfoldagepension', - response: new Response().withJSONBody({ - applicationLineId: 1234567, - }), - prefixType: 'only-base-path', - method: HttpMethod.POST, - }) - - /* Additional support for the elderly */ - await addXroadMock({ - config: SocialInsuranceAdministration, - prefix: 'XROAD_TR_PATH', - apiPath: - '/api/protected/v1/Applicant/additionalsupportfortheelderly/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/additionalsupportfortheelderly', - response: new Response().withJSONBody({ - applicationLineId: 1234567, - }), - prefixType: 'only-base-path', - method: HttpMethod.POST, - }) - - /* Pension supplement */ - await addXroadMock({ - config: SocialInsuranceAdministration, - prefix: 'XROAD_TR_PATH', - apiPath: '/api/protected/v1/Applicant/pensionsupplement/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/pensionsupplement', - response: new Response().withJSONBody({ - applicationLineId: 1234567, - }), - prefixType: 'only-base-path', - method: HttpMethod.POST, - }) - - /* Household supplement */ - await addXroadMock({ - config: SocialInsuranceAdministration, - prefix: 'XROAD_TR_PATH', - apiPath: '/api/protected/v1/Applicant/householdsupplement/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/householdsupplement', - response: new Response().withJSONBody({ - applicationLineId: 1234567, - }), - prefixType: 'only-base-path', - method: HttpMethod.POST, - }) + await setupApplicationMocks('oldagepension') + await setupApplicationMocks('halfoldagepension') + await setupApplicationMocks('additionalsupportfortheelderly') + await setupApplicationMocks('pensionsupplement') + await setupApplicationMocks('householdsupplement') } From 6665d45f67a7ad547dd2b37d474927dbb98544c4 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Tue, 15 Oct 2024 18:05:33 +0000 Subject: [PATCH 09/17] Moved all common steps to a shared file so it can be used in multiple SIA tests - coderabbit --- ...additional-support-for-the-elderly.spec.ts | 212 ------- .../acceptance/household-supplement.spec.ts | 222 ------- .../acceptance/old-age-pension.spec.ts | 574 ------------------ .../acceptance/pension-supplement.spec.ts | 206 ------- ...additional-support-for-the-elderly.spec.ts | 107 ++++ .../household-supplement.spec.ts | 145 +++++ .../old-age-pension.spec.ts | 315 ++++++++++ .../pension-supplement.spec.ts | 129 ++++ .../social-insurance-administration/shared.ts | 139 +++++ 9 files changed, 835 insertions(+), 1214 deletions(-) delete mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts delete mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts delete mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts delete mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts create mode 100644 apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts deleted file mode 100644 index a0d82324756b..000000000000 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/additional-support-for-the-elderly.spec.ts +++ /dev/null @@ -1,212 +0,0 @@ -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' -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/felagslegur-vidbotarstudningur' - -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( - 'felagslegur-vidbotarstudningur', - ) - await setupXroadMocks() - await use(applicationPage) - - await applicationPage.close() - await applicationContext.close() - }, -}) - -applicationTest.describe('Additional support for the elderly', () => { - applicationTest( - 'Should be able to create application', - async ({ applicationPage }) => { - const page = applicationPage - const { proceed } = helpers(page) - - 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 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('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( - '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/household-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts deleted file mode 100644 index 6d3efbe435c3..000000000000 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/household-supplement.spec.ts +++ /dev/null @@ -1,222 +0,0 @@ -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' -import { householdSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/household-supplement' -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/heimilisuppbot' - -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('Household Supplement', () => { - applicationTest( - 'Should be able to create application', - async ({ applicationPage }) => { - const page = applicationPage - const { proceed } = helpers(page) - - 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 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.type('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 proceed() - }) - - await applicationTest.step('Household supplement', async () => { - await expect( - page.getByRole('heading', { - name: label( - householdSupplementFormMessage.shared.householdSupplement, - ), - }), - ).toBeVisible() - - await page - .getByRole('region', { - name: label( - householdSupplementFormMessage.info.householdSupplementHousing, - ), - }) - .getByRole('radio', { - name: label( - householdSupplementFormMessage.info - .householdSupplementHousingOwner, - ), - }) - .click() - - await page - .getByRole('region', { - name: label( - householdSupplementFormMessage.info - .householdSupplementChildrenBetween18And25, - ), - }) - .getByRole('radio', { - name: label(socialInsuranceAdministrationMessage.shared.no), - }) - .click() - 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( - '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 to view the application', - async () => { - await expect( - page - .getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.conclusionScreen - .receivedTitle, - ), - }) - .first(), - ).toBeVisible() - }, - ) - }, - ) -}) 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 deleted file mode 100644 index 9b7bad42d3c6..000000000000 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/old-age-pension.spec.ts +++ /dev/null @@ -1,574 +0,0 @@ -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( - 'Check that attachments for pension payments header is visible', - 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() - }, - ) - }, - ) -}) - -applicationTest.describe('Half 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('half-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('Self-employed or employee', async () => { - await expect( - page.getByRole('heading', { - name: label( - oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, - ), - }), - ).toBeVisible() - - await page - .getByRole('radio', { - name: label(oldAgePensionFormMessage.employer.employee), - }) - .click() - await proceed() - }) - - await applicationTest.step('Employer registration', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.registrationTitle), - }), - ).toBeVisible() - - const employerEmail = page.getByRole('textbox', { - name: label(oldAgePensionFormMessage.employer.email), - }) - await employerEmail.selectText() - await employerEmail.fill('mockEmail@mail.is') - - await page - .getByRole('radio', { - name: label(oldAgePensionFormMessage.employer.ratioYearly), - }) - .click() - - const employmentRatio = page.getByRole('textbox', { - name: label(oldAgePensionFormMessage.employer.ratio), - }) - await employmentRatio.selectText() - await employmentRatio.fill('50') - await proceed() - }) - - await applicationTest.step('Employers', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.employerTitle), - }), - ).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( - 'Check that attachments for pension payments header is visible', - 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/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts deleted file mode 100644 index 24504cdbc5ca..000000000000 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/pension-supplement.spec.ts +++ /dev/null @@ -1,206 +0,0 @@ -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' -import { pensionSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/pension-supplement' -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/uppbot-a-lifeyri' - -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('uppbot-a-lifeyri') - await setupXroadMocks() - await use(applicationPage) - - await applicationPage.close() - await applicationContext.close() - }, -}) - -applicationTest.describe('Pension Supplement', () => { - applicationTest( - 'Should be able to create application', - async ({ applicationPage }) => { - const page = applicationPage - const { proceed } = helpers(page) - - 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 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 proceed() - }) - - await applicationTest.step('Select application reason', async () => { - await expect( - page.getByRole('heading', { - name: label(pensionSupplementFormMessage.applicationReason.title), - }), - ).toBeVisible() - - await page - .getByRole('region', { - name: label(pensionSupplementFormMessage.applicationReason.title), - }) - .getByRole('checkbox', { - name: label( - pensionSupplementFormMessage.applicationReason.medicineCost, - ), - }) - .click() - - 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( - '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 to view the application', - async () => { - await expect( - page - .getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.conclusionScreen - .receivedTitle, - ), - }) - .first(), - ).toBeVisible() - }, - ) - }, - ) -}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts new file mode 100644 index 000000000000..9c355e793064 --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts @@ -0,0 +1,107 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { test as base, expect, Page } from '@playwright/test' +import { + disableI18n, + disablePreviousApplications, +} from '../../../../../support/disablers' +import { label } from '../../../../../support/i18n' +import { session } from '../../../../../support/session' +import { setupXroadMocks } from '../setup-xroad.mocks' +import { + additionalAttachments, + fillApplicantInfo, + fillPaymentInfo, + selectPeriod, + submitApplication, + writeComment, +} from './shared' + +const homeUrl = '/umsoknir/felagslegur-vidbotarstudningur' + +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( + 'felagslegur-vidbotarstudningur', + ) + await setupXroadMocks() + await use(applicationPage) + + await applicationPage.close() + await applicationContext.close() + }, +}) + +applicationTest.describe('Additional support for the elderly', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + + 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 page + .getByRole('button', { + name: label( + socialInsuranceAdministrationMessage.pre.startApplication, + ), + }) + .click() + }) + + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, true), + ) + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) + + await applicationTest.step('Write comment', () => writeComment(page)) + + await applicationTest.step('Submit application', () => + submitApplication(page), + ) + + 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/social-insurance-administration/household-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts new file mode 100644 index 000000000000..5e925dc1b81a --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts @@ -0,0 +1,145 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { householdSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/household-supplement' +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' +import { + additionalAttachments, + fillApplicantInfo, + fillPaymentInfo, + selectPeriod, + submitApplication, + writeComment, +} from './shared' + +const homeUrl = '/umsoknir/heimilisuppbot' + +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('Household Supplement', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + 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 page + .getByRole('button', { + name: label( + socialInsuranceAdministrationMessage.pre.startApplication, + ), + }) + .click() + }) + + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, false), + ) + + await applicationTest.step('Household supplement', async () => { + await expect( + page.getByRole('heading', { + name: label( + householdSupplementFormMessage.shared.householdSupplement, + ), + }), + ).toBeVisible() + + await page + .getByRole('region', { + name: label( + householdSupplementFormMessage.info.householdSupplementHousing, + ), + }) + .getByRole('radio', { + name: label( + householdSupplementFormMessage.info + .householdSupplementHousingOwner, + ), + }) + .click() + + await page + .getByRole('region', { + name: label( + householdSupplementFormMessage.info + .householdSupplementChildrenBetween18And25, + ), + }) + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.no), + }) + .click() + await proceed() + }) + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) + + await applicationTest.step('Write comment', () => writeComment(page)) + + await applicationTest.step('Submit application', () => + submitApplication(page), + ) + + await applicationTest.step( + 'Check that conclusion screen header is visible', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) + }, + ) +}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts new file mode 100644 index 000000000000..38aa192c7a08 --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts @@ -0,0 +1,315 @@ +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' +import { + additionalAttachments, + fillApplicantInfo, + fillPaymentInfo, + selectPeriod, + submitApplication, + writeComment, +} from './shared' + +const agreeToDataProviders = async (page: Page) => { + const { proceed } = helpers(page) + + await expect( + page.getByRole('heading', { + name: label(socialInsuranceAdministrationMessage.pre.externalDataSection), + }), + ).toBeVisible() + await page.getByTestId('agree-to-data-providers').click() + await proceed() +} + +const pensionFunds = async (page: Page) => { + 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() +} + +const onePaymentPerYear = async (page: Page) => { + const { proceed } = helpers(page) + + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.onePaymentPerYear.onePaymentPerYearTitle, + ), + }), + ).toBeVisible() + await page + .getByRole('radio', { + name: label(socialInsuranceAdministrationMessage.shared.no), + }) + .click() + await proceed() +} + +const viewResidenceHistory = async (page: Page) => { + const { proceed } = helpers(page) + + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.residence.residenceHistoryTitle), + }), + ).toBeVisible() + await proceed() +} + +const pensionPaymentsAttachments = async (page: Page) => { + const { proceed } = helpers(page) + + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.fileUpload.pensionFileTitle), + }), + ).toBeVisible() + await proceed() +} + +const conclusionScreen = async (page: Page) => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedAwaitingIncomePlanTitle, + ), + }) + .first(), + ).toBeVisible() +} + +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', () => + agreeToDataProviders(page), + ) + + await applicationTest.step( + 'Answer pension fund question and start application', + () => pensionFunds(page), + ) + + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, true), + ) + + await applicationTest.step('One payment per year', () => + onePaymentPerYear(page), + ) + + await applicationTest.step('View residence history', () => + viewResidenceHistory(page), + ) + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that attachments for pension payments header is visible', + () => pensionPaymentsAttachments(page), + ) + + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) + + await applicationTest.step('Write comment', () => writeComment(page)) + + await applicationTest.step('Submit application', () => + submitApplication(page), + ) + + await applicationTest.step( + 'Check that conclusion screen header is visible', + () => conclusionScreen(page), + ) + }, + ) +}) + +applicationTest.describe('Half 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('half-old-age-pension').click() + await proceed() + }) + + await applicationTest.step('Agree to data providers', () => + agreeToDataProviders(page), + ) + + await applicationTest.step( + 'Answer pension fund question and start application', + () => pensionFunds(page), + ) + + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, true), + ) + + await applicationTest.step('One payment per year', () => + onePaymentPerYear(page), + ) + + await applicationTest.step('View residence history', () => + viewResidenceHistory(page), + ) + + await applicationTest.step('Self-employed or employee', async () => { + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, + ), + }), + ).toBeVisible() + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.employee), + }) + .click() + await proceed() + }) + + await applicationTest.step('Employer registration', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.registrationTitle), + }), + ).toBeVisible() + + const employerEmail = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.email), + }) + await employerEmail.selectText() + await employerEmail.fill('mockEmail@mail.is') + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.ratioYearly), + }) + .click() + + const employmentRatio = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.ratio), + }) + await employmentRatio.selectText() + await employmentRatio.fill('50') + await proceed() + }) + + await applicationTest.step('Employers', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.employerTitle), + }), + ).toBeVisible() + await proceed() + }) + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that attachments for pension payments header is visible', + () => pensionPaymentsAttachments(page), + ) + + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) + + await applicationTest.step('Write comment', () => writeComment(page)) + + await applicationTest.step('Submit application', () => + submitApplication(page), + ) + + await applicationTest.step( + 'Check that conclusion screen header is visible', + () => conclusionScreen(page), + ) + }, + ) +}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts new file mode 100644 index 000000000000..b33d0e49c247 --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts @@ -0,0 +1,129 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { pensionSupplementFormMessage } from '@island.is/application/templates/social-insurance-administration/pension-supplement' +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' +import { + additionalAttachments, + fillApplicantInfo, + fillPaymentInfo, + selectPeriod, + submitApplication, + writeComment, +} from './shared' + +const homeUrl = '/umsoknir/uppbot-a-lifeyri' + +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('uppbot-a-lifeyri') + await setupXroadMocks() + await use(applicationPage) + + await applicationPage.close() + await applicationContext.close() + }, +}) + +applicationTest.describe('Pension Supplement', () => { + applicationTest( + 'Should be able to create application', + async ({ applicationPage }) => { + const page = applicationPage + const { proceed } = helpers(page) + + 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 page + .getByRole('button', { + name: label( + socialInsuranceAdministrationMessage.pre.startApplication, + ), + }) + .click() + }) + + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, false), + ) + + await applicationTest.step('Select application reason', async () => { + await expect( + page.getByRole('heading', { + name: label(pensionSupplementFormMessage.applicationReason.title), + }), + ).toBeVisible() + + await page + .getByRole('region', { + name: label(pensionSupplementFormMessage.applicationReason.title), + }) + .getByRole('checkbox', { + name: label( + pensionSupplementFormMessage.applicationReason.medicineCost, + ), + }) + .click() + + await proceed() + }) + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) + + await applicationTest.step('Write comment', () => writeComment(page)) + + await applicationTest.step('Submit application', () => + submitApplication(page), + ) + + await applicationTest.step( + 'Check that conclusion screen header is visible', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) + }, + ) +}) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts new file mode 100644 index 000000000000..5a5a321f053e --- /dev/null +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts @@ -0,0 +1,139 @@ +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { expect, Page } from '@playwright/test' +import { label } from '../../../../../support/i18n' +import { helpers } from '../../../../../support/locator-helpers' + +export const fillApplicantInfo = async (page: Page) => { + const { proceed } = helpers(page) + + 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() +} + +export const fillPaymentInfo = async (page: Page, includeTax: boolean) => { + const { proceed } = helpers(page) + + 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') + + if (includeTax) { + 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() +} + +export const selectPeriod = async (page: Page) => { + const { proceed } = helpers(page) + + 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() +} + +export const additionalAttachments = async (page: Page) => { + const { proceed } = helpers(page) + + await expect( + page.getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.fileUpload.additionalFileTitle, + ), + }), + ).toBeVisible() + await proceed() +} + +export const writeComment = async (page: Page) => { + const { proceed } = helpers(page) + + 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() +} + +export const submitApplication = async (page: Page) => { + await expect( + page + .locator('form') + .getByRole('paragraph') + .filter({ + hasText: label( + socialInsuranceAdministrationMessage.confirm.overviewTitle, + ), + }), + ).toBeVisible() + await page + .getByRole('button', { + name: label(socialInsuranceAdministrationMessage.confirm.submitButton), + }) + .click() +} From c23a72c29473fe0f902376bb7c19fc9c61ab7a4d Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 11:11:47 +0000 Subject: [PATCH 10/17] Updated all instances of faedingardagur in parentalLeave mocks to use ISO 8601 strings - coderabbit --- .../acceptance/mocks/parentalLeave.mock.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index 8b122fee172a..0190192a4648 100644 --- 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 @@ -23,7 +23,7 @@ export const loadParentalLeaveXroadMocks = async () => { fulltNafn: 'Gervimaður Afríka', kynkodi: '1', bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), + faedingardagur: '1930-01-01T00:00:00', logheimili: { heiti: 'Engihjalli 3', postnumer: '200', @@ -52,7 +52,7 @@ export const loadParentalLeaveXroadMocks = async () => { fulltNafn: 'Stubbur Maack', kynkodi: '3', bannmerking: false, - faedingardagur: new Date('2011-11-11T00:00:00'), + faedingardagur: '2011-11-11T00:00:00', logheimili: { heiti: 'Engihjalli 3', postnumer: '200', @@ -81,7 +81,7 @@ export const loadParentalLeaveXroadMocks = async () => { fulltNafn: 'Gervimaður útlönd', kynkodi: '1', bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), + faedingardagur: '1930-01-01T00:00:00', logheimili: { heiti: 'Engihjalli 3', postnumer: '200', From 4ad882cb0e56d4f834add4aa8c7054b0a3e82610 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 15:17:31 +0000 Subject: [PATCH 11/17] Added more descriptive test names - coderabbit --- .../additional-support-for-the-elderly.spec.ts | 2 +- .../household-supplement.spec.ts | 2 +- .../social-insurance-administration/old-age-pension.spec.ts | 4 ++-- .../pension-supplement.spec.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts index 9c355e793064..f8bcda2b0130 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts @@ -44,7 +44,7 @@ const applicationTest = base.extend<{ applicationPage: Page }>({ applicationTest.describe('Additional support for the elderly', () => { applicationTest( - 'Should be able to create application', + 'Should complete Additional support for the elderly application successfully', async ({ applicationPage }) => { const page = applicationPage diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts index 5e925dc1b81a..1a830a811f21 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts @@ -44,7 +44,7 @@ const applicationTest = base.extend<{ applicationPage: Page }>({ applicationTest.describe('Household Supplement', () => { applicationTest( - 'Should be able to create application', + 'Should complete Household Supplement application successfully', async ({ applicationPage }) => { const page = applicationPage const { proceed } = helpers(page) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts index 38aa192c7a08..150d88c5487f 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts @@ -127,7 +127,7 @@ const applicationTest = base.extend<{ applicationPage: Page }>({ applicationTest.describe('Old Age Pension', () => { applicationTest( - 'Should be able to create application', + 'Should complete Old Age Pension application successfully', async ({ applicationPage }) => { const page = applicationPage const { proceed } = helpers(page) @@ -195,7 +195,7 @@ applicationTest.describe('Old Age Pension', () => { applicationTest.describe('Half Old Age Pension', () => { applicationTest( - 'Should be able to create application', + 'Should complete Half Old Age Pension application successfully', async ({ applicationPage }) => { const page = applicationPage const { proceed } = helpers(page) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts index b33d0e49c247..68f0e8f662ea 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts @@ -44,7 +44,7 @@ const applicationTest = base.extend<{ applicationPage: Page }>({ applicationTest.describe('Pension Supplement', () => { applicationTest( - 'Should be able to create application', + 'Should complete Pension Supplement application successfully', async ({ applicationPage }) => { const page = applicationPage const { proceed } = helpers(page) From 115d5d8fb2ad6b41d3782d59259b7f989feffc9c Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 15:18:07 +0000 Subject: [PATCH 12/17] Changed getByRole to getByText in submitApplication - coderabbit --- .../acceptance/social-insurance-administration/shared.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts index 5a5a321f053e..369a9b0370b4 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts @@ -124,12 +124,9 @@ export const submitApplication = async (page: Page) => { await expect( page .locator('form') - .getByRole('paragraph') - .filter({ - hasText: label( - socialInsuranceAdministrationMessage.confirm.overviewTitle, - ), - }), + .getByText( + label(socialInsuranceAdministrationMessage.confirm.overviewTitle), + ), ).toBeVisible() await page .getByRole('button', { From e1e6f75f3abbc6a7c955b7e9183f94fcc95d8fca Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 15:33:25 +0000 Subject: [PATCH 13/17] Updated OAP tests - coderabbit --- .../old-age-pension.spec.ts | 404 +++++++----------- 1 file changed, 166 insertions(+), 238 deletions(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts index 150d88c5487f..60bbc9a6c410 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts @@ -18,87 +18,182 @@ import { writeComment, } from './shared' -const agreeToDataProviders = async (page: Page) => { +const oldAgeApplicationTest = async (page: Page, applicationType: string) => { const { proceed } = helpers(page) - await expect( - page.getByRole('heading', { - name: label(socialInsuranceAdministrationMessage.pre.externalDataSection), - }), - ).toBeVisible() - await page.getByTestId('agree-to-data-providers').click() - await proceed() -} + await applicationTest.step('Select type of application', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.pre.applicationTypeTitle), + }), + ).toBeVisible() + await page.getByTestId(applicationType).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() + }, + ) -const pensionFunds = async (page: Page) => { - 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), + await applicationTest.step('Fill in applicant info', () => + fillApplicantInfo(page), + ) + + await applicationTest.step('Fill in payment information', () => + fillPaymentInfo(page, true), + ) + + 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() + }) + + if (applicationType === 'half-old-age-pension') { + await applicationTest.step('Self-employed or employee', async () => { + await expect( + page.getByRole('heading', { + name: label( + oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, + ), + }), + ).toBeVisible() + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.employee), + }) + .click() + await proceed() }) - .click() -} -const onePaymentPerYear = async (page: Page) => { - const { proceed } = helpers(page) + await applicationTest.step('Employer registration', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.registrationTitle), + }), + ).toBeVisible() + + const employerEmail = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.email), + }) + await employerEmail.selectText() + await employerEmail.fill('mockEmail@mail.is') + + await page + .getByRole('radio', { + name: label(oldAgePensionFormMessage.employer.ratioYearly), + }) + .click() - await expect( - page.getByRole('heading', { - name: label( - oldAgePensionFormMessage.onePaymentPerYear.onePaymentPerYearTitle, - ), - }), - ).toBeVisible() - await page - .getByRole('radio', { - name: label(socialInsuranceAdministrationMessage.shared.no), + const employmentRatio = page.getByRole('textbox', { + name: label(oldAgePensionFormMessage.employer.ratio), + }) + await employmentRatio.selectText() + await employmentRatio.fill('50') + await proceed() }) - .click() - await proceed() -} -const viewResidenceHistory = async (page: Page) => { - const { proceed } = helpers(page) + await applicationTest.step('Employers', async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.employer.employerTitle), + }), + ).toBeVisible() + await proceed() + }) + } + + await applicationTest.step('Select period', () => selectPeriod(page)) + + await applicationTest.step( + 'Check that attachments for pension payments header is visible', + async () => { + await expect( + page.getByRole('heading', { + name: label(oldAgePensionFormMessage.fileUpload.pensionFileTitle), + }), + ).toBeVisible() + await proceed() + }, + ) - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.residence.residenceHistoryTitle), - }), - ).toBeVisible() - await proceed() -} + await applicationTest.step( + 'Check that additional documents header is visible', + () => additionalAttachments(page), + ) -const pensionPaymentsAttachments = async (page: Page) => { - const { proceed } = helpers(page) + await applicationTest.step('Write comment', () => writeComment(page)) - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.fileUpload.pensionFileTitle), - }), - ).toBeVisible() - await proceed() -} + await applicationTest.step('Submit application', () => + submitApplication(page), + ) -const conclusionScreen = async (page: Page) => { - await expect( - page - .getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.conclusionScreen - .receivedAwaitingIncomePlanTitle, - ), - }) - .first(), - ).toBeVisible() + await applicationTest.step( + 'Check that conclusion screen header is visible', + async () => { + await expect( + page + .getByRole('heading', { + name: label( + socialInsuranceAdministrationMessage.conclusionScreen + .receivedAwaitingIncomePlanTitle, + ), + }) + .first(), + ).toBeVisible() + }, + ) } const homeUrl = '/umsoknir/ellilifeyrir' @@ -130,65 +225,8 @@ applicationTest.describe('Old Age Pension', () => { 'Should complete Old Age Pension application successfully', 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', () => - agreeToDataProviders(page), - ) - - await applicationTest.step( - 'Answer pension fund question and start application', - () => pensionFunds(page), - ) - - await applicationTest.step('Fill in applicant info', () => - fillApplicantInfo(page), - ) - - await applicationTest.step('Fill in payment information', () => - fillPaymentInfo(page, true), - ) - - await applicationTest.step('One payment per year', () => - onePaymentPerYear(page), - ) - - await applicationTest.step('View residence history', () => - viewResidenceHistory(page), - ) - - await applicationTest.step('Select period', () => selectPeriod(page)) - - await applicationTest.step( - 'Check that attachments for pension payments header is visible', - () => pensionPaymentsAttachments(page), - ) - - await applicationTest.step( - 'Check that additional documents header is visible', - () => additionalAttachments(page), - ) - - await applicationTest.step('Write comment', () => writeComment(page)) - - await applicationTest.step('Submit application', () => - submitApplication(page), - ) - - await applicationTest.step( - 'Check that conclusion screen header is visible', - () => conclusionScreen(page), - ) + await oldAgeApplicationTest(page, 'old-age-pension') }, ) }) @@ -198,118 +236,8 @@ applicationTest.describe('Half Old Age Pension', () => { 'Should complete Half Old Age Pension application successfully', 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('half-old-age-pension').click() - await proceed() - }) - - await applicationTest.step('Agree to data providers', () => - agreeToDataProviders(page), - ) - - await applicationTest.step( - 'Answer pension fund question and start application', - () => pensionFunds(page), - ) - - await applicationTest.step('Fill in applicant info', () => - fillApplicantInfo(page), - ) - - await applicationTest.step('Fill in payment information', () => - fillPaymentInfo(page, true), - ) - - await applicationTest.step('One payment per year', () => - onePaymentPerYear(page), - ) - - await applicationTest.step('View residence history', () => - viewResidenceHistory(page), - ) - - await applicationTest.step('Self-employed or employee', async () => { - await expect( - page.getByRole('heading', { - name: label( - oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, - ), - }), - ).toBeVisible() - - await page - .getByRole('radio', { - name: label(oldAgePensionFormMessage.employer.employee), - }) - .click() - await proceed() - }) - - await applicationTest.step('Employer registration', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.registrationTitle), - }), - ).toBeVisible() - - const employerEmail = page.getByRole('textbox', { - name: label(oldAgePensionFormMessage.employer.email), - }) - await employerEmail.selectText() - await employerEmail.fill('mockEmail@mail.is') - - await page - .getByRole('radio', { - name: label(oldAgePensionFormMessage.employer.ratioYearly), - }) - .click() - - const employmentRatio = page.getByRole('textbox', { - name: label(oldAgePensionFormMessage.employer.ratio), - }) - await employmentRatio.selectText() - await employmentRatio.fill('50') - await proceed() - }) - - await applicationTest.step('Employers', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.employerTitle), - }), - ).toBeVisible() - await proceed() - }) - - await applicationTest.step('Select period', () => selectPeriod(page)) - - await applicationTest.step( - 'Check that attachments for pension payments header is visible', - () => pensionPaymentsAttachments(page), - ) - - await applicationTest.step( - 'Check that additional documents header is visible', - () => additionalAttachments(page), - ) - - await applicationTest.step('Write comment', () => writeComment(page)) - - await applicationTest.step('Submit application', () => - submitApplication(page), - ) - await applicationTest.step( - 'Check that conclusion screen header is visible', - () => conclusionScreen(page), - ) + await oldAgeApplicationTest(page, 'half-old-age-pension') }, ) }) From e6329ee0f2cae400170cec9179496a541cd3f608 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 15:44:07 +0000 Subject: [PATCH 14/17] Updated all instances of faedingardagur in nationalRegistry mocks to use ISO 8601 strings - coderabbit --- .../acceptance/mocks/nationalRegistry.mock.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts index 91ff121893ca..820ea70ac71d 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/mocks/nationalRegistry.mock.ts @@ -18,7 +18,7 @@ export const loadNationalRegistryXroadMocks = async () => { fulltNafn: 'Gervimaður Afríka', kynkodi: '1', bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), + faedingardagur: '1930-01-01T00:00:00', logheimili: { heiti: 'Engihjalli 3', postnumer: '200', @@ -106,7 +106,7 @@ export const loadNationalRegistryXroadMocks = async () => { fulltNafn: 'Gervimaður útlönd', kynkodi: '1', bannmerking: false, - faedingardagur: new Date('1930-01-01T00:00:00'), + faedingardagur: '1930-01-01T00:00:00', logheimili: { heiti: 'Engihjalli 3', postnumer: '200', From 097fa340e9afb2709dcd5b44a49c610d69dd8938 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 16 Oct 2024 17:24:34 +0000 Subject: [PATCH 15/17] [TS-926] Only display available months in TR applications --- .../AdditionalSupportForTheElderlyForm.ts | 66 +++++++++++------ .../additionalSupportForTheElderlyUtils.ts | 48 +++++++++--- .../src/forms/HouseholdSupplementForm.ts | 72 +++++++++++------- .../src/lib/householdSupplementUtils.ts | 36 +++++---- .../src/forms/OldAgePensionForm.ts | 68 ++++++++++------- .../src/lib/oldAgePensionUtils.ts | 50 +++++++------ .../src/forms/PensionSupplementForm.ts | 74 ++++++++++++------- .../src/lib/pensionSupplementUtils.ts | 30 +++++--- 8 files changed, 280 insertions(+), 164 deletions(-) diff --git a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts index 447428a9d306..9772c3bdf933 100644 --- a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts +++ b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/forms/AdditionalSupportForTheElderlyForm.ts @@ -3,50 +3,51 @@ import { buildCustomField, buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildRadioField, buildSection, buildSelectField, - buildSubSection, buildSubmitField, + buildSubSection, buildTextField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' import { - Application, - DefaultEvents, - Form, - FormModes, - FormValue, - YES, -} from '@island.is/application/types' + BankAccountType, + fileUploadSharedProps, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' import { friendlyFormatIBAN, friendlyFormatSWIFT, getBankIsk, - typeOfBankInfo, getCurrencies, - getYesNoOptions, getTaxOptions, + getYesNoOptions, + typeOfBankInfo, } from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { additionalSupportForTheElderyFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' import { - BankAccountType, - fileUploadSharedProps, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - getApplicationExternalData, - getAvailableYears, -} from '../lib/additionalSupportForTheElderlyUtils' + Application, + DefaultEvents, + Form, + FormModes, + FormValue, + YES, +} from '@island.is/application/types' import { applicantInformationMultiField, buildFormConclusionSection, } from '@island.is/application/ui-forms' -import { getApplicationAnswers } from '../lib/additionalSupportForTheElderlyUtils' import isEmpty from 'lodash/isEmpty' +import { + getApplicationAnswers, + getApplicationExternalData, + getAvailableMonths, + getAvailableYears, +} from '../lib/additionalSupportForTheElderlyUtils' +import { additionalSupportForTheElderyFormMessage } from '../lib/messages' export const AdditionalSupportForTheElderlyForm: Form = buildForm({ id: 'AdditionalSupportForTheElderlyDraft', @@ -352,7 +353,24 @@ export const AdditionalSupportForTheElderlyForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts index 52578d67db00..d1dd74e3811e 100644 --- a/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts +++ b/libs/application/templates/social-insurance-administration/additional-support-for-the-elderly/src/lib/additionalSupportForTheElderlyUtils.ts @@ -1,4 +1,16 @@ import { getValueViaPath } from '@island.is/application/core' +import { + BankAccountType, + MONTHS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + AdditionalInformation, + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, ExternalData, @@ -7,22 +19,17 @@ import { import addMonths from 'date-fns/addMonths' import subMonths from 'date-fns/subMonths' import { AttachmentLabel, AttachmentTypes } from './constants' -import { - FileType, - Attachments, - AdditionalInformation, - BankInfo, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' export const getApplicationAnswers = (answers: Application['answers']) => { const selectedYear = getValueViaPath(answers, 'period.year') as string const selectedMonth = getValueViaPath(answers, 'period.month') as string + + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const applicantPhonenumber = getValueViaPath( answers, 'applicant.phoneNumber', @@ -86,6 +93,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicantPhonenumber, selectedYear, selectedMonth, + selectedYearHiddenInput, comment, additionalAttachments, additionalAttachmentsRequired, @@ -230,6 +238,24 @@ export const getAvailableYears = () => { ) } +// returns available months for selected year, since available period is +// 3 months back in time and 6 months in the future. +export const getAvailableMonths = (selectedYear: string) => { + if (!selectedYear) return [] + + const threeMonthsBackInTime = subMonths(new Date(), 3) + const sixMonthsInTheFuture = addMonths(new Date(), 6) + + let months = MONTHS + if (threeMonthsBackInTime.getFullYear().toString() === selectedYear) { + months = months.slice(threeMonthsBackInTime.getMonth() + 1, months.length) + } else if (sixMonthsInTheFuture.getFullYear().toString() === selectedYear) { + months = months.slice(0, sixMonthsInTheFuture.getMonth() + 1) + } + + return months +} + export const isEligible = (externalData: ExternalData): boolean => { const { isEligible } = getApplicationExternalData(externalData) diff --git a/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts b/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts index 980124680daa..cbb1142f20ea 100644 --- a/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts +++ b/libs/application/templates/social-insurance-administration/household-supplement/src/forms/HouseholdSupplementForm.ts @@ -1,18 +1,33 @@ import { + buildAlertMessageField, + buildCustomField, + buildDescriptionField, + buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildPhoneField, + buildRadioField, buildSection, + buildSelectField, buildSubSection, buildSubmitField, buildTextField, - buildCustomField, - buildRadioField, - buildFileUploadField, - buildAlertMessageField, - buildSelectField, - buildDescriptionField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' +import { + BankAccountType, + fileUploadSharedProps, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + getYesNoOptions, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -22,32 +37,18 @@ import { NationalRegistrySpouse, YES, } from '@island.is/application/types' -import { householdSupplementFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { buildFormConclusionSection } from '@island.is/application/ui-forms' +import * as kennitala from 'kennitala' +import isEmpty from 'lodash/isEmpty' import { HouseholdSupplementHousing, maritalStatuses } from '../lib/constants' import { - isExistsCohabitantOlderThan25, getApplicationAnswers, getApplicationExternalData, + getAvailableMonths, getAvailableYears, + isExistsCohabitantOlderThan25, } from '../lib/householdSupplementUtils' -import { - BankAccountType, - MONTHS, - fileUploadSharedProps, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { buildFormConclusionSection } from '@island.is/application/ui-forms' -import isEmpty from 'lodash/isEmpty' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - typeOfBankInfo, - getCurrencies, - getYesNoOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import * as kennitala from 'kennitala' +import { householdSupplementFormMessage } from '../lib/messages' export const HouseholdSupplementForm: Form = buildForm({ id: 'HouseholdSupplementDraft', @@ -530,7 +531,24 @@ export const HouseholdSupplementForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts b/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts index 5fa576ae1a2c..5e21cf054916 100644 --- a/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts +++ b/libs/application/templates/social-insurance-administration/household-supplement/src/lib/householdSupplementUtils.ts @@ -1,29 +1,29 @@ import { getValueViaPath } from '@island.is/application/core' import { - HouseholdSupplementHousing, - AttachmentLabel, - AttachmentTypes, -} from './constants' + BankAccountType, + MONTHS, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, - YesOrNo, - YES, ExternalData, + YES, + YesOrNo, } from '@island.is/application/types' import addMonths from 'date-fns/addMonths' import subYears from 'date-fns/subYears' import * as kennitala from 'kennitala' import { FileUpload } from '../types' import { - Attachments, - BankInfo, - FileType, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - MONTHS, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' + AttachmentLabel, + AttachmentTypes, + HouseholdSupplementHousing, +} from './constants' export const getApplicationAnswers = (answers: Application['answers']) => { const applicantPhonenumber = getValueViaPath( @@ -55,6 +55,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const additionalAttachments = getValueViaPath( answers, 'fileUploadAdditionalFiles.additionalDocuments', @@ -102,6 +107,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { leaseAgreementAttachments, selectedYear, selectedMonth, + selectedYearHiddenInput, additionalAttachments, additionalAttachmentsRequired, comment, 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 e54267247f75..2d086a88fa4f 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 @@ -3,6 +3,7 @@ import { buildCustomField, buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, buildRadioField, buildRepeater, @@ -12,6 +13,23 @@ import { buildSubSection, buildTextField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' +import { + BankAccountType, + fileUploadSharedProps, + IS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + getTaxOptions, + getYesNoOptions, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -21,37 +39,20 @@ import { NO, YES, } from '@island.is/application/types' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { oldAgePensionFormMessage } from '../lib/messages' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + applicantInformationMultiField, + buildFormConclusionSection, +} from '@island.is/application/ui-forms' +import isEmpty from 'lodash/isEmpty' import { ApplicationType, Employment, RatioType } from '../lib/constants' +import { oldAgePensionFormMessage } from '../lib/messages' import { getApplicationAnswers, getApplicationExternalData, + getAvailableMonths, getAvailableYears, isEarlyRetirement, } from '../lib/oldAgePensionUtils' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - getCurrencies, - typeOfBankInfo, - getYesNoOptions, - getTaxOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import { - applicantInformationMultiField, - buildFormConclusionSection, -} from '@island.is/application/ui-forms' -import isEmpty from 'lodash/isEmpty' -import { - BankAccountType, - fileUploadSharedProps, - IS, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' export const OldAgePensionForm: Form = buildForm({ id: 'OldAgePensionDraft', @@ -586,7 +587,24 @@ export const OldAgePensionForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(application, selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), buildAlertMessageField({ id: 'period.alert', diff --git a/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts b/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts index 1834e636073e..7ddec140d8ad 100644 --- a/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts +++ b/libs/application/templates/social-insurance-administration/old-age-pension/src/lib/oldAgePensionUtils.ts @@ -1,40 +1,40 @@ import { getValueViaPath } from '@island.is/application/core' import { - oldAgePensionAge, - earlyRetirementMinAge, - earlyRetirementMaxAge, - ApplicationType, - Employment, - AttachmentLabel, - AttachmentTypes, -} from './constants' + BankAccountType, + MONTHS, + TaxLevelOptions, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { + Attachments, + BankInfo, + FileType, + PaymentInfo, +} from '@island.is/application/templates/social-insurance-administration-core/types' import { Application, NationalRegistryResidenceHistory, YesOrNo, } from '@island.is/application/types' -import { oldAgePensionFormMessage } from './messages' -import * as kennitala from 'kennitala' -import addYears from 'date-fns/addYears' import addMonths from 'date-fns/addMonths' +import addYears from 'date-fns/addYears' +import * as kennitala from 'kennitala' import { CombinedResidenceHistory, Employer, + FileUpload, IncompleteEmployer, SelfEmployed, - FileUpload, } from '../types' import { - BankAccountType, - MONTHS, - TaxLevelOptions, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - Attachments, - BankInfo, - FileType, - PaymentInfo, -} from '@island.is/application/templates/social-insurance-administration-core/types' + ApplicationType, + AttachmentLabel, + AttachmentTypes, + earlyRetirementMaxAge, + earlyRetirementMinAge, + Employment, + oldAgePensionAge, +} from './constants' +import { oldAgePensionFormMessage } from './messages' export const getApplicationAnswers = (answers: Application['answers']) => { const pensionFundQuestion = getValueViaPath( @@ -51,6 +51,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const applicantPhonenumber = getValueViaPath( answers, 'applicant.phoneNumber', @@ -154,6 +159,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicationType, selectedYear, selectedMonth, + selectedYearHiddenInput, applicantPhonenumber, bank, residenceHistoryQuestion, diff --git a/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts b/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts index 6f81b31315d5..4e9a5fd7af24 100644 --- a/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts +++ b/libs/application/templates/social-insurance-administration/pension-supplement/src/forms/PensionSupplementForm.ts @@ -1,21 +1,31 @@ import { + buildAlertMessageField, + buildCheckboxField, + buildCustomField, + buildFileUploadField, buildForm, + buildHiddenInputWithWatchedValue, buildMultiField, + buildRadioField, buildSection, + buildSelectField, + buildSubmitField, buildSubSection, buildTextField, - buildCustomField, - buildSubmitField, - buildCheckboxField, - buildFileUploadField, - buildAlertMessageField, - buildRadioField, - buildSelectField, } from '@island.is/application/core' +import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' import { - applicantInformationMultiField, - buildFormConclusionSection, -} from '@island.is/application/ui-forms' + BankAccountType, + fileUploadSharedProps, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' +import { + friendlyFormatIBAN, + friendlyFormatSWIFT, + getBankIsk, + getCurrencies, + typeOfBankInfo, +} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' import { Application, DefaultEvents, @@ -23,29 +33,20 @@ import { FormModes, FormValue, } from '@island.is/application/types' +import { + applicantInformationMultiField, + buildFormConclusionSection, +} from '@island.is/application/ui-forms' +import isEmpty from 'lodash/isEmpty' +import { ApplicationReason } from '../lib/constants' import { pensionSupplementFormMessage } from '../lib/messages' import { - getApplicationReasonOptions, getApplicationAnswers, getApplicationExternalData, + getApplicationReasonOptions, + getAvailableMonths, getAvailableYears, } from '../lib/pensionSupplementUtils' -import { ApplicationReason } from '../lib/constants' -import { - MONTHS, - fileUploadSharedProps, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import isEmpty from 'lodash/isEmpty' -import { BankAccountType } from '@island.is/application/templates/social-insurance-administration-core/lib/constants' -import { - friendlyFormatIBAN, - friendlyFormatSWIFT, - getBankIsk, - getCurrencies, - typeOfBankInfo, -} from '@island.is/application/templates/social-insurance-administration-core/lib/socialInsuranceAdministrationUtils' -import Logo from '@island.is/application/templates/social-insurance-administration-core/assets/Logo' -import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' export const PensionSupplementForm: Form = buildForm({ id: 'PensionSupplementDraft', @@ -312,7 +313,24 @@ export const PensionSupplementForm: Form = buildForm({ width: 'half', placeholder: socialInsuranceAdministrationMessage.period.monthDefaultText, - options: MONTHS, + options: (application: Application) => { + const { selectedYear } = getApplicationAnswers( + application.answers, + ) + + return getAvailableMonths(selectedYear) + }, + condition: (answers) => { + const { selectedYear, selectedYearHiddenInput } = + getApplicationAnswers(answers) + + return selectedYear === selectedYearHiddenInput + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on options in the select above + id: 'period.hiddenInput', + watchValue: 'period.year', }), ], }), diff --git a/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts b/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts index 14615e6c3564..cdefa151c0ed 100644 --- a/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts +++ b/libs/application/templates/social-insurance-administration/pension-supplement/src/lib/pensionSupplementUtils.ts @@ -1,23 +1,23 @@ import { getValueViaPath } from '@island.is/application/core' -import { Application, ExternalData, Option } from '@island.is/application/types' import { - ApplicationReason, - AttachmentLabel, - AttachmentTypes, -} from './constants' -import { pensionSupplementFormMessage } from './messages' -import subYears from 'date-fns/subYears' -import addMonths from 'date-fns/addMonths' + BankAccountType, + MONTHS, +} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' import { Attachments, BankInfo, FileType, } from '@island.is/application/templates/social-insurance-administration-core/types' -import { - BankAccountType, - MONTHS, -} from '@island.is/application/templates/social-insurance-administration-core/lib/constants' +import { Application, ExternalData, Option } from '@island.is/application/types' +import addMonths from 'date-fns/addMonths' +import subYears from 'date-fns/subYears' import { PensionSupplementAttachments } from '../types' +import { + ApplicationReason, + AttachmentLabel, + AttachmentTypes, +} from './constants' +import { pensionSupplementFormMessage } from './messages' export const getApplicationAnswers = (answers: Application['answers']) => { const applicantPhonenumber = getValueViaPath( @@ -34,6 +34,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const selectedMonth = getValueViaPath(answers, 'period.month') as string + const selectedYearHiddenInput = getValueViaPath( + answers, + 'period.hiddenInput', + ) as string + const additionalAttachments = getValueViaPath( answers, 'fileUploadAdditionalFiles.additionalDocuments', @@ -106,6 +111,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => { applicationReason, selectedYear, selectedMonth, + selectedYearHiddenInput, additionalAttachments, additionalAttachmentsRequired, comment, From 731b2000404b9f8236d5717e57d1223efe3dc2fe Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Thu, 17 Oct 2024 09:06:25 +0000 Subject: [PATCH 16/17] Removed TODO comment --- .../acceptance/social-insurance-administration/shared.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts index 369a9b0370b4..f185d7ae53e6 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts @@ -78,7 +78,6 @@ export const selectPeriod = async (page: Page) => { 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') From bbbd1268c496d7b5062a47e9f79fcd9f7ed3e8df Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Thu, 17 Oct 2024 10:23:16 +0000 Subject: [PATCH 17/17] Refactor repeated heading visibility checks - coderabbit --- ...additional-support-for-the-elderly.spec.ts | 12 ++- .../household-supplement.spec.ts | 23 ++--- .../old-age-pension.spec.ts | 88 ++++++++----------- .../pension-supplement.spec.ts | 21 ++--- .../social-insurance-administration/shared.ts | 61 ++++++------- 5 files changed, 91 insertions(+), 114 deletions(-) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts index f8bcda2b0130..cd0beb0e65b0 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/additional-support-for-the-elderly.spec.ts @@ -9,6 +9,7 @@ import { session } from '../../../../../support/session' import { setupXroadMocks } from '../setup-xroad.mocks' import { additionalAttachments, + expectHeadingToBeVisible, fillApplicantInfo, fillPaymentInfo, selectPeriod, @@ -49,13 +50,10 @@ applicationTest.describe('Additional support for the elderly', () => { const page = applicationPage await applicationTest.step('Agree to data providers', async () => { - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.pre.externalDataSection, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.pre.externalDataSection, + ) await page.getByTestId('agree-to-data-providers').click() await page .getByRole('button', { diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts index 1a830a811f21..2827ea5c8238 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/household-supplement.spec.ts @@ -11,6 +11,7 @@ import { session } from '../../../../../support/session' import { setupXroadMocks } from '../setup-xroad.mocks' import { additionalAttachments, + expectHeadingToBeVisible, fillApplicantInfo, fillPaymentInfo, selectPeriod, @@ -50,13 +51,10 @@ applicationTest.describe('Household Supplement', () => { const { proceed } = helpers(page) await applicationTest.step('Agree to data providers', async () => { - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.pre.externalDataSection, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.pre.externalDataSection, + ) await page.getByTestId('agree-to-data-providers').click() await page .getByRole('button', { @@ -76,13 +74,10 @@ applicationTest.describe('Household Supplement', () => { ) await applicationTest.step('Household supplement', async () => { - await expect( - page.getByRole('heading', { - name: label( - householdSupplementFormMessage.shared.householdSupplement, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + householdSupplementFormMessage.shared.householdSupplement, + ) await page .getByRole('region', { diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts index 60bbc9a6c410..580622c31d55 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/old-age-pension.spec.ts @@ -11,6 +11,7 @@ import { session } from '../../../../../support/session' import { setupXroadMocks } from '../setup-xroad.mocks' import { additionalAttachments, + expectHeadingToBeVisible, fillApplicantInfo, fillPaymentInfo, selectPeriod, @@ -22,23 +23,19 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { const { proceed } = helpers(page) await applicationTest.step('Select type of application', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.pre.applicationTypeTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.pre.applicationTypeTitle, + ) await page.getByTestId(applicationType).click() await proceed() }) await applicationTest.step('Agree to data providers', async () => { - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.pre.externalDataSection, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.pre.externalDataSection, + ) await page.getByTestId('agree-to-data-providers').click() await proceed() }) @@ -46,11 +43,10 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { await applicationTest.step( 'Answer pension fund question and start application', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.pre.questionTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.pre.questionTitle, + ) await page .getByRole('radio', { name: label(socialInsuranceAdministrationMessage.shared.yes), @@ -75,13 +71,10 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { ) await applicationTest.step('One payment per year', async () => { - await expect( - page.getByRole('heading', { - name: label( - oldAgePensionFormMessage.onePaymentPerYear.onePaymentPerYearTitle, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.onePaymentPerYear.onePaymentPerYearTitle, + ) await page .getByRole('radio', { name: label(socialInsuranceAdministrationMessage.shared.no), @@ -91,23 +84,19 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { }) await applicationTest.step('View residence history', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.residence.residenceHistoryTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.residence.residenceHistoryTitle, + ) await proceed() }) if (applicationType === 'half-old-age-pension') { await applicationTest.step('Self-employed or employee', async () => { - await expect( - page.getByRole('heading', { - name: label( - oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.employer.selfEmployedOrEmployeeTitle, + ) await page .getByRole('radio', { @@ -118,11 +107,10 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { }) await applicationTest.step('Employer registration', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.registrationTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.employer.registrationTitle, + ) const employerEmail = page.getByRole('textbox', { name: label(oldAgePensionFormMessage.employer.email), @@ -145,11 +133,10 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { }) await applicationTest.step('Employers', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.employer.employerTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.employer.employerTitle, + ) await proceed() }) } @@ -159,11 +146,10 @@ const oldAgeApplicationTest = async (page: Page, applicationType: string) => { await applicationTest.step( 'Check that attachments for pension payments header is visible', async () => { - await expect( - page.getByRole('heading', { - name: label(oldAgePensionFormMessage.fileUpload.pensionFileTitle), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + oldAgePensionFormMessage.fileUpload.pensionFileTitle, + ) await proceed() }, ) diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts index 68f0e8f662ea..3df87bc4404e 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/pension-supplement.spec.ts @@ -11,6 +11,7 @@ import { session } from '../../../../../support/session' import { setupXroadMocks } from '../setup-xroad.mocks' import { additionalAttachments, + expectHeadingToBeVisible, fillApplicantInfo, fillPaymentInfo, selectPeriod, @@ -50,13 +51,10 @@ applicationTest.describe('Pension Supplement', () => { const { proceed } = helpers(page) await applicationTest.step('Agree to data providers', async () => { - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.pre.externalDataSection, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.pre.externalDataSection, + ) await page.getByTestId('agree-to-data-providers').click() await page .getByRole('button', { @@ -76,11 +74,10 @@ applicationTest.describe('Pension Supplement', () => { ) await applicationTest.step('Select application reason', async () => { - await expect( - page.getByRole('heading', { - name: label(pensionSupplementFormMessage.applicationReason.title), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + pensionSupplementFormMessage.applicationReason.title, + ) await page .getByRole('region', { diff --git a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts index f185d7ae53e6..f48d38e521e2 100644 --- a/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts +++ b/apps/system-e2e/src/tests/islandis/application-system/acceptance/social-insurance-administration/shared.ts @@ -1,18 +1,27 @@ import { socialInsuranceAdministrationMessage } from '@island.is/application/templates/social-insurance-administration-core/lib/messages' import { expect, Page } from '@playwright/test' +import { MessageDescriptor } from 'react-intl' import { label } from '../../../../../support/i18n' import { helpers } from '../../../../../support/locator-helpers' -export const fillApplicantInfo = async (page: Page) => { - const { proceed } = helpers(page) - +export const expectHeadingToBeVisible = async ( + page: Page, + message: MessageDescriptor, +) => { await expect( page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.info.infoSubSectionTitle, - ), + name: label(message), }), ).toBeVisible() +} + +export const fillApplicantInfo = async (page: Page) => { + const { proceed } = helpers(page) + + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.info.infoSubSectionTitle, + ) const phoneNumber = page.getByRole('textbox', { name: label(socialInsuranceAdministrationMessage.info.applicantPhonenumber), @@ -25,11 +34,10 @@ export const fillApplicantInfo = async (page: Page) => { export const fillPaymentInfo = async (page: Page, includeTax: boolean) => { const { proceed } = helpers(page) - await expect( - page.getByRole('heading', { - name: label(socialInsuranceAdministrationMessage.payment.title), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.payment.title, + ) const paymentBank = page.getByRole('textbox', { name: label(socialInsuranceAdministrationMessage.payment.bank), }) @@ -69,11 +77,10 @@ export const fillPaymentInfo = async (page: Page, includeTax: boolean) => { export const selectPeriod = async (page: Page) => { const { proceed } = helpers(page) - await expect( - page.getByRole('heading', { - name: label(socialInsuranceAdministrationMessage.period.title), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.period.title, + ) await page.getByTestId('select-period.year').click() await page.keyboard.press('Enter') @@ -87,26 +94,20 @@ export const selectPeriod = async (page: Page) => { export const additionalAttachments = async (page: Page) => { const { proceed } = helpers(page) - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.fileUpload.additionalFileTitle, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.fileUpload.additionalFileTitle, + ) await proceed() } export const writeComment = async (page: Page) => { const { proceed } = helpers(page) - await expect( - page.getByRole('heading', { - name: label( - socialInsuranceAdministrationMessage.additionalInfo.commentSection, - ), - }), - ).toBeVisible() + await expectHeadingToBeVisible( + page, + socialInsuranceAdministrationMessage.additionalInfo.commentSection, + ) await page .getByPlaceholder( label(