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

Prijem z dohody #913

Merged
merged 19 commits into from
Nov 16, 2024
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
54 changes: 54 additions & 0 deletions __tests__/dohoda.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { validate } from '../src/pages/dohoda'
import { testValidation } from './utils/testValidation'

describe('dohoda', () => {
describe('#validate', () => {
testValidation(validate, [
{
input: { dohoda: undefined },
expected: ['dohoda'],
},
{ input: { dohoda: false }, expected: [] },
{
input: { dohoda: true },
expected: [
'uhrnPrijmovZoVsetkychDohod',
'uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody',
'uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody',
'uhrnPreddavkovNaDanDohody',
'udajeODanovomBonuseNaDietaDohody',
],
},
{
input: {
dohoda: true,
r029_poberal_dochodok: true,
uhrnPrijmovZoVsetkychDohod: 'a',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '-1',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '-1',
udajeODanovomBonuseNaDietaDohody: 'a',
uhrnPreddavkovNaDanDohody: '-1',
},
expected: [
'uhrnPrijmovZoVsetkychDohod',
'uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody',
'uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody',
'uhrnPreddavkovNaDanDohody',
'udajeODanovomBonuseNaDietaDohody',
],
},
{
input: {
dohoda: true,
r029_poberal_dochodok: true,
uhrnPrijmovZoVsetkychDohod: '10',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '20',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '20',
udajeODanovomBonuseNaDietaDohody: '30',
uhrnPreddavkovNaDanDohody: '40',
},
expected: [],
},
])
})
})
6 changes: 5 additions & 1 deletion __tests__/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('routes', () => {
homeRoute,
'/prijmy-a-vydavky',
'/zamestnanie',
'/dohoda',
'/partner',
'/deti',
'/dochodok',
Expand All @@ -33,6 +34,7 @@ describe('routes', () => {
homeRoute,
'/prijmy-a-vydavky',
'/zamestnanie',
'/dohoda',
'/partner',
'/deti',
'/dochodok',
Expand All @@ -55,6 +57,7 @@ describe('routes', () => {
homeRoute,
'/prijmy-a-vydavky',
'/zamestnanie',
'/dohoda',
'/partner',
'/deti',
'/dochodok',
Expand All @@ -78,6 +81,7 @@ describe('routes', () => {
homeRoute,
'/prijmy-a-vydavky',
'/zamestnanie',
'/dohoda',
'/partner',
'/deti',
'/dochodok',
Expand Down Expand Up @@ -170,7 +174,7 @@ describe('routes', () => {

it('should not redirect from route when form is filled out', () => {
validateRoute(
{ route: '/partner', replace } as any,
{ route: '/dohoda', replace } as any,
{} as TaxForm,
{ employed: false } as TaxFormUserInput,
{} as PostponeUserInput,
Expand Down
8 changes: 8 additions & 0 deletions __tests__/testCases/case202201Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const case202201Input: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '1084.26',
employed: true,

/** SECTION Dohoda */
uhrnPrijmovZoVsetkychDohod: '4420',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '850.60',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '230',
uhrnPreddavkovNaDanDohody: '0',
udajeODanovomBonuseNaDietaDohody: '0',
dohoda: true,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
zaplatene_prispevky_na_dochodok: '0',
Expand Down
10 changes: 9 additions & 1 deletion __tests__/testCases/case202202aInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const case202202aInput: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '0',
employed: false,

/** SECTION Dohoda */
uhrnPrijmovZoVsetkychDohod: '5500',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '1200',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '330',
uhrnPreddavkovNaDanDohody: '120',
udajeODanovomBonuseNaDietaDohody: '100',
dohoda: true,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
zaplatene_prispevky_na_dochodok: '0',
Expand Down Expand Up @@ -62,6 +70,6 @@ export const case202202aInput: E2eTestUserInput = {

expectNgoDonationValue: true,

percent2: '173,62',
percent2: '193,88',
percent3: '320,78',
}
10 changes: 9 additions & 1 deletion __tests__/testCases/case202202bInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const case202202bInput: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '0',
employed: false,

/** SECTION Dohoda */
uhrnPrijmovZoVsetkychDohod: '5500',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '1200',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '330',
uhrnPreddavkovNaDanDohody: '120',
udajeODanovomBonuseNaDietaDohody: '100',
dohoda: true,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
zaplatene_prispevky_na_dochodok: '0',
Expand Down Expand Up @@ -63,6 +71,6 @@ export const case202202bInput: E2eTestUserInput = {
expectNgoDonationValue: true,

/** SECTION Two Percent */
percent2: '178,62',
percent2: '194,53',
percent3: '321,72',
}
8 changes: 8 additions & 0 deletions __tests__/testCases/case202202cInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const case202202cInput: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '0',
employed: false,

/** SECTION Dohoda */
uhrnPrijmovZoVsetkychDohod: '0',
uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '0',
uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '0',
uhrnPreddavkovNaDanDohody: '0',
udajeODanovomBonuseNaDietaDohody: '0',
dohoda: false,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
zaplatene_prispevky_na_dochodok: '0',
Expand Down
1 change: 1 addition & 0 deletions __tests__/testCases/case202301Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const case202301Input: E2eTestUserInput = {
uhrnPreddavkovNaDan: '0',
udajeODanovomBonuseNaDieta: '0',
employed: false,
dohoda: false,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
Expand Down
1 change: 1 addition & 0 deletions __tests__/testCases/case202302Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const case202302Input: E2eTestUserInput = {
uhrnPreddavkovNaDan: '446.76',
udajeODanovomBonuseNaDieta: '0',
employed: true,
dohoda: false,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
Expand Down
1 change: 1 addition & 0 deletions __tests__/testCases/case202303Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const case202303Input: E2eTestUserInput = {
uhrnPreddavkovNaDan: '1434',
udajeODanovomBonuseNaDieta: '0',
employed: true,
dohoda: false,

/** SECTION Pension */
platil_prispevky_na_dochodok: false,
Expand Down
1 change: 1 addition & 0 deletions __tests__/testCases/prenajom202303Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export const prenajom202303Input: E2eTestUserInput = {
vydavkyZPrenajmu: '4325',
prenajomPrijemZPrilezitostnejCinnosti: true,
vyskaOslobodenia: '350',
dohoda: false,
}
1 change: 1 addition & 0 deletions __tests__/testCases/prenajom202304Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const prenajom202304Input: E2eTestUserInput = {
prenajomPrijemZPrilezitostnejCinnosti: false,
expectNgoDonationValue: true,
percent2: '7,57',
dohoda: false,
}
16 changes: 16 additions & 0 deletions cypress/e2e/executeCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ const executeTestCase = (testCase: string) => {

next()

/** SECTION Dohoda */
assertUrl('/dohoda')

if (input.dohoda) {
getInput('dohoda', '-yes').click()
typeToInput('uhrnPrijmovZoVsetkychDohod', input)
typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input)
typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input)
typeToInput('uhrnPreddavkovNaDanDohody', input)
typeToInput('udajeODanovomBonuseNaDietaDohody', input)
} else {
getInput('dohoda', '-no').click()
}

next()

/** SECTION Partner */
assertUrl('/partner')

Expand Down
64 changes: 64 additions & 0 deletions cypress/e2e/pagePercent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ describe('twoPercent page', () => {

next()

/** SECTION Dohoda */
assertUrl('/dohoda')

if (input.dohoda) {
getInput('dohoda', '-yes').click()
typeToInput('uhrnPrijmovZoVsetkychDohod', input)
typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input)
typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input)
typeToInput('uhrnPreddavkovNaDanDohody', input)
typeToInput('udajeODanovomBonuseNaDietaDohody', input)
} else {
getInput('dohoda', '-no').click()
}

next()

/** SECTION Partner */
if (input.r032_uplatnujem_na_partnera) {
getInput('r032_uplatnujem_na_partnera', '-yes').click()
Expand Down Expand Up @@ -253,6 +269,22 @@ describe('twoPercent page', () => {

next()

/** SECTION Dohoda */
assertUrl('/dohoda')

if (input.dohoda) {
getInput('dohoda', '-yes').click()
typeToInput('uhrnPrijmovZoVsetkychDohod', input)
typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input)
typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input)
typeToInput('uhrnPreddavkovNaDanDohody', input)
typeToInput('udajeODanovomBonuseNaDietaDohody', input)
} else {
getInput('dohoda', '-no').click()
}

next()

/** SECTION Partner */
if (input.r032_uplatnujem_na_partnera) {
getInput('r032_uplatnujem_na_partnera', '-yes').click()
Expand Down Expand Up @@ -428,6 +460,22 @@ describe('twoPercent page', () => {

next()

/** SECTION Dohoda */
assertUrl('/dohoda')

if (input.dohoda) {
getInput('dohoda', '-yes').click()
typeToInput('uhrnPrijmovZoVsetkychDohod', input)
typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input)
typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input)
typeToInput('uhrnPreddavkovNaDanDohody', input)
typeToInput('udajeODanovomBonuseNaDietaDohody', input)
} else {
getInput('dohoda', '-no').click()
}

next()

/** SECTION Partner */
if (input.r032_uplatnujem_na_partnera) {
getInput('r032_uplatnujem_na_partnera', '-yes').click()
Expand Down Expand Up @@ -540,6 +588,22 @@ describe('twoPercent page', () => {

next()

/** SECTION Dohoda */
assertUrl('/dohoda')

if (input.dohoda) {
getInput('dohoda', '-yes').click()
typeToInput('uhrnPrijmovZoVsetkychDohod', input)
typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input)
typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input)
typeToInput('uhrnPreddavkovNaDanDohody', input)
typeToInput('udajeODanovomBonuseNaDietaDohody', input)
} else {
getInput('dohoda', '-no').click()
}

next()

/** SECTION Partner */
if (input.r032_uplatnujem_na_partnera) {
getInput('r032_uplatnujem_na_partnera', '-yes').click()
Expand Down
18 changes: 14 additions & 4 deletions cypress/e2e/pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const navigateEligibleToChildrenPage = () => {
assertUrl('/zamestnanie')
skipPage()

assertUrl('/dohoda')
skipPage()

assertUrl('/partner')
skipPage()
}
Expand Down Expand Up @@ -153,7 +156,7 @@ describe('Employment page', () => {

// Should submit and next page should be parter
next()
assertUrl('/partner')
assertUrl('/dohoda')
})
it('should erase previous answers when answer is changed to "no"', () => {
cy.visit('/zamestnanie')
Expand All @@ -174,7 +177,7 @@ describe('Employment page', () => {
next()

// go back
assertUrl('/partner')
assertUrl('/dohoda')
cy.get('[data-test=back]').click()
assertUrl('/zamestnanie')

Expand Down Expand Up @@ -224,7 +227,7 @@ describe('Employment page', () => {
next()

// go back
assertUrl('/partner')
assertUrl('/dohoda')
cy.get('[data-test=back]').click()
assertUrl('/zamestnanie')

Expand All @@ -249,7 +252,7 @@ describe('Partner page', () => {

// Back button should work and be the correct page
cy.get('[data-test=back]').click()
assertUrl('/zamestnanie')
assertUrl('/dohoda')

// Go back to our page
cy.visit('/partner')
Expand Down Expand Up @@ -471,6 +474,9 @@ describe('Children page', () => {
})
next()

assertUrl('/dohoda')
skipPage()

assertUrl('/partner')
skipPage()

Expand Down Expand Up @@ -851,6 +857,9 @@ describe('IBAN page', () => {
assertUrl('/partner')
skipPage()

assertUrl('/partner')
skipPage()

assertUrl('/deti')
getInput('hasChildren', '-yes').click()

Expand Down Expand Up @@ -946,6 +955,7 @@ describe('Summary page', () => {
;[
'/prijmy-a-vydavky',
'/zamestnanie',
'/dohoda',
'/partner',
'/deti',
'/deti',
Expand Down
Loading
Loading