Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
159 changes: 159 additions & 0 deletions tests/sites/sote/longterm-assisted-living-fee/fixtures/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { expect, test, type Page, type Locator } from '@playwright/test';

async function selectRadioOption(group: Locator, option: 'yes' | 'no') {
await group.waitFor({ state: 'visible' });

const labelText = option === 'yes' ? 'Kyllä' : 'Ei';
const label = group.locator('label', { hasText: labelText });

await expect(label).toBeVisible();
await label.click();

const input =
option === 'yes' ? group.locator('input[type="radio"]').first() : group.locator('input[type="radio"]').last();

await expect(input).toBeChecked();
}

const fillEarnedIncome = (page: Page, value: string) =>
test.step('Fill earned income', async () => {
await page.getByLabel('Ansiotulot (euroa)', { exact: true }).fill(String(value));
});

const fillClientBenefits = (page: Page, value: string) =>
test.step('Fill client benefits', async () => {
await page.getByLabel('Etuudet (euroa)', { exact: true }).fill(String(value));
});

const fillCapitalIncome = (page: Page, value: string) =>
test.step('Fill capital income', async () => {
await page.getByLabel('Pääomatulot (euroa)', { exact: true }).fill(String(value));
});

const fillAnnualForestIncome = (page: Page, value: string) =>
test.step('Fill annual forest income', async () => {
await page.getByLabel('Metsän vuotuinen tuotto (euroa)', { exact: true }).fill(String(value));
});

const fillGuardianshipFees = (page: Page, value: string) =>
test.step('Fill guardianship fees', async () => {
await page.getByLabel('Edunvalvontamaksut (euroa)', { exact: true }).fill(String(value));
});

const fillClientForeclosure = (page: Page, value: string) =>
test.step('Fill client foreclosure', async () => {
await page.getByLabel('Ulosmittaus (euroa)', { exact: true }).fill(String(value));
});

const fillCompensationOrLifeAnnuity = (page: Page, value: string) =>
test.step('Fill compensation or life annuity', async () => {
await page.getByLabel('Hyvitys tai syytinki (euroa)', { exact: true }).fill(String(value));
});

const fillMaintenancePayments = (page: Page, value: string) =>
test.step('Fill maintenance payments', async () => {
await page.getByLabel('Elatusapu (euroa)', { exact: true }).fill(String(value));
});

const fillMedicationCosts = (page: Page, value: string) =>
test.step('Fill medication costs', async () => {
await page.getByLabel('Lääkekulut (euroa)', { exact: true }).fill(String(value));
});

const fillShareOfHousingCosts = (page: Page, value: string) =>
test.step('Fill share of housing costs', async () => {
await page.getByLabel('Asumiskulujen omavastuu (euroa)', { exact: true }).fill(String(value));
});

const selectHasSpouseYes = (page: Page) =>
test.step('Select has spouse: yes', async () => {
const group = page.getByRole('group', {
name: 'Onko asiakkaalla puolisoa',
});
await selectRadioOption(group, 'yes');
});

const selectHasSpouseNo = (page: Page) =>
test.step('Select has spouse: no', async () => {
const group = page.getByRole('group', {
name: 'Onko asiakkaalla puolisoa',
});

await selectRadioOption(group, 'no');
});

const fillSpouseEarnedIncome = (page: Page, value: string) =>
test.step('Fill spouse earned income', async () => {
await page.getByLabel('Puolison ansiotulot (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseClientBenefits = (page: Page, value: string) =>
test.step('Fill spouse client benefits', async () => {
await page.getByLabel('Puolison etuudet (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseCapitalIncome = (page: Page, value: string) =>
test.step('Fill spouse capital income', async () => {
await page.getByLabel('Puolison pääomatulot (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseAnnualForestIncome = (page: Page, value: string) =>
test.step('Fill spouse annual forest income', async () => {
await page.getByLabel('Puolison metsän vuotuinen tuotto (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseGuardianshipFees = (page: Page, value: string) =>
test.step('Fill spouse guardianship fees', async () => {
await page.getByLabel('Puolison edunvalvontamaksut (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseClientForeclosure = (page: Page, value: string) =>
test.step('Fill spouse foreclosure', async () => {
await page.getByLabel('Puolison ulosmittaus (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseCompensationOrLifeAnnuity = (page: Page, value: string) =>
test.step('Fill spouse compensation or life annuity', async () => {
await page.getByLabel('Puolison hyvitys tai syytinki (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseMaintenancePayments = (page: Page, value: string) =>
test.step('Fill spouse maintenance payments', async () => {
await page.getByLabel('Puolison elatusapu (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseMedicationCosts = (page: Page, value: string) =>
test.step('Fill spouse medication costs', async () => {
await page.getByLabel('Puolison lääkekulut (euroa)', { exact: true }).fill(String(value));
});

const fillSpouseShareOfHousingCosts = (page: Page, value: string) =>
test.step('Fill spouse share of housing costs', async () => {
await page.getByLabel('Puolison asumiskulujen omavastuu (euroa)', { exact: true }).fill(String(value));
});


export {
fillEarnedIncome,
fillClientBenefits,
fillCapitalIncome,
fillAnnualForestIncome,
fillGuardianshipFees,
fillClientForeclosure,
fillCompensationOrLifeAnnuity,
fillMaintenancePayments,
fillMedicationCosts,
fillShareOfHousingCosts,
selectHasSpouseYes,
selectHasSpouseNo,
fillSpouseEarnedIncome,
fillSpouseClientBenefits,
fillSpouseCapitalIncome,
fillSpouseAnnualForestIncome,
fillSpouseGuardianshipFees,
fillSpouseClientForeclosure,
fillSpouseCompensationOrLifeAnnuity,
fillSpouseMaintenancePayments,
fillSpouseMedicationCosts,
fillSpouseShareOfHousingCosts,
};
66 changes: 66 additions & 0 deletions tests/sites/sote/longterm-assisted-living-fee/form.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { expect, test } from '@playwright/test';
import { existsBeforeEach, testUnfilledFields } from '../../../common/calculators/calculatorsCommon';

test.beforeEach(
existsBeforeEach(
'/fi/sosiaali-ja-terveyspalvelut/pitkaaikaisen-ymparivuorokautisen-palveluasumisen-asiakasmaksun-laskuri',
),
);

test('Test unfilled fields', async ({ page }) => {
await testUnfilledFields(page);
});

test('Earned income input must be positive', async ({ page }) => {
await page.getByLabel('Ansiotulot (euroa)', { exact: true }).fill('-1');
await page.getByRole('button', { name: 'Laske arvio' }).click();

expect(await page.getByText('Arvon pitää olla 0 tai enemmän: Ansiotulot.').isVisible()).toBeTruthy();

await page.getByLabel('Ansiotulot (euroa)', { exact: true }).fill('1500,50€');
await page.getByRole('button', { name: 'Laske arvio' }).click();

expect(await page.getByText('Arvon pitää olla 0 tai enemmän: Ansiotulot.').isVisible()).toBeFalsy();
});

test('Annual forest income input must be positive', async ({ page }) => {
await page.getByLabel('Metsän vuotuinen tuotto (euroa)', { exact: true }).fill('-10');
await page.getByRole('button', { name: 'Laske arvio' }).click();

expect(await page.getByText('Arvon pitää olla 0 tai enemmän: Metsän vuotuinen tuotto.').isVisible()).toBeTruthy();
});

test('Has spouse selection must be selected', async ({ page }) => {
await page.getByRole('button', { name: 'Laske arvio' }).click();

expect(await page.getByText('Valinta on pakollinen: Onko asiakkaalla puolisoa?').isVisible()).toBeTruthy();
});

test('Spouse earned income must be positive when spouse is selected', async ({ page }) => {
const group = page.getByRole('group', {name: 'Onko asiakkaalla puolisoa'});

await group.locator('label', { hasText: 'Kyllä' }).click();

await page.getByLabel('Puolison ansiotulot (euroa)').fill('-100');
await page.getByRole('button', { name: 'Laske arvio' }).click();

expect(await page.getByText('Arvon pitää olla 0 tai enemmän: Puolison ansiotulot.').isVisible(),).toBeTruthy();
});

test('Valid inputs produce a result receipt', async ({ page }) => {

await page.getByLabel('Ansiotulot (euroa)', { exact: true }).fill('2000');
await page.getByLabel('Etuudet (euroa)', { exact: true }).fill('500');
await page.getByLabel('Pääomatulot (euroa)', { exact: true }).fill('0');
await page.getByLabel('Metsän vuotuinen tuotto (euroa)', { exact: true }).fill('1200');

await page.getByRole('group', { name: 'Onko asiakkaalla puolisoa' })
.locator('label', { hasText: 'Ei' })
.click();

await page.getByRole('button', { name: 'Laske arvio' }).click();

await expect(
page.getByText('Arvoitu asiakasmaksu on yhteensä'),
).toBeVisible();
});
Loading