-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: review application edit changes before submit (hl-1062) (#2838)
* refactor: rename application api view for easier editor search * feat: application history to use text field (from varchar 100) * feat: update change reason historical record from payload * feat: add review for edit changes * refactor: add modal customizations to theme files * fix: add validation to paper application date * chore: e2e tests for handler edit/review * refactor: make date function more generic with parameter
- Loading branch information
Showing
39 changed files
with
1,227 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...benefit/applications/migrations/0058_alter_historicalapplication_history_change_reason.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.18 on 2024-01-24 09:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("applications", "0057_attachment_type_decision_text"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="historicalapplication", | ||
name="history_change_reason", | ||
field=models.TextField(null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
export const NEW_FORM_DATA = { | ||
company: { | ||
id: '0201256-6', | ||
bankAccountNumber: 'FI81 4975 4587 0004 02', | ||
firstName: 'Kuura', | ||
lastName: 'Massi-Päällikkö', | ||
phone: '050 000 0000', | ||
email: '[email protected]', | ||
coOperationNegotiationsDescription: 'Lorem ipsum dolor sit amet', | ||
}, | ||
employee: { | ||
firstName: 'Ruu', | ||
lastName: 'Rättisitikka', | ||
ssn: '050632-8912', | ||
monthlyPay: '1800', | ||
vacationMoney: '100', | ||
otherExpenses: '300', | ||
jobTitle: 'Verkkosamooja', | ||
workingHours: '30', | ||
collectiveBargainingAgreement: 'Yleinen TES', | ||
}, | ||
deminimis: { | ||
granter: 'Valtio', | ||
amount: '2000', | ||
grantedAt: `1.1.${new Date().getFullYear()}`, | ||
}, | ||
}; | ||
|
||
export const EDIT_FORM_DATA = { | ||
company: { | ||
bankAccountNumber: 'FI65 4712 8581 0006 05', | ||
firstName: 'Malla', | ||
lastName: 'Jout-Sen', | ||
phone: '040 123 4567', | ||
email: '[email protected]', | ||
coOperationNegotiationsDescription: 'Aenean fringilla lorem tellus', | ||
}, | ||
employee: { | ||
firstName: 'Cool', | ||
lastName: 'Kanerva', | ||
ssn: '211081-2043', | ||
monthlyPay: '1111', | ||
vacationMoney: '222', | ||
otherExpenses: '333', | ||
jobTitle: 'Some-asiantuntija', | ||
workingHours: '18', | ||
collectiveBargainingAgreement: '-', | ||
}, | ||
deminimis: { | ||
granter: 'Hyvän tekijät Inc.', | ||
amount: '3000', | ||
grantedAt: `3.3.${new Date().getFullYear() - 1}`, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,38 +4,11 @@ import { format } from 'date-fns'; | |
import { Selector } from 'testcafe'; | ||
|
||
import fi from '../../public/locales/fi/common.json'; | ||
import { NEW_FORM_DATA as form } from '../constants/forms'; | ||
import MainIngress from '../page-model/MainIngress'; | ||
import handlerUser from '../utils/handlerUser'; | ||
import { getFrontendUrl } from '../utils/url.utils'; | ||
|
||
const form = { | ||
company: { | ||
id: '0201256-6', | ||
bankAccountNumber: 'FI81 4975 4587 0004 02', | ||
firstName: 'Kuura', | ||
lastName: 'Massi-Päällikkö', | ||
phone: '050 000 0000', | ||
email: '[email protected]', | ||
coOperationNegotiationsDescription: 'Lorem ipsum dolor sit amet', | ||
}, | ||
employee: { | ||
firstName: 'Ruu', | ||
lastName: 'Rättisitikka', | ||
ssn: '050632-8912', | ||
monthlyPay: '1800', | ||
vacationMoney: '100', | ||
otherExpenses: '300', | ||
jobTitle: 'Verkkosamooja', | ||
workingHours: '30', | ||
collectiveBargainingAgreement: 'Yleinen TES', | ||
}, | ||
deminimis: { | ||
granter: 'Valtio', | ||
amount: '2000', | ||
grantedAt: `1.1.${new Date().getFullYear()}`, | ||
}, | ||
}; | ||
|
||
const url = getFrontendUrl(`/`); | ||
|
||
const uploadFileAttachment = async ( | ||
|
@@ -48,7 +21,7 @@ const uploadFileAttachment = async ( | |
await t.wait(100); | ||
}; | ||
|
||
fixture('New application') | ||
fixture('Create new application') | ||
.page(url) | ||
.beforeEach(async (t) => { | ||
clearDataToPrintOnFailure(t); | ||
|
@@ -127,9 +100,13 @@ test('Fill form and submit', async (t: TestController) => { | |
); | ||
|
||
await uploadFileAttachment(t, '#upload_attachment_full_application'); | ||
await t.wait(1000); | ||
await uploadFileAttachment(t, '#upload_attachment_employment_contract'); | ||
await uploadFileAttachment(t, '#upload_attachment_pay_subsidy_decision'); | ||
await t.wait(1000); | ||
await uploadFileAttachment(t, '#upload_attachment_education_contract'); | ||
await t.wait(1000); | ||
await uploadFileAttachment(t, '#upload_attachment_pay_subsidy_decision'); | ||
await t.wait(1000); | ||
|
||
/** | ||
* Click through all applicant terms. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,37 +4,11 @@ import { format } from 'date-fns'; | |
import { Selector } from 'testcafe'; | ||
|
||
import fi from '../../public/locales/fi/common.json'; | ||
import { EDIT_FORM_DATA as form, NEW_FORM_DATA } from '../constants/forms'; | ||
import MainIngress from '../page-model/MainIngress'; | ||
import handlerUser from '../utils/handlerUser'; | ||
import { getFrontendUrl } from '../utils/url.utils'; | ||
|
||
const form = { | ||
company: { | ||
bankAccountNumber: 'FI81 4975 4587 0004 02', | ||
firstName: 'Malla', | ||
lastName: 'Jout-Sen', | ||
phone: '040 123 4567', | ||
email: '[email protected]', | ||
coOperationNegotiationsDescription: 'Aenean fringilla lorem tellus', | ||
}, | ||
employee: { | ||
firstName: 'Cool', | ||
lastName: 'Kanerva', | ||
ssn: '211081-2043', | ||
monthlyPay: '1111', | ||
vacationMoney: '222', | ||
otherExpenses: '333', | ||
jobTitle: 'Some-asiantuntija', | ||
workingHours: '18', | ||
collectiveBargainingAgreement: '-', | ||
}, | ||
deminimis: { | ||
granter: 'Hyvän tekijät Inc.', | ||
amount: '3000', | ||
grantedAt: `3.3.${new Date().getFullYear() - 1}`, | ||
}, | ||
}; | ||
|
||
const url = getFrontendUrl(`/`); | ||
|
||
const uploadFileAttachment = async ( | ||
|
@@ -52,32 +26,35 @@ const clearAndFill = async ( | |
selector: string, | ||
value: string | ||
) => { | ||
await t.click(selector); | ||
await t.selectText(selector); | ||
await t.pressKey('delete'); | ||
await t.typeText(selector, value ?? ''); | ||
}; | ||
|
||
fixture('New application') | ||
fixture('Edit existing application') | ||
.page(url) | ||
.beforeEach(async (t) => { | ||
clearDataToPrintOnFailure(t); | ||
await t.useRole(handlerUser); | ||
await t.navigateTo('/'); | ||
}); | ||
|
||
test('Fill form and submit', async (t: TestController) => { | ||
test('Open form and edit fields, then submit', async (t: TestController) => { | ||
const mainIngress = new MainIngress(fi.mainIngress.heading, 'h1'); | ||
await mainIngress.isLoaded(); | ||
|
||
// Open already created form in index page | ||
// Open already created application in index page | ||
const applicationLink = Selector('td') | ||
.withText('Ruu Rättisitikka') | ||
.withText( | ||
`${NEW_FORM_DATA.employee.firstName} ${NEW_FORM_DATA.employee.lastName}` | ||
) | ||
.sibling('td') | ||
.nth(0) | ||
.find('a'); | ||
await t.click(applicationLink); | ||
|
||
// Start handling the application | ||
// // Start handling the application | ||
const buttonSelector = 'main button'; | ||
const handleButton = Selector(buttonSelector).withText( | ||
fi.review.actions.handle | ||
|
@@ -181,13 +158,15 @@ test('Fill form and submit', async (t: TestController) => { | |
await t.click(Selector('[name="application_consent_3"]')); | ||
|
||
// Validate form and submit | ||
const nextButton = Selector(buttonSelector).withText( | ||
fi.applications.actions.save | ||
const validationButton = Selector(buttonSelector).withText( | ||
fi.applications.actions.continue | ||
); | ||
await t.click(nextButton); | ||
await t.click(validationButton); | ||
|
||
const submitButton = Selector(buttonSelector).withText( | ||
fi.review.actions.handlingPanel | ||
); | ||
await t.expect(submitButton.visible).ok(); | ||
await t.typeText('#changeReason', 'Testing edit application'); | ||
|
||
const submitButton = Selector('[data-testid="confirm-ok"]'); | ||
await t.click(submitButton); | ||
|
||
await t.expect(editButton.visible).ok(); | ||
}); |
Oops, something went wrong.