Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(social-insurance-administration): Add e2e tests #16397

Merged
merged 21 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a038d6f
[TS-106] e2e tests (Old-age-pension)
veronikasif Oct 15, 2024
5bfdcfd
[TS-319] e2e tests (Additional-support-for-the-elderly)
veronikasif Oct 15, 2024
a8137ca
Fixed typo in nationalRegistry.mock file after coderabbit review
veronikasif Oct 15, 2024
8e1bec7
[TS-156] e2e tests (Pension-supplement)
veronikasif Oct 15, 2024
f15ef35
chore: nx format:write update dirty files
andes-it Oct 15, 2024
bc36986
[TS-155] e2e tests (Household-supplement)
veronikasif Oct 15, 2024
48b9239
Merge branch 'feat/social-insurance-administration-e2e' of https://gi…
veronikasif Oct 15, 2024
6e527fe
[TS-324] e2e test for 1/2 old age pension
veronikasif Oct 15, 2024
f5defe6
Added a helper function that mocks each type of SIA application - cod…
veronikasif Oct 15, 2024
6665d45
Moved all common steps to a shared file so it can be used in multiple…
veronikasif Oct 15, 2024
c23a72c
Updated all instances of faedingardagur in parentalLeave mocks to use…
veronikasif Oct 16, 2024
4ad882c
Added more descriptive test names - coderabbit
veronikasif Oct 16, 2024
115d5d8
Changed getByRole to getByText in submitApplication - coderabbit
veronikasif Oct 16, 2024
e1e6f75
Updated OAP tests - coderabbit
veronikasif Oct 16, 2024
e6329ee
Updated all instances of faedingardagur in nationalRegistry mocks to …
veronikasif Oct 16, 2024
097fa34
[TS-926] Only display available months in TR applications
veronikasif Oct 16, 2024
731b200
Removed TODO comment
veronikasif Oct 17, 2024
bbbd126
Refactor repeated heading visibility checks - coderabbit
veronikasif Oct 17, 2024
51603d7
Merge branch 'main' into feat/social-insurance-administration-e2e
veronikasif Oct 17, 2024
b80c8d5
Merge branch 'main' into feat/social-insurance-administration-e2e
veronikasif Oct 18, 2024
4aceb5d
Merge branch 'main' into feat/social-insurance-administration-e2e
kodiakhq[bot] Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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()
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
})

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()
})
veronikasif marked this conversation as resolved.
Show resolved Hide resolved

await applicationTest.step(
'Check that conclusion screen header is visible',
async () => {
await expect(
page
.getByRole('heading', {
name: label(
socialInsuranceAdministrationMessage.conclusionScreen
.receivedAwaitingIncomePlanTitle,
),
})
.first(),
).toBeVisible()
},
)
},
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import { Response } from '@anev/ts-mountebank'
import { NationalRegistry } from '../../../../../../../../infra/src/dsl/xroad'
import { addXroadMock } from '../../../../../support/wire-mocks'
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
veronikasif marked this conversation as resolved.
Show resolved Hide resolved

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',
}),
})
veronikasif marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading