diff --git a/cypress/e2e/postponePages.spec.ts b/cypress/e2e/postponePages.spec.ts index a48255da..4dec6431 100644 --- a/cypress/e2e/postponePages.spec.ts +++ b/cypress/e2e/postponePages.spec.ts @@ -2,6 +2,9 @@ import { postponeHomeRoute, PostponeRoute, Route } from '../../src/lib/routes' import { foreignIncomeInput } from '../../__tests__/testCases/postpone/foreignIncomeInput' import { PostponeUserInput } from '../../src/types/PostponeUserInput' +const date = new Date +const month = date.getMonth() + 1; + function getInputPostpone( key: K, suffix = '', @@ -28,89 +31,93 @@ const next = () => { return cy.contains('Pokračovať').click() } -describe('/odklad/osobne-udaje page', () => { - beforeEach('Navigate to test page', () => { - cy.visit(postponeHomeRoute) - - cy.contains('Súhlasím a chcem odložiť daňové priznanie').click() - assertUrl('/odklad/prijmy-zo-zahranicia') - getInputPostpone('prijmy_zo_zahranicia', '-yes').click() - - next() - }) - it('Back and validation', () => { - assertUrl('/odklad/osobne-udaje') - - // Back button should work and be the correct page - cy.get('[data-test=back]').click() - assertUrl('/odklad/prijmy-zo-zahranicia') - - // Go back to our page - next() - - // Shows error, when presses next without interaction - next() - cy.get('[data-test=error]') - }) - it('with autoform', () => { - assertUrl('/odklad/osobne-udaje') - - /** With autoform */ - typeToInputPostpone('dic', foreignIncomeInput) - getInputPostpone('meno_priezvisko').type('Julius Renc') - - cy.contains('Július Renceš').click() - - getInputPostpone('meno_priezvisko').should('contain.value', 'Július Renceš') - getInputPostpone('ulica').should('contain.value', 'Benková Potôň') - getInputPostpone('cislo').should('contain.value', '343') - getInputPostpone('psc').should('contain.value', '930 36') - getInputPostpone('obec').should('contain.value', 'Horná Potôň') - cy.get(`[data-test="stat-select"]`).should('contain.value', 'Slovensko') +// button is not usable outside scope of first three months +// when postpone for tax report is availible +if (month >= 1 && month < 4) { + describe('/odklad/osobne-udaje page', () => { + beforeEach('Navigate to test page', () => { + cy.visit(postponeHomeRoute) + + cy.contains('Súhlasím a chcem odložiť daňové priznanie').click() + assertUrl('/odklad/prijmy-zo-zahranicia') + getInputPostpone('prijmy_zo_zahranicia', '-yes').click() + + next() + }) + it('Back and validation', () => { + assertUrl('/odklad/osobne-udaje') + + // Back button should work and be the correct page + cy.get('[data-test=back]').click() + assertUrl('/odklad/prijmy-zo-zahranicia') + + // Go back to our page + next() + + // Shows error, when presses next without interaction + next() + cy.get('[data-test=error]') + }) + it('with autoform', () => { + assertUrl('/odklad/osobne-udaje') + + /** With autoform */ + typeToInputPostpone('dic', foreignIncomeInput) + getInputPostpone('meno_priezvisko').type('Julius Renc') + + cy.contains('Július Renceš').click() + + getInputPostpone('meno_priezvisko').should('contain.value', 'Július Renceš') + getInputPostpone('ulica').should('contain.value', 'Benková Potôň') + getInputPostpone('cislo').should('contain.value', '343') + getInputPostpone('psc').should('contain.value', '930 36') + getInputPostpone('obec').should('contain.value', 'Horná Potôň') + cy.get(`[data-test="stat-select"]`).should('contain.value', 'Slovensko') + }) + + it('Manual entry', () => { + assertUrl('/odklad/osobne-udaje') + + typeToInputPostpone('dic', foreignIncomeInput) + typeToInputPostpone('meno', foreignIncomeInput) + typeToInputPostpone('priezvisko', foreignIncomeInput) + typeToInputPostpone('ulica', foreignIncomeInput) + typeToInputPostpone('cislo', foreignIncomeInput) + typeToInputPostpone('obec', foreignIncomeInput) + typeToInputPostpone('psc', foreignIncomeInput) + cy.get('[data-test="stat-select"]').select(foreignIncomeInput.stat) + }) + it('Errors', () => { + assertUrl('/odklad/osobne-udaje') + + getInputPostpone('dic').type('invalid') + + next() + cy.get('.govuk-error-summary') + }) }) - it('Manual entry', () => { - assertUrl('/odklad/osobne-udaje') - - typeToInputPostpone('dic', foreignIncomeInput) - typeToInputPostpone('meno', foreignIncomeInput) - typeToInputPostpone('priezvisko', foreignIncomeInput) - typeToInputPostpone('ulica', foreignIncomeInput) - typeToInputPostpone('cislo', foreignIncomeInput) - typeToInputPostpone('obec', foreignIncomeInput) - typeToInputPostpone('psc', foreignIncomeInput) - cy.get('[data-test="stat-select"]').select(foreignIncomeInput.stat) - }) - it('Errors', () => { - assertUrl('/odklad/osobne-udaje') + describe('/odklad/suhrn page', () => { + beforeEach('Navigate to test page', () => { + cy.visit(postponeHomeRoute) - getInputPostpone('dic').type('invalid') - - next() - cy.get('.govuk-error-summary') - }) -}) + cy.contains('Súhlasím a chcem odložiť daňové priznanie').click() + assertUrl('/odklad/prijmy-zo-zahranicia') + getInputPostpone('prijmy_zo_zahranicia', '-yes').click() -describe('/odklad/suhrn page', () => { - beforeEach('Navigate to test page', () => { - cy.visit(postponeHomeRoute) + next() - cy.contains('Súhlasím a chcem odložiť daňové priznanie').click() - assertUrl('/odklad/prijmy-zo-zahranicia') - getInputPostpone('prijmy_zo_zahranicia', '-yes').click() + getInputPostpone('meno_priezvisko').type('Julius Renc') + cy.contains('Július Renceš').click() - next() + next() + }) + it('Back', () => { + assertUrl('/odklad/suhrn') - getInputPostpone('meno_priezvisko').type('Julius Renc') - cy.contains('Július Renceš').click() - - next() - }) - it('Back', () => { - assertUrl('/odklad/suhrn') - - // Back button should work and be the correct page - cy.get('[data-test=back]').click() - assertUrl('/odklad/osobne-udaje') + // Back button should work and be the correct page + cy.get('[data-test=back]').click() + assertUrl('/odklad/osobne-udaje') + }) }) -}) +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f91088a2..58e0e2d9 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -37,7 +37,7 @@ const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive }) => (
- +