From a4fd5d3e61e72bdd45bfc9e3688ef9cd2a4ff973 Mon Sep 17 00:00:00 2001 From: AndrejNagy <46596011+AndrejNagy@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:14:10 +0200 Subject: [PATCH] vypnutie odkladu (#784) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * vypnutie odkladu po 31.3. * put now as parameter into PostponeSection * Make button look in compliance with our UX standard * vypnutie odkladu po 31.3. * put now as parameter into PostponeSection * Make button look in compliance with our UX standard * Fix failing tests while month is 10-12 * fix tests logic based on their component logic * identity fix, comments * identity fix, comments --------- Co-authored-by: Andrej Nagy Co-authored-by: Michal Ormos Co-authored-by: Michal Ormos Co-authored-by: Marek Vigaš Co-authored-by: micorm --- cypress/e2e/postponePages.spec.ts | 163 ++++++++++++++++-------------- src/pages/index.tsx | 51 ++++++++-- 2 files changed, 128 insertions(+), 86 deletions(-) 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 }) => (
- +
    @@ -150,16 +150,12 @@ const TaxFormSection = ({ nextRoute, isDebug, isLive }) => { ) } -const PostponeSection = ({ nextPostponeRoute }) => ( +const PostponeSection = ({ nextPostponeRoute, now}) => ( <>

    {`Odklad daňového priznania za rok ${TAX_YEAR}`}

    -

    - {`Riadny termín pre podanie daňového priznania a zaplatenie dane je - 31.3.${TAX_YEAR + 1}`} -

    -

    Termín si viete predĺžiť:

    +
    • {`do 30.6.${ TAX_YEAR + 1 @@ -174,12 +170,51 @@ const PostponeSection = ({ nextPostponeRoute }) => (

      + + + +) +const PostponeText = ({ now }) => ( + <> + {(now.getMonth() > 2) && ( + <> +

      + {`Riadny termín pre podanie daňového priznania a zaplatenie dane bol do + 31.3.${TAX_YEAR + 1}`} +

      +

      Termín ste si mohli predĺžiť:

      + )} + {(now.getMonth() < 3) && ( + <> +

      + {`Riadny termín pre podanie daňového priznania a zaplatenie dane je + 31.3.${TAX_YEAR + 1}`} +

      +

      Termín si viete predĺžiť:

      + )} + +) + +const PostponeButton = ({ now }) => ( + <> + {(now.getMonth() > 2) && ( + <> + + )} + {(now.getMonth() < 3) && ( + <> - + )} )