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'