diff --git a/cypress/e2e/donor/certificate-provider.cy.js b/cypress/e2e/donor/certificate-provider.cy.js index 88ef7f78e4..dab975c06c 100644 --- a/cypress/e2e/donor/certificate-provider.cy.js +++ b/cypress/e2e/donor/certificate-provider.cy.js @@ -30,6 +30,13 @@ describe('Certificate provider task', () => { cy.get('#f-mobile').type(TestMobile); cy.contains('button', 'Save and continue').click(); + cy.url().should('contain', '/how-do-you-know-your-certificate-provider'); + cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); + + cy.contains('How do you know John Doe, your certificate provider?'); + cy.contains('label', 'Professionally').click(); + cy.contains('button', 'Save and continue').click(); + cy.url().should('contain', '/how-would-certificate-provider-prefer-to-carry-out-their-role'); cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); @@ -39,21 +46,11 @@ describe('Certificate provider task', () => { cy.url().should('contain', '/certificate-provider-address'); - cy.contains('label', 'Enter a new address').click(); - cy.contains('button', 'Continue').click(); AddressFormAssertions.assertCanAddAddressFromSelect() - cy.url().should('contain', '/how-do-you-know-your-certificate-provider'); + cy.url().should('contain', '/task-list'); cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); - cy.contains('How do you know John Doe, your certificate provider?'); - cy.contains('label', 'Professionally').click(); - cy.contains('button', 'Save and continue').click(); - - cy.url().should('contain', '/do-you-want-to-notify-people'); - cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); - - cy.visitLpa('/task-list') cy.contains('li', "Choose your certificate provider") .should('contain', 'Completed'); }); @@ -81,18 +78,6 @@ describe('Certificate provider task', () => { cy.get('#f-mobile').type(TestMobile); cy.contains('button', 'Save and continue').click(); - cy.url().should('contain', '/how-would-certificate-provider-prefer-to-carry-out-their-role'); - cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); - - cy.contains('label', 'Using paper forms').click(); - cy.contains('button', 'Save and continue').click() - - cy.url().should('contain', '/certificate-provider-address'); - - cy.contains('label', 'Enter a new address').click(); - cy.contains('button', 'Continue').click(); - AddressFormAssertions.assertCanAddAddressFromSelect() - cy.url().should('contain', '/how-do-you-know-your-certificate-provider'); cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); @@ -107,10 +92,22 @@ describe('Certificate provider task', () => { cy.contains('label', '2 years or more').click(); cy.contains('button', 'Save and continue').click(); - cy.url().should('contain', '/do-you-want-to-notify-people'); + cy.url().should('contain', '/how-would-certificate-provider-prefer-to-carry-out-their-role'); + + cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); + cy.contains('label', 'Using paper forms').click(); + + cy.contains('button', 'Save and continue').click() + + cy.url().should('contain', '/certificate-provider-address'); + cy.contains('label', 'Enter a new address').click(); + cy.contains('button', 'Continue').click(); + + AddressFormAssertions.assertCanAddAddressFromSelect() + + cy.url().should('contain', '/task-list'); cy.checkA11yApp({ rules: { 'aria-allowed-attr': { enabled: false } } }); - cy.visitLpa('/task-list') cy.contains('li', "Choose your certificate provider") .should('contain', 'Completed'); }); @@ -258,7 +255,7 @@ describe('Certificate provider task', () => { cy.contains('There is also an attorney called Jessie Jones.'); cy.contains('button', 'Save and continue').click(); - cy.url().should('contain', '/how-would-certificate-provider-prefer-to-carry-out-their-role'); + cy.url().should('contain', '/how-do-you-know-your-certificate-provider'); }); it('warns when lastname shared with other donor', () => { @@ -274,6 +271,6 @@ describe('Certificate provider task', () => { cy.contains('Your certificate provider’s last name is the same as yours or very similar'); cy.contains('button', 'Save and continue').click(); - cy.url().should('contain', '/how-would-certificate-provider-prefer-to-carry-out-their-role'); + cy.url().should('contain', '/how-do-you-know-your-certificate-provider'); }); }); diff --git a/go.sum b/go.sum index b57b90085e..48747abbde 100644 --- a/go.sum +++ b/go.sum @@ -7,105 +7,57 @@ github.com/MicahParks/keyfunc v1.9.0/go.mod h1:IdnCilugA0O/99dW+/MkvlyrsX8+L8+x9 github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= -github.com/aws/aws-sdk-go-v2 v1.21.2 h1:+LXZ0sgo8quN9UOKXXzAWRT3FWd4NxeXWOZom9pE7GA= -github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2 v1.22.1 h1:sjnni/AuoTXxHitsIdT0FwmqUuNUuHtufcVDErVFT9U= github.com/aws/aws-sdk-go-v2 v1.22.1/go.mod h1:Kd0OJtkW3Q0M0lUWGszapWjEvrXDzRW+D21JNsroB+c= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.14 h1:Sc82v7tDQ/vdU1WtuSyzZ1I7y/68j//HJ6uozND1IDs= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.14/go.mod h1:9NCTOURS8OpxvoAVHq79LK81/zC78hfRWFn+aL0SPcY= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0 h1:hHgLiIrTRtddC0AKcJr5s7i/hLgcpTt+q/FKxf1Zayk= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0/go.mod h1:w4I/v3NOWgD+qvs1NPEwhd++1h3XPHFaVxasfY6HlYQ= -github.com/aws/aws-sdk-go-v2/config v1.19.1 h1:oe3vqcGftyk40icfLymhhhNysAwk0NfiwkDi2GTPMXs= -github.com/aws/aws-sdk-go-v2/config v1.19.1/go.mod h1:ZwDUgFnQgsazQTnWfeLWk5GjeqTQTL8lMkoE1UXzxdE= github.com/aws/aws-sdk-go-v2/config v1.22.0 h1:9Mm99OalzZRz0ab5fpodMoHBApHS6pqRNp3M9NmzvDg= github.com/aws/aws-sdk-go-v2/config v1.22.0/go.mod h1:2eWgw5lps8fKI7LZVTrRTYP6HE6k/uEFUuTSHfXwqP0= -github.com/aws/aws-sdk-go-v2/credentials v1.13.43 h1:LU8vo40zBlo3R7bAvBVy/ku4nxGEyZe9N8MqAeFTzF8= -github.com/aws/aws-sdk-go-v2/credentials v1.13.43/go.mod h1:zWJBz1Yf1ZtX5NGax9ZdNjhhI4rgjfgsyk6vTY1yfVg= github.com/aws/aws-sdk-go-v2/credentials v1.15.1 h1:hmf6lAm9hk7uLCfapZn/jL05lm6Uwdbn1B0fgjyuf4M= github.com/aws/aws-sdk-go-v2/credentials v1.15.1/go.mod h1:QTcHga3ZbQOneJuxmGBOCxiClxmp+TlvmjFexAnJ790= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.43 h1:jlR1Rwjb3z5d1p0sqhNcuCaqdp73H+1O/X8Lc2kBDrY= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.43/go.mod h1:X1HGecFASboCkBt1GJRM4a/FDYYogu9AciUoXVsbr4U= github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.0 h1:nKmTvugKsuO2bHkL0vkpHEFtRoT/ijOVx0VdP+LLjgw= github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.0/go.mod h1:vxJ/EEKuP9CCSG4lEViyU9i5gr2M0X5OIJqTcX/oxuU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 h1:PIktER+hwIG286DqXyvVENjgLTAwGgoeriLDD5C+YlQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13/go.mod h1:f/Ib/qYjhV2/qdsf79H3QP/eRE4AkVyEf6sk7XfZ1tg= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2 h1:gIeH4+o1MN/caGBWjoGQTUTIu94xD6fI5B2+TcwBf70= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2/go.mod h1:wLyMIo/zPOhQhPXTddpfdkSleyigtFi8iMnC+2m/SK4= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 h1:nFBQlGtkbPzp/NjZLuFxRqmT91rLJkgvsEQs68h962Y= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ= github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1 h1:fi1ga6WysOyYb5PAf3Exd6B5GiSNpnZim4h1rhlBqx0= github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1/go.mod h1:V5CY8wNurvPUibTi9mwqUqpiFZ5LnioKWIFUDtIzdI8= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 h1:JRVhO25+r3ar2mKGP7E0LDl8K9/G36gjlqca5iQbaqc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1 h1:ZpaV/j48RlPc4AmOZuPv22pJliXjXq8/reL63YzyFnw= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1/go.mod h1:R8aXraabD2e3qv1csxM14/X9WF4wFMIY0kH4YEtYD5M= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 h1:hze8YsjSh8Wl1rYa1CJpRmXP21BvOBuc76YhW0HsuQ4= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45/go.mod h1:lD5M20o09/LCuQ2mE62Mb/iSdSlCNuj6H5ci7tW7OsE= github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0 h1:DqOQvIfmGkXZUVJnl9VRk0AnxyS59tCtX9k1Pyss4Ak= github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0/go.mod h1:VV/Kbw9Mg1GWJOT9WK+oTL3cWZiXtapnNvDSRqTZLsg= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.6 h1:wmGLw2i8ZTlHLw7a9ULGfQbuccw8uIiNr6sol5bFzc8= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.6/go.mod h1:Q0Hq2X/NuL7z8b1Dww8rmOFl+jzusKEcyvkKspwdpyc= github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.1 h1:vzYLDkwTw4CY0vUk84MeSufRf8XIsC/GsoIFXD60sTg= github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.1/go.mod h1:ToBFBnjeGR2ruMx8IWp/y7vSK3Irj5/oPwifruiqoOM= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.23.0 h1:xmSAn14nM6IdHyuWO/bsrAagOQtnqzuUCLxdVmj9nhg= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.23.0/go.mod h1:1HkLh8vaL4obF95fne7ZOu7sxomS/+vkBt3/+gqqwE4= github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0 h1:wAG9NailFhGhg8Ngg2YeCtzGmFWc63SYqJKdvN5ZMkE= github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0/go.mod h1:ByrosnNlEq6xkA0d+FwB4f0HH/5KWCcgBqVxAt+Rsps= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.7 h1:WCeS9WZbIqEKCbgIkrHB5jw/9mO2QMYTLPF8wee3v4Y= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.7/go.mod h1:uT1paW42RVCVEoAEbWKu98gEI0GMBWUsT/H+pI4ODJQ= github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.17.0 h1:iTGBKvqZNU9SsQCzRiK8f0u9kVtdG4K1Q68A97JRn6w= github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.17.0/go.mod h1:EabdnPA1OVcrolKX/hyMSNvJv8MBCZtlAlncsg/b/rA= -github.com/aws/aws-sdk-go-v2/service/eventbridge v1.22.2 h1:OyuAwr4t1emvQdH+M6BqZR/0a67SUOm6glJ2ot6NQE4= -github.com/aws/aws-sdk-go-v2/service/eventbridge v1.22.2/go.mod h1:z29eBmJY+MYzdT1gbSdcjXgJ5CMVw3wKcclrxcitLqw= github.com/aws/aws-sdk-go-v2/service/eventbridge v1.24.0 h1:602uhl5EMsyPGOvufUOSuRbLYT5RI1mFwWOI/OKUMXc= github.com/aws/aws-sdk-go-v2/service/eventbridge v1.24.0/go.mod h1:KiYs9sDklqLLv/tq+fae/8mLiJj4b7mV8Uqn1Sn3aZA= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.15 h1:7R8uRYyXzdD71KWVCL78lJZltah6VVznXBazvKjfH58= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.15/go.mod h1:26SQUPcTNgV1Tapwdt4a1rOsYRsnBsJHLMPoxK2b0d8= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 h1:CJxo7ZBbaIzmXfV3hjcx36n9V87gJsIUPJflwqEHl3Q= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0/go.mod h1:yjVfjuY4nD1EW9i387Kau+I6V5cBA5YnC/mWNopjZrI= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.38 h1:skaFGzv+3kA+v2BPKhuekeb1Hbb105+44r8ASC+q5SE= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.38/go.mod h1:epIZoRSSbRIwLPJU5F+OldHhwZPBdpDeQkRdCeY3+00= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.1 h1:15FUCJzAP9Y25nioTqTrGlZmhOtthaXBWlt4pS+d3Xo= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.1/go.mod h1:5655NW53Un6l7JzkI6AA3rZvf0m532cSnLThA1fVXcA= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.37 h1:4LoizcvPT9A0tiAFhepxn0bGZXkzvN0pG0epydY3Pno= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.37/go.mod h1:7xBUZyP6LeLc+5Ym9PG7atqw4sR28sBtYcHETik+bPE= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1 h1:aY45T0Xk+xHHrQPlQrp8IhrgN7k4SL5VF2UXhsmI2rs= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1/go.mod h1:5E/dXkj2ljMIAvuYaFuYwitKJg6ULwsDbUr3g8izVB0= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 h1:WWZA/I2K4ptBS1kg0kV1JbBtG/umed0vwHRrmcr9z7k= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37/go.mod h1:vBmDnwWXWxNPFRMmG2m/3MKOe+xEcMDo1tanpaWCcck= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1 h1:2OXw3ppu1XsB6rqKEMV4tnecTjIY3PRV2U6IP6KPJQo= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1/go.mod h1:FZB4AdakIqW/yERVdGJA6Z9jraax1beXfhBBnK2wwR8= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.6 h1:9ulSU5ClouoPIYhDQdg9tpl83d5Yb91PXTKK+17q+ow= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.6/go.mod h1:lnc2taBsR9nTlz9meD+lhFZZ9EWY712QHrRflWpTcOA= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.1 h1:dnl0klXYX9EKpzZbWlH5LJL+YTcEZcJEMPFFr/rAHUQ= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.1/go.mod h1:Mfk/9Joso4tCQYzM4q4HRUIqwln8lnIIMB/OE8Zebdc= -github.com/aws/aws-sdk-go-v2/service/s3 v1.40.2 h1:Ll5/YVCOzRB+gxPqs2uD0R7/MyATC0w85626glSKmp4= -github.com/aws/aws-sdk-go-v2/service/s3 v1.40.2/go.mod h1:Zjfqt7KhQK+PO1bbOsFNzKgaq7TcxzmEoDWN8lM0qzQ= github.com/aws/aws-sdk-go-v2/service/s3 v1.42.0 h1:u0YoSrxjr3Lm+IqIlRAV+4YTFwkXjyB9db9CfUFge2w= github.com/aws/aws-sdk-go-v2/service/s3 v1.42.0/go.mod h1:98EIdRu+BNsdqITsXfy+57TZfwlUQC9aDn9a9qoo90U= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.6 h1:y3n83jEM6EuawrD5HZCh3eMj9RsfxniVLcXlyFMNITM= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.6/go.mod h1:A108ijf0IFtqhYApU+Gia80aPSAUfi9dItm+h5fWGJE= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.0 h1:PXSCgeF51ApT3k+fduqw7IaCxICt1nozWV1iPz7TyxU= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.0/go.mod h1:bpDXZjRbNT5gb9pa2jJlSUvBkfNwfG3OWgGqFYY73kA= github.com/aws/aws-sdk-go-v2/service/sqs v1.24.5 h1:RyDpTOMEJO6ycxw1vU/6s0KLFaH3M0z/z9gXHSndPTk= github.com/aws/aws-sdk-go-v2/service/sqs v1.24.5/go.mod h1:RZBu4jmYz3Nikzpu/VuVvRnTEJ5a+kf36WT2fcl5Q+Q= -github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 h1:JuPGc7IkOP4AaqcZSIcyqLpFSqBWK32rM9+a1g6u73k= -github.com/aws/aws-sdk-go-v2/service/sso v1.15.2/go.mod h1:gsL4keucRCgW+xA85ALBpRFfdSLH4kHOVSnLMSuBECo= github.com/aws/aws-sdk-go-v2/service/sso v1.17.0 h1:I/Oh3IxGPfHXiGnwM54TD6hNr/8TlUrBXAtTyGhR+zw= github.com/aws/aws-sdk-go-v2/service/sso v1.17.0/go.mod h1:H6NCMvDBqA+CvIaXzaSqM6LWtzv9BzZrqBOqz+PzRF8= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 h1:HFiiRkf1SdaAmV3/BHOFZ9DjFynPHj8G/UIO1lQS+fk= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3/go.mod h1:a7bHA82fyUXOm+ZSWKU6PIoBxrjSprdLoM8xPYvzYVg= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0 h1:irbXQkfVYIRaewYSXcu4yVk0m2T+JzZd0dkop7FjmO0= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0/go.mod h1:4wPNCkM22+oRe71oydP66K50ojDUC33XutSMi2pEF/M= -github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 h1:0BkLfgeDjfZnZ+MhB3ONb01u9pwFYTCZVhlsSSBvlbU= -github.com/aws/aws-sdk-go-v2/service/sts v1.23.2/go.mod h1:Eows6e1uQEsc4ZaHANmsPRzAKcVDrcmjjWiih2+HUUQ= github.com/aws/aws-sdk-go-v2/service/sts v1.25.0 h1:sYIFy8tm1xQwRvVQ4CRuBGXKIg9sHNuG6+3UAQuoujk= github.com/aws/aws-sdk-go-v2/service/sts v1.25.0/go.mod h1:S/LOQUeYDfJeJpFCIJDMjy7dwL4aA33HUdVi+i7uH8k= github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= -github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.16.0 h1:gJZEH/Fqh+RsvlJ1Zt4tVAtV6bKkp3cC+R6FCZMNzik= github.com/aws/smithy-go v1.16.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= github.com/brunoscheufler/aws-ecs-metadata-go v0.0.0-20220812150832-b6b31c6eeeaf h1:WCnJxXZXx9c8gwz598wvdqmu+YTzB9wx2X1OovK3Le8= @@ -122,9 +74,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= @@ -181,8 +130,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= @@ -301,8 +248,6 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -342,8 +287,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/internal/actor/certificate_provider.go b/internal/actor/certificate_provider.go index 8901f3dd01..27391d93a7 100644 --- a/internal/actor/certificate_provider.go +++ b/internal/actor/certificate_provider.go @@ -22,6 +22,15 @@ const ( Online // online ) +//go:generate enumerator -type CertificateProviderRelationshipLength -linecomment -empty +type CertificateProviderRelationshipLength uint8 + +const ( + LessThanTwoYears CertificateProviderRelationshipLength = iota + 1 // lt-2-years + GreaterThanEqualToTwoYears // gte-2-years + RelationshipLengthUnknown // unknown +) + // CertificateProvider contains details about the certificate provider, provided by the applicant type CertificateProvider struct { // First names of the certificate provider @@ -41,7 +50,7 @@ type CertificateProvider struct { // The certificate provider's relationship to the applicant Relationship CertificateProviderRelationship // Amount of time Relationship has been in place if Personally - RelationshipLength string + RelationshipLength CertificateProviderRelationshipLength } func (c CertificateProvider) FullName() string { diff --git a/internal/actor/enum_certificateproviderrelationshiplength.go b/internal/actor/enum_certificateproviderrelationshiplength.go new file mode 100644 index 0000000000..7ae16f035a --- /dev/null +++ b/internal/actor/enum_certificateproviderrelationshiplength.go @@ -0,0 +1,69 @@ +// Code generated by "enumerator -type CertificateProviderRelationshipLength -linecomment -empty"; DO NOT EDIT. +package actor + +import ( + "fmt" + "strconv" +) + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[LessThanTwoYears-1] + _ = x[GreaterThanEqualToTwoYears-2] + _ = x[RelationshipLengthUnknown-3] +} + +const _CertificateProviderRelationshipLength_name = "lt-2-yearsgte-2-yearsunknown" + +var _CertificateProviderRelationshipLength_index = [...]uint8{0, 10, 21, 28} + +func (i CertificateProviderRelationshipLength) String() string { + i -= 1 + if i >= CertificateProviderRelationshipLength(len(_CertificateProviderRelationshipLength_index)-1) { + return "CertificateProviderRelationshipLength(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _CertificateProviderRelationshipLength_name[_CertificateProviderRelationshipLength_index[i]:_CertificateProviderRelationshipLength_index[i+1]] +} + +func (i CertificateProviderRelationshipLength) IsLessThanTwoYears() bool { + return i == LessThanTwoYears +} + +func (i CertificateProviderRelationshipLength) IsGreaterThanEqualToTwoYears() bool { + return i == GreaterThanEqualToTwoYears +} + +func (i CertificateProviderRelationshipLength) IsRelationshipLengthUnknown() bool { + return i == RelationshipLengthUnknown +} + +func ParseCertificateProviderRelationshipLength(s string) (CertificateProviderRelationshipLength, error) { + switch s { + case "lt-2-years": + return LessThanTwoYears, nil + case "gte-2-years": + return GreaterThanEqualToTwoYears, nil + case "unknown": + return RelationshipLengthUnknown, nil + default: + return CertificateProviderRelationshipLength(0), fmt.Errorf("invalid CertificateProviderRelationshipLength '%s'", s) + } +} + +type CertificateProviderRelationshipLengthOptions struct { + LessThanTwoYears CertificateProviderRelationshipLength + GreaterThanEqualToTwoYears CertificateProviderRelationshipLength + RelationshipLengthUnknown CertificateProviderRelationshipLength +} + +var CertificateProviderRelationshipLengthValues = CertificateProviderRelationshipLengthOptions{ + LessThanTwoYears: LessThanTwoYears, + GreaterThanEqualToTwoYears: GreaterThanEqualToTwoYears, + RelationshipLengthUnknown: RelationshipLengthUnknown, +} + +func (i CertificateProviderRelationshipLength) Empty() bool { + return i == CertificateProviderRelationshipLength(0) +} diff --git a/internal/page/donor/certificate_provider_address.go b/internal/page/donor/certificate_provider_address.go index f9d719a553..453d146ac4 100644 --- a/internal/page/donor/certificate_provider_address.go +++ b/internal/page/donor/certificate_provider_address.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -11,16 +12,16 @@ import ( func CertificateProviderAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error { - data := &chooseAddressData{ - App: appData, - ActorLabel: "certificateProvider", - FullName: lpa.CertificateProvider.FullName(), - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "certificateProvider" + data.FullName = lpa.CertificateProvider.FullName() if lpa.CertificateProvider.Address.Line1 != "" { data.Form.Action = "manual" data.Form.Address = &lpa.CertificateProvider.Address + } else if lpa.CertificateProvider.Relationship.IsProfessionally() { + data.Form.Action = "postcode" + data.overrideProfessionalCertificateProviderKeys() } if r.Method == http.MethodPost { @@ -29,6 +30,7 @@ func CertificateProviderAddress(logger Logger, tmpl template.Template, addressCl setAddress := func(address place.Address) error { lpa.CertificateProvider.Address = *data.Form.Address + lpa.Tasks.CertificateProvider = actor.TaskCompleted return donorStore.Put(r.Context(), lpa) } @@ -40,7 +42,7 @@ func CertificateProviderAddress(logger Logger, tmpl template.Template, addressCl return err } - return appData.Redirect(w, r, lpa, page.Paths.HowDoYouKnowYourCertificateProvider.Format(lpa.ID)) + return appData.Redirect(w, r, lpa, page.Paths.TaskList.Format(lpa.ID)) } case "postcode-select": @@ -66,7 +68,7 @@ func CertificateProviderAddress(logger Logger, tmpl template.Template, addressCl return err } - return appData.Redirect(w, r, lpa, page.Paths.HowDoYouKnowYourCertificateProvider.Format(lpa.ID)) + return appData.Redirect(w, r, lpa, page.Paths.TaskList.Format(lpa.ID)) } else { data.Addresses = lpa.ActorAddresses() } diff --git a/internal/page/donor/certificate_provider_address_test.go b/internal/page/donor/certificate_provider_address_test.go index d0681a4f0a..6caed9c4bc 100644 --- a/internal/page/donor/certificate_provider_address_test.go +++ b/internal/page/donor/certificate_provider_address_test.go @@ -33,6 +33,42 @@ func TestGetCertificateProviderAddress(t *testing.T) { Form: &form.AddressForm{}, FullName: "John Smith", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, + }). + Return(nil) + + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &page.Lpa{CertificateProvider: certificateProvider}) + resp := w.Result() + + assert.Nil(t, err) + assert.Equal(t, http.StatusOK, resp.StatusCode) +} + +func TestGetCertificateProviderAddressWhenProfessionalCertificateProvider(t *testing.T) { + w := httptest.NewRecorder() + r, _ := http.NewRequest(http.MethodGet, "/", nil) + + certificateProvider := actor.CertificateProvider{ + FirstNames: "John", + LastName: "Smith", + Address: place.Address{}, + Relationship: actor.Professionally, + } + + template := newMockTemplate(t) + template. + On("Execute", w, &chooseAddressData{ + App: testAppData, + Form: &form.AddressForm{Action: "postcode"}, + FullName: "John Smith", + ActorLabel: "certificateProvider", + TitleKeys: titleKeys{ + Manual: "personsWorkAddress", + PostcodeSelectAndPostcodeLookup: "selectPersonsWorkAddress", + Postcode: "whatIsPersonsWorkPostcode", + ReuseAndReuseSelect: "selectAnAddressForPerson", + ReuseOrNew: "addPersonsAddress", + }, }). Return(nil) @@ -61,6 +97,7 @@ func TestGetCertificateProviderAddressFromStore(t *testing.T) { }, FullName: " ", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, }). Return(nil) @@ -89,6 +126,7 @@ func TestGetCertificateProviderAddressManual(t *testing.T) { }, FullName: " ", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, }). Return(nil) @@ -110,6 +148,7 @@ func TestGetCertificateProviderAddressWhenTemplateErrors(t *testing.T) { Form: &form.AddressForm{}, FullName: " ", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -139,6 +178,7 @@ func TestPostCertificateProviderAddressManual(t *testing.T) { On("Put", r.Context(), &page.Lpa{ ID: "lpa-id", CertificateProvider: actor.CertificateProvider{Address: testAddress}, + Tasks: page.Tasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) @@ -147,7 +187,7 @@ func TestPostCertificateProviderAddressManual(t *testing.T) { assert.Nil(t, err) assert.Equal(t, http.StatusFound, resp.StatusCode) - assert.Equal(t, page.Paths.HowDoYouKnowYourCertificateProvider.Format("lpa-id"), resp.Header.Get("Location")) + assert.Equal(t, page.Paths.TaskList.Format("lpa-id"), resp.Header.Get("Location")) } func TestPostCertificateProviderAddressManualWhenStoreErrors(t *testing.T) { @@ -168,6 +208,7 @@ func TestPostCertificateProviderAddressManualWhenStoreErrors(t *testing.T) { donorStore. On("Put", r.Context(), &page.Lpa{ CertificateProvider: actor.CertificateProvider{Address: testAddress}, + Tasks: page.Tasks{CertificateProvider: actor.TaskCompleted}, }). Return(expectedError) @@ -198,6 +239,7 @@ func TestPostCertificateProviderAddressManualFromStore(t *testing.T) { FirstNames: "John", Address: testAddress, }, + Tasks: page.Tasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) @@ -212,7 +254,7 @@ func TestPostCertificateProviderAddressManualFromStore(t *testing.T) { assert.Nil(t, err) assert.Equal(t, http.StatusFound, resp.StatusCode) - assert.Equal(t, page.Paths.HowDoYouKnowYourCertificateProvider.Format("lpa-id"), resp.Header.Get("Location")) + assert.Equal(t, page.Paths.TaskList.Format("lpa-id"), resp.Header.Get("Location")) } func TestPostCertificateProviderAddressManualWhenValidationError(t *testing.T) { @@ -245,6 +287,7 @@ func TestPostCertificateProviderAddressManualWhenValidationError(t *testing.T) { FullName: " ", ActorLabel: "certificateProvider", Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -277,6 +320,7 @@ func TestPostCertificateProviderPostcodeSelect(t *testing.T) { }, FullName: " ", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, }). Return(nil) @@ -318,6 +362,7 @@ func TestPostCertificateProviderPostcodeSelectWhenValidationError(t *testing.T) ActorLabel: "certificateProvider", Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -358,6 +403,7 @@ func TestPostCertificateProviderPostcodeLookup(t *testing.T) { FullName: " ", ActorLabel: "certificateProvider", Addresses: addresses, + TitleKeys: testTitleKeys, }). Return(nil) @@ -399,6 +445,7 @@ func TestPostCertificateProviderPostcodeLookupError(t *testing.T) { ActorLabel: "certificateProvider", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -445,6 +492,7 @@ func TestPostCertificateProviderPostcodeLookupInvalidPostcodeError(t *testing.T) ActorLabel: "certificateProvider", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -485,6 +533,7 @@ func TestPostCertificateProviderPostcodeLookupValidPostcodeNoAddresses(t *testin ActorLabel: "certificateProvider", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noAddressesFound"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -514,6 +563,7 @@ func TestPostCertificateProviderPostcodeLookupWhenValidationError(t *testing.T) FullName: " ", ActorLabel: "certificateProvider", Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -542,6 +592,7 @@ func TestPostCertificateProviderAddressReuse(t *testing.T) { FullName: " ", ActorLabel: "certificateProvider", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -578,6 +629,7 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { Country: "GB", }, }, + Tasks: page.Tasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) @@ -586,7 +638,7 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { assert.Nil(t, err) assert.Equal(t, http.StatusFound, resp.StatusCode) - assert.Equal(t, page.Paths.HowDoYouKnowYourCertificateProvider.Format("lpa-id"), resp.Header.Get("Location")) + assert.Equal(t, page.Paths.TaskList.Format("lpa-id"), resp.Header.Get("Location")) } func TestPostCertificateProviderAddressReuseSelectWhenValidationError(t *testing.T) { @@ -609,6 +661,7 @@ func TestPostCertificateProviderAddressReuseSelectWhenValidationError(t *testing Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), FullName: " ", ActorLabel: "certificateProvider", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/certificate_provider_details.go b/internal/page/donor/certificate_provider_details.go index 1b8488ad01..f05e496e12 100644 --- a/internal/page/donor/certificate_provider_details.go +++ b/internal/page/donor/certificate_provider_details.go @@ -64,11 +64,13 @@ func CertificateProviderDetails(tmpl template.Template, donorStore DonorStore) H lpa.CertificateProvider.Mobile = data.Form.Mobile } + lpa.Tasks.CertificateProvider = actor.TaskInProgress + if err := donorStore.Put(r.Context(), lpa); err != nil { return err } - return appData.Redirect(w, r, lpa, page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole.Format(lpa.ID)) + return appData.Redirect(w, r, lpa, page.Paths.HowDoYouKnowYourCertificateProvider.Format(lpa.ID)) } } diff --git a/internal/page/donor/certificate_provider_details_test.go b/internal/page/donor/certificate_provider_details_test.go index 54d7877571..1a3505ee3b 100644 --- a/internal/page/donor/certificate_provider_details_test.go +++ b/internal/page/donor/certificate_provider_details_test.go @@ -181,6 +181,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { LastName: "Doe", }, CertificateProvider: tc.certificateProviderDetails, + Tasks: page.Tasks{CertificateProvider: actor.TaskInProgress}, }). Return(nil) @@ -195,7 +196,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { assert.Nil(t, err) assert.Equal(t, http.StatusFound, resp.StatusCode) - assert.Equal(t, page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole.Format("lpa-id"), resp.Header.Get("Location")) + assert.Equal(t, page.Paths.HowDoYouKnowYourCertificateProvider.Format("lpa-id"), resp.Header.Get("Location")) }) } } diff --git a/internal/page/donor/choose_address.go b/internal/page/donor/choose_address.go index ddb9272685..06abbe964b 100644 --- a/internal/page/donor/choose_address.go +++ b/internal/page/donor/choose_address.go @@ -10,6 +10,20 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) +func newChooseAddressData(appData page.AppData) *chooseAddressData { + return &chooseAddressData{ + App: appData, + Form: &form.AddressForm{}, + TitleKeys: titleKeys{ + Manual: "personsAddress", + Postcode: "whatIsPersonsPostcode", + PostcodeSelectAndPostcodeLookup: "selectAnAddressForPerson", + ReuseAndReuseSelect: "selectAnAddressForPerson", + ReuseOrNew: "addPersonsAddress", + }, + } +} + type chooseAddressData struct { App page.AppData Errors validation.List @@ -19,6 +33,21 @@ type chooseAddressData struct { CanSkip bool Addresses []place.Address Form *form.AddressForm + TitleKeys titleKeys +} + +type titleKeys struct { + Manual string + PostcodeSelectAndPostcodeLookup string + Postcode string + ReuseAndReuseSelect string + ReuseOrNew string +} + +func (d *chooseAddressData) overrideProfessionalCertificateProviderKeys() { + d.TitleKeys.Manual = "personsWorkAddress" + d.TitleKeys.Postcode = "whatIsPersonsWorkPostcode" + d.TitleKeys.PostcodeSelectAndPostcodeLookup = "selectPersonsWorkAddress" } func lookupAddress(ctx context.Context, logger Logger, addressClient AddressClient, data *chooseAddressData, your bool) { diff --git a/internal/page/donor/choose_address_test.go b/internal/page/donor/choose_address_test.go new file mode 100644 index 0000000000..ea0b627326 --- /dev/null +++ b/internal/page/donor/choose_address_test.go @@ -0,0 +1,41 @@ +package donor + +import ( + "testing" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/form" + "github.com/stretchr/testify/assert" +) + +var testTitleKeys = titleKeys{ + Manual: "personsAddress", + Postcode: "whatIsPersonsPostcode", + PostcodeSelectAndPostcodeLookup: "selectAnAddressForPerson", + ReuseAndReuseSelect: "selectAnAddressForPerson", + ReuseOrNew: "addPersonsAddress", +} + +func TestNewChooseAddressData(t *testing.T) { + assert.Equal(t, &chooseAddressData{ + Form: &form.AddressForm{}, + TitleKeys: testTitleKeys, + App: testAppData, + }, newChooseAddressData(testAppData)) +} + +func TestOverrideProfessionalCertificateProviderKeys(t *testing.T) { + data := newChooseAddressData(testAppData) + data.overrideProfessionalCertificateProviderKeys() + + assert.Equal(t, &chooseAddressData{ + App: testAppData, + Form: &form.AddressForm{}, + TitleKeys: titleKeys{ + Manual: "personsWorkAddress", + Postcode: "whatIsPersonsWorkPostcode", + PostcodeSelectAndPostcodeLookup: "selectPersonsWorkAddress", + ReuseAndReuseSelect: "selectAnAddressForPerson", + ReuseOrNew: "addPersonsAddress", + }, + }, data) +} diff --git a/internal/page/donor/choose_attorneys_address.go b/internal/page/donor/choose_attorneys_address.go index 322bb74662..56339e2dee 100644 --- a/internal/page/donor/choose_attorneys_address.go +++ b/internal/page/donor/choose_attorneys_address.go @@ -18,14 +18,11 @@ func ChooseAttorneysAddress(logger Logger, tmpl template.Template, addressClient return appData.Redirect(w, r, lpa, page.Paths.ChooseAttorneys.Format(lpa.ID)) } - data := &chooseAddressData{ - App: appData, - ActorLabel: "attorney", - FullName: attorney.FullName(), - ID: attorney.ID, - CanSkip: true, - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "attorney" + data.FullName = attorney.FullName() + data.ID = attorney.ID + data.CanSkip = true if attorney.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/choose_attorneys_address_test.go b/internal/page/donor/choose_attorneys_address_test.go index f5ee7f4d43..45fd1377ca 100644 --- a/internal/page/donor/choose_attorneys_address_test.go +++ b/internal/page/donor/choose_attorneys_address_test.go @@ -29,6 +29,7 @@ func TestGetChooseAttorneysAddress(t *testing.T) { FullName: "John Smith", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -67,6 +68,7 @@ func TestGetChooseAttorneysAddressFromStore(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -95,6 +97,7 @@ func TestGetChooseAttorneysAddressManual(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -120,6 +123,7 @@ func TestGetChooseAttorneysAddressWhenTemplateErrors(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -350,6 +354,7 @@ func TestPostChooseAttorneysAddressManualWhenValidationError(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -386,6 +391,7 @@ func TestPostChooseAttorneysAddressPostcodeSelect(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -431,6 +437,7 @@ func TestPostChooseAttorneysAddressPostcodeSelectWhenValidationError(t *testing. FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -475,6 +482,7 @@ func TestPostChooseAttorneysPostcodeLookup(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -520,6 +528,7 @@ func TestPostChooseAttorneysPostcodeLookupError(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -570,6 +579,7 @@ func TestPostChooseAttorneysPostcodeLookupInvalidPostcodeError(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -612,6 +622,7 @@ func TestPostChooseAttorneysPostcodeLookupValidPostcodeNoAddresses(t *testing.T) FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -645,6 +656,7 @@ func TestPostChooseAttorneysPostcodeLookupWhenValidationError(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -678,6 +690,7 @@ func TestPostChooseAttorneysAddressReuse(t *testing.T) { CanSkip: true, ActorLabel: "attorney", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -755,6 +768,7 @@ func TestPostChooseAttorneysAddressReuseSelectWhenValidationError(t *testing.T) FullName: " ", CanSkip: true, ActorLabel: "attorney", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/choose_people_to_notify_address.go b/internal/page/donor/choose_people_to_notify_address.go index bedab6adb9..534c7cc31b 100644 --- a/internal/page/donor/choose_people_to_notify_address.go +++ b/internal/page/donor/choose_people_to_notify_address.go @@ -19,13 +19,10 @@ func ChoosePeopleToNotifyAddress(logger Logger, tmpl template.Template, addressC return appData.Redirect(w, r, lpa, page.Paths.ChoosePeopleToNotify.Format(lpa.ID)) } - data := &chooseAddressData{ - App: appData, - ActorLabel: "personToNotify", - FullName: personToNotify.FullName(), - ID: personToNotify.ID, - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "personToNotify" + data.FullName = personToNotify.FullName() + data.ID = personToNotify.ID if personToNotify.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/choose_people_to_notify_address_test.go b/internal/page/donor/choose_people_to_notify_address_test.go index 08381ddfbf..fda5bd3728 100644 --- a/internal/page/donor/choose_people_to_notify_address_test.go +++ b/internal/page/donor/choose_people_to_notify_address_test.go @@ -35,6 +35,7 @@ func TestGetChoosePeopleToNotifyAddress(t *testing.T) { ID: "123", FullName: "John Smith", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(nil) @@ -60,6 +61,7 @@ func TestGetChoosePeopleToNotifyAddressFromStore(t *testing.T) { ID: "123", FullName: " ", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(nil) @@ -87,6 +89,7 @@ func TestGetChoosePeopleToNotifyAddressManual(t *testing.T) { ID: "123", FullName: " ", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(nil) @@ -114,6 +117,7 @@ func TestGetChoosePeopleToNotifyAddressWhenTemplateErrors(t *testing.T) { ID: "123", FullName: " ", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -254,6 +258,7 @@ func TestPostChoosePeopleToNotifyPostcodeSelect(t *testing.T) { ID: "123", FullName: "John ", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(nil) @@ -302,6 +307,7 @@ func TestPostChoosePeopleToNotifyPostcodeSelectWhenValidationError(t *testing.T) ActorLabel: "personToNotify", Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -343,6 +349,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookup(t *testing.T) { FullName: "John ", ActorLabel: "personToNotify", Addresses: addresses, + TitleKeys: testTitleKeys, }). Return(nil) @@ -385,6 +392,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupError(t *testing.T) { ActorLabel: "personToNotify", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -432,6 +440,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupInvalidPostcodeError(t *testing.T ActorLabel: "personToNotify", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -473,6 +482,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupValidPostcodeNoAddresses(t *testi ActorLabel: "personToNotify", Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noAddressesFound"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -508,6 +518,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupWhenValidationError(t *testing.T) FullName: " ", ActorLabel: "personToNotify", Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -538,6 +549,7 @@ func TestPostChoosePeopleToNotifyAddressReuse(t *testing.T) { FullName: " ", ActorLabel: "personToNotify", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -609,6 +621,7 @@ func TestPostChoosePeopleToNotifyAddressReuseSelectWhenValidationError(t *testin ID: "123", FullName: " ", ActorLabel: "personToNotify", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/choose_replacement_attorneys_address.go b/internal/page/donor/choose_replacement_attorneys_address.go index 67501449b8..c58b62cbf3 100644 --- a/internal/page/donor/choose_replacement_attorneys_address.go +++ b/internal/page/donor/choose_replacement_attorneys_address.go @@ -14,14 +14,11 @@ func ChooseReplacementAttorneysAddress(logger Logger, tmpl template.Template, ad attorneyId := r.FormValue("id") attorney, _ := lpa.ReplacementAttorneys.Get(attorneyId) - data := &chooseAddressData{ - App: appData, - ActorLabel: "replacementAttorney", - FullName: attorney.FullName(), - ID: attorney.ID, - CanSkip: true, - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "replacementAttorney" + data.FullName = attorney.FullName() + data.ID = attorney.ID + data.CanSkip = true if attorney.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/choose_replacement_attorneys_address_test.go b/internal/page/donor/choose_replacement_attorneys_address_test.go index e3d1df94dc..5affa3b7c8 100644 --- a/internal/page/donor/choose_replacement_attorneys_address_test.go +++ b/internal/page/donor/choose_replacement_attorneys_address_test.go @@ -36,6 +36,7 @@ func TestGetChooseReplacementAttorneysAddress(t *testing.T) { FullName: "John Smith", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -67,6 +68,7 @@ func TestGetChooseReplacementAttorneysAddressFromStore(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -98,6 +100,7 @@ func TestGetChooseReplacementAttorneysAddressManual(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -126,6 +129,7 @@ func TestGetChooseReplacementAttorneysAddressWhenTemplateErrors(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -311,6 +315,7 @@ func TestPostChooseReplacementAttorneysAddressManualWhenValidationError(t *testi FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -345,6 +350,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelect(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -388,6 +394,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelectWhenValidationError(t *test FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -430,6 +437,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookup(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -473,6 +481,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupError(t *testing.T) { FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -521,6 +530,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupInvalidPostcodeError(t *tes FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -565,6 +575,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupValidPostcodeNoAddresses(t FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -598,6 +609,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupWhenValidationError(t *test FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) @@ -629,6 +641,7 @@ func TestPostChooseReplacementAttorneysAddressReuse(t *testing.T) { CanSkip: true, ActorLabel: "replacementAttorney", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -706,6 +719,7 @@ func TestPostChooseReplacementAttorneysAddressReuseSelectWhenValidationError(t * FullName: " ", CanSkip: true, ActorLabel: "replacementAttorney", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/enter_replacement_trust_corporation_address.go b/internal/page/donor/enter_replacement_trust_corporation_address.go index 413b0c75b9..ee6aa53eba 100644 --- a/internal/page/donor/enter_replacement_trust_corporation_address.go +++ b/internal/page/donor/enter_replacement_trust_corporation_address.go @@ -13,11 +13,8 @@ func EnterReplacementTrustCorporationAddress(logger Logger, tmpl template.Templa return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error { trustCorporation := lpa.ReplacementAttorneys.TrustCorporation - data := &chooseAddressData{ - App: appData, - ActorLabel: "theTrustCorporation", - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "theTrustCorporation" if trustCorporation.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/enter_replacement_trust_corporation_address_test.go b/internal/page/donor/enter_replacement_trust_corporation_address_test.go index 6a60ed489f..48dd610ca8 100644 --- a/internal/page/donor/enter_replacement_trust_corporation_address_test.go +++ b/internal/page/donor/enter_replacement_trust_corporation_address_test.go @@ -26,6 +26,7 @@ func TestGetEnterReplacementTrustCorporationAddress(t *testing.T) { App: testAppData, Form: &form.AddressForm{}, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -51,6 +52,7 @@ func TestGetEnterReplacementTrustCorporationAddressManual(t *testing.T) { Address: &place.Address{}, }, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -73,6 +75,7 @@ func TestGetEnterReplacementTrustCorporationAddressWhenTemplateErrors(t *testing App: testAppData, Form: &form.AddressForm{}, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -220,6 +223,7 @@ func TestPostEnterReplacementTrustCorporationAddressManualWhenValidationError(t }, Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -253,6 +257,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelect(t *testing.T) Address: &testAddress, }, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -295,6 +300,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelectWhenValidation Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -336,6 +342,7 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookup(t *testing.T) { }, Addresses: addresses, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -378,6 +385,7 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookupError(t *testing.T) { Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -425,6 +433,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupInvalidPostcod Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -464,6 +473,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupValidPostcodeN Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noAddressesFound"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -494,6 +504,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupWhenValidation }, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -524,6 +535,7 @@ func TestPostEnterReplacementTrustCorporationAddressReuse(t *testing.T) { }, ActorLabel: "theTrustCorporation", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -600,6 +612,7 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelectWhenValidationErr Addresses: []place.Address{{Line1: "donor lane"}}, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/enter_trust_corporation_address.go b/internal/page/donor/enter_trust_corporation_address.go index f8e1d432f5..75ab6fd162 100644 --- a/internal/page/donor/enter_trust_corporation_address.go +++ b/internal/page/donor/enter_trust_corporation_address.go @@ -13,11 +13,8 @@ func EnterTrustCorporationAddress(logger Logger, tmpl template.Template, address return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error { trustCorporation := lpa.Attorneys.TrustCorporation - data := &chooseAddressData{ - App: appData, - ActorLabel: "theTrustCorporation", - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "theTrustCorporation" if trustCorporation.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/enter_trust_corporation_address_test.go b/internal/page/donor/enter_trust_corporation_address_test.go index 26bc84c9b2..f3532ba218 100644 --- a/internal/page/donor/enter_trust_corporation_address_test.go +++ b/internal/page/donor/enter_trust_corporation_address_test.go @@ -26,6 +26,7 @@ func TestGetEnterTrustCorporationAddress(t *testing.T) { App: testAppData, Form: &form.AddressForm{}, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -51,6 +52,7 @@ func TestGetEnterTrustCorporationAddressManual(t *testing.T) { Address: &place.Address{}, }, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -73,6 +75,7 @@ func TestGetEnterTrustCorporationAddressWhenTemplateErrors(t *testing.T) { App: testAppData, Form: &form.AddressForm{}, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -220,6 +223,7 @@ func TestPostEnterTrustCorporationAddressManualWhenValidationError(t *testing.T) }, Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -253,6 +257,7 @@ func TestPostEnterTrustCorporationAddressPostcodeSelect(t *testing.T) { Address: &testAddress, }, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -295,6 +300,7 @@ func TestPostEnterTrustCorporationAddressPostcodeSelectWhenValidationError(t *te Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -336,6 +342,7 @@ func TestPostEnterTrustCorporationPostcodeLookup(t *testing.T) { }, Addresses: addresses, ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -378,6 +385,7 @@ func TestPostEnterTrustCorporationPostcodeLookupError(t *testing.T) { Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -425,6 +433,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupInvalidPostcodeError(t *t Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -464,6 +473,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupValidPostcodeNoAddresses( Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noAddressesFound"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -494,6 +504,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupWhenValidationError(t *te }, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) @@ -524,6 +535,7 @@ func TestPostEnterTrustCorporationAddressReuse(t *testing.T) { }, ActorLabel: "theTrustCorporation", Addresses: []place.Address{{Line1: "donor lane"}}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -600,6 +612,7 @@ func TestPostEnterTrustCorporationAddressReuseSelectWhenValidationError(t *testi Addresses: []place.Address{{Line1: "donor lane"}}, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), ActorLabel: "theTrustCorporation", + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/how_do_you_know_your_certificate_provider.go b/internal/page/donor/how_do_you_know_your_certificate_provider.go index e132cbb82b..b5019e9f0b 100644 --- a/internal/page/donor/how_do_you_know_your_certificate_provider.go +++ b/internal/page/donor/how_do_you_know_your_certificate_provider.go @@ -6,6 +6,7 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -33,30 +34,26 @@ func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore Dono data.Errors = data.Form.Validate() if data.Errors.None() { - lpa.CertificateProvider.Relationship = data.Form.How - - requireLength := false - if lpa.CertificateProvider.Relationship.IsPersonally() { - requireLength = true + if data.Form.How.IsProfessionally() && lpa.CertificateProvider.Relationship.IsPersonally() { + lpa.CertificateProvider.RelationshipLength = actor.RelationshipLengthUnknown } - if requireLength { - // TODO: should stay as Completed if editing and not changing the answer here + if !lpa.CertificateProvider.Relationship.Empty() && data.Form.How != lpa.CertificateProvider.Relationship { lpa.Tasks.CertificateProvider = actor.TaskInProgress - } else { - lpa.CertificateProvider.RelationshipLength = "" - lpa.Tasks.CertificateProvider = actor.TaskCompleted + lpa.CertificateProvider.Address = place.Address{} } + lpa.CertificateProvider.Relationship = data.Form.How + if err := donorStore.Put(r.Context(), lpa); err != nil { return err } - if requireLength { + if lpa.CertificateProvider.Relationship.IsPersonally() { return appData.Redirect(w, r, lpa, page.Paths.HowLongHaveYouKnownCertificateProvider.Format(lpa.ID)) } - return appData.Redirect(w, r, lpa, page.Paths.DoYouWantToNotifyPeople.Format(lpa.ID)) + return appData.Redirect(w, r, lpa, page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole.Format(lpa.ID)) } } diff --git a/internal/page/donor/how_do_you_know_your_certificate_provider_test.go b/internal/page/donor/how_do_you_know_your_certificate_provider_test.go index d0cb7c30b5..2971a54f29 100644 --- a/internal/page/donor/how_do_you_know_your_certificate_provider_test.go +++ b/internal/page/donor/how_do_you_know_your_certificate_provider_test.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -81,7 +82,6 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { testCases := map[string]struct { form url.Values certificateProviderDetails actor.CertificateProvider - taskState actor.TaskState redirect page.LpaPath }{ "professionally": { @@ -90,8 +90,7 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { FirstNames: "John", Relationship: actor.Professionally, }, - taskState: actor.TaskCompleted, - redirect: page.Paths.DoYouWantToNotifyPeople, + redirect: page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole, }, "personally": { form: url.Values{"how": {actor.Personally.String()}}, @@ -99,8 +98,7 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { FirstNames: "John", Relationship: actor.Personally, }, - taskState: actor.TaskInProgress, - redirect: page.Paths.HowLongHaveYouKnownCertificateProvider, + redirect: page.Paths.HowLongHaveYouKnownCertificateProvider, }, } @@ -116,9 +114,8 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { ID: "lpa-id", CertificateProvider: tc.certificateProviderDetails, Tasks: page.Tasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - CertificateProvider: tc.taskState, + YourDetails: actor.TaskCompleted, + ChooseAttorneys: actor.TaskCompleted, }, }). Return(nil) @@ -140,6 +137,79 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { } } +func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *testing.T) { + testCases := map[string]struct { + form url.Values + existingCertificateProviderDetails actor.CertificateProvider + updatedCertificateProviderDetails actor.CertificateProvider + redirect page.LpaPath + taskState actor.TaskState + }{ + "personally to professionally": { + form: url.Values{"how": {actor.Professionally.String()}}, + existingCertificateProviderDetails: actor.CertificateProvider{ + RelationshipLength: actor.GreaterThanEqualToTwoYears, + Relationship: actor.Personally, + Address: testAddress, + }, + updatedCertificateProviderDetails: actor.CertificateProvider{ + RelationshipLength: actor.RelationshipLengthUnknown, + Relationship: actor.Professionally, + Address: place.Address{}, + }, + redirect: page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole, + }, + "professionally to personally": { + form: url.Values{"how": {actor.Personally.String()}}, + existingCertificateProviderDetails: actor.CertificateProvider{ + Relationship: actor.Professionally, + Address: testAddress, + }, + updatedCertificateProviderDetails: actor.CertificateProvider{ + Relationship: actor.Personally, + Address: place.Address{}, + }, + redirect: page.Paths.HowLongHaveYouKnownCertificateProvider, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + w := httptest.NewRecorder() + r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(tc.form.Encode())) + r.Header.Add("Content-Type", page.FormUrlEncoded) + + donorStore := newMockDonorStore(t) + donorStore. + On("Put", r.Context(), &page.Lpa{ + ID: "lpa-id", + CertificateProvider: tc.updatedCertificateProviderDetails, + Tasks: page.Tasks{ + YourDetails: actor.TaskCompleted, + ChooseAttorneys: actor.TaskCompleted, + CertificateProvider: actor.TaskInProgress, + }, + }). + Return(nil) + + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &page.Lpa{ + ID: "lpa-id", + CertificateProvider: tc.existingCertificateProviderDetails, + Tasks: page.Tasks{ + YourDetails: actor.TaskCompleted, + ChooseAttorneys: actor.TaskCompleted, + CertificateProvider: actor.TaskCompleted, + }, + }) + resp := w.Result() + + assert.Nil(t, err) + assert.Equal(t, http.StatusFound, resp.StatusCode) + assert.Equal(t, tc.redirect.Format("lpa-id"), resp.Header.Get("Location")) + }) + } +} + func TestPostHowDoYouKnowYourCertificateProviderWhenStoreErrors(t *testing.T) { form := url.Values{ "how": {actor.Personally.String()}, diff --git a/internal/page/donor/how_long_have_you_known_certificate_provider.go b/internal/page/donor/how_long_have_you_known_certificate_provider.go index c967c00ea3..df6b784509 100644 --- a/internal/page/donor/how_long_have_you_known_certificate_provider.go +++ b/internal/page/donor/how_long_have_you_known_certificate_provider.go @@ -13,7 +13,8 @@ type howLongHaveYouKnownCertificateProviderData struct { App page.AppData Errors validation.List CertificateProvider actor.CertificateProvider - HowLong string + RelationshipLength actor.CertificateProviderRelationshipLength + Options actor.CertificateProviderRelationshipLengthOptions } func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { @@ -21,7 +22,8 @@ func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore D data := &howLongHaveYouKnownCertificateProviderData{ App: appData, CertificateProvider: lpa.CertificateProvider, - HowLong: lpa.CertificateProvider.RelationshipLength, + RelationshipLength: lpa.CertificateProvider.RelationshipLength, + Options: actor.CertificateProviderRelationshipLengthValues, } if r.Method == http.MethodPost { @@ -29,17 +31,16 @@ func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore D data.Errors = form.Validate() if data.Errors.None() { - if form.HowLong == "lt-2-years" { + if form.RelationshipLength == actor.LessThanTwoYears { return appData.Redirect(w, r, lpa, page.Paths.ChooseNewCertificateProvider.Format(lpa.ID)) } - lpa.Tasks.CertificateProvider = actor.TaskCompleted - lpa.CertificateProvider.RelationshipLength = form.HowLong + lpa.CertificateProvider.RelationshipLength = form.RelationshipLength if err := donorStore.Put(r.Context(), lpa); err != nil { return err } - return appData.Redirect(w, r, lpa, page.Paths.DoYouWantToNotifyPeople.Format(lpa.ID)) + return appData.Redirect(w, r, lpa, page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole.Format(lpa.ID)) } } @@ -48,20 +49,24 @@ func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore D } type howLongHaveYouKnownCertificateProviderForm struct { - HowLong string + RelationshipLength actor.CertificateProviderRelationshipLength + Error error } func readHowLongHaveYouKnownCertificateProviderForm(r *http.Request) *howLongHaveYouKnownCertificateProviderForm { + relationshipLength, err := actor.ParseCertificateProviderRelationshipLength(page.PostFormString(r, "relationship-length")) + return &howLongHaveYouKnownCertificateProviderForm{ - HowLong: page.PostFormString(r, "how-long"), + RelationshipLength: relationshipLength, + Error: err, } } func (f *howLongHaveYouKnownCertificateProviderForm) Validate() validation.List { var errors validation.List - errors.String("how-long", "howLongYouHaveKnownCertificateProvider", f.HowLong, - validation.Select("gte-2-years", "lt-2-years")) + errors.Error("relationship-length", "howLongYouHaveKnownCertificateProvider", f.Error, + validation.Selected()) return errors } diff --git a/internal/page/donor/how_long_have_you_known_certificate_provider_test.go b/internal/page/donor/how_long_have_you_known_certificate_provider_test.go index 29fd54a277..a6d40f3dc9 100644 --- a/internal/page/donor/how_long_have_you_known_certificate_provider_test.go +++ b/internal/page/donor/how_long_have_you_known_certificate_provider_test.go @@ -23,7 +23,8 @@ func TestGetHowLongHaveYouKnownCertificateProvider(t *testing.T) { template := newMockTemplate(t) template. On("Execute", w, &howLongHaveYouKnownCertificateProviderData{ - App: testAppData, + App: testAppData, + Options: actor.CertificateProviderRelationshipLengthValues, }). Return(nil) @@ -38,14 +39,15 @@ func TestGetHowLongHaveYouKnownCertificateProviderFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{RelationshipLength: "gte-2-years"} + certificateProvider := actor.CertificateProvider{RelationshipLength: actor.GreaterThanEqualToTwoYears} template := newMockTemplate(t) template. On("Execute", w, &howLongHaveYouKnownCertificateProviderData{ App: testAppData, CertificateProvider: certificateProvider, - HowLong: "gte-2-years", + RelationshipLength: actor.GreaterThanEqualToTwoYears, + Options: actor.CertificateProviderRelationshipLengthValues, }). Return(nil) @@ -63,7 +65,8 @@ func TestGetHowLongHaveYouKnownCertificateProviderWhenTemplateErrors(t *testing. template := newMockTemplate(t) template. On("Execute", w, &howLongHaveYouKnownCertificateProviderData{ - App: testAppData, + App: testAppData, + Options: actor.CertificateProviderRelationshipLengthValues, }). Return(expectedError) @@ -76,7 +79,7 @@ func TestGetHowLongHaveYouKnownCertificateProviderWhenTemplateErrors(t *testing. func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) { form := url.Values{ - "how-long": {"gte-2-years"}, + "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, } w := httptest.NewRecorder() @@ -89,8 +92,8 @@ func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) ID: "lpa-id", Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")}}}, AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - CertificateProvider: actor.CertificateProvider{RelationshipLength: "gte-2-years"}, - Tasks: page.Tasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, CertificateProvider: actor.TaskCompleted}, + CertificateProvider: actor.CertificateProvider{RelationshipLength: actor.GreaterThanEqualToTwoYears}, + Tasks: page.Tasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }). Return(nil) @@ -104,12 +107,12 @@ func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) assert.Nil(t, err) assert.Equal(t, http.StatusFound, resp.StatusCode) - assert.Equal(t, page.Paths.DoYouWantToNotifyPeople.Format("lpa-id"), resp.Header.Get("Location")) + assert.Equal(t, page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole.Format("lpa-id"), resp.Header.Get("Location")) } func TestPostHowLongHaveYouKnownCertificateProviderLessThan2Years(t *testing.T) { form := url.Values{ - "how-long": {"lt-2-years"}, + "relationship-length": {"lt-2-years"}, } w := httptest.NewRecorder() @@ -126,7 +129,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderLessThan2Years(t *testing.T) func TestPostHowLongHaveYouKnownCertificateProviderWhenStoreErrors(t *testing.T) { form := url.Values{ - "how-long": {"gte-2-years"}, + "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, } w := httptest.NewRecorder() @@ -151,8 +154,9 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenValidationErrors(t *testi template := newMockTemplate(t) template. On("Execute", w, &howLongHaveYouKnownCertificateProviderData{ - App: testAppData, - Errors: validation.With("how-long", validation.SelectError{Label: "howLongYouHaveKnownCertificateProvider"}), + App: testAppData, + Errors: validation.With("relationship-length", validation.SelectError{Label: "howLongYouHaveKnownCertificateProvider"}), + Options: actor.CertificateProviderRelationshipLengthValues, }). Return(nil) @@ -165,7 +169,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenValidationErrors(t *testi func TestReadHowLongHaveYouKnownCertificateProviderForm(t *testing.T) { form := url.Values{ - "how-long": {"gte-2-years"}, + "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -173,7 +177,7 @@ func TestReadHowLongHaveYouKnownCertificateProviderForm(t *testing.T) { result := readHowLongHaveYouKnownCertificateProviderForm(r) - assert.Equal(t, "gte-2-years", result.HowLong) + assert.Equal(t, actor.GreaterThanEqualToTwoYears, result.RelationshipLength) } func TestHowLongHaveYouKnownCertificateProviderFormValidate(t *testing.T) { @@ -181,20 +185,16 @@ func TestHowLongHaveYouKnownCertificateProviderFormValidate(t *testing.T) { form *howLongHaveYouKnownCertificateProviderForm errors validation.List }{ - "gte-2-years": { + "valid": { form: &howLongHaveYouKnownCertificateProviderForm{ - HowLong: "gte-2-years", + RelationshipLength: actor.GreaterThanEqualToTwoYears, }, }, - "missing": { - form: &howLongHaveYouKnownCertificateProviderForm{}, - errors: validation.With("how-long", validation.SelectError{Label: "howLongYouHaveKnownCertificateProvider"}), - }, "invalid": { form: &howLongHaveYouKnownCertificateProviderForm{ - HowLong: "what", + Error: expectedError, }, - errors: validation.With("how-long", validation.SelectError{Label: "howLongYouHaveKnownCertificateProvider"}), + errors: validation.With("relationship-length", validation.SelectError{Label: "howLongYouHaveKnownCertificateProvider"}), }, } diff --git a/internal/page/donor/your_address.go b/internal/page/donor/your_address.go index feef28c2e1..033d9d9c7e 100644 --- a/internal/page/donor/your_address.go +++ b/internal/page/donor/your_address.go @@ -11,10 +11,7 @@ import ( func YourAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error { - data := &chooseAddressData{ - App: appData, - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) if lpa.Donor.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/your_address_test.go b/internal/page/donor/your_address_test.go index 3948accd56..f8d27cdccf 100644 --- a/internal/page/donor/your_address_test.go +++ b/internal/page/donor/your_address_test.go @@ -23,8 +23,9 @@ func TestGetYourAddress(t *testing.T) { template := newMockTemplate(t) template. On("Execute", w, &chooseAddressData{ - App: testAppData, - Form: &form.AddressForm{}, + App: testAppData, + Form: &form.AddressForm{}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -49,6 +50,7 @@ func TestGetYourAddressFromStore(t *testing.T) { Action: "manual", Address: &address, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -75,6 +77,7 @@ func TestGetYourAddressManual(t *testing.T) { Action: "manual", Address: &place.Address{}, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -92,8 +95,9 @@ func TestGetYourAddressWhenTemplateErrors(t *testing.T) { template := newMockTemplate(t) template. On("Execute", w, &chooseAddressData{ - App: testAppData, - Form: &form.AddressForm{}, + App: testAppData, + Form: &form.AddressForm{}, + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -273,7 +277,8 @@ func TestPostYourAddressManualWhenValidationError(t *testing.T) { Country: "GB", }, }, - Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1OfYourAddress"}), + Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1OfYourAddress"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -311,6 +316,7 @@ func TestPostYourAddressSelect(t *testing.T) { LookupPostcode: "NG1", Address: expectedAddress, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -350,6 +356,7 @@ func TestPostYourAddressSelectWhenValidationError(t *testing.T) { }, Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "yourAddressFromTheList"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -388,6 +395,7 @@ func TestPostYourAddressLookup(t *testing.T) { LookupPostcode: "NG1", }, Addresses: addresses, + TitleKeys: testTitleKeys, }). Return(nil) @@ -427,6 +435,7 @@ func TestPostYourAddressLookupError(t *testing.T) { }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -471,6 +480,7 @@ func TestPostYourAddressInvalidPostcodeError(t *testing.T) { }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -509,6 +519,7 @@ func TestPostYourAddressValidPostcodeNoAddresses(t *testing.T) { }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noYourAddressesFound"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -535,7 +546,8 @@ func TestPostYourAddressLookupWhenValidationError(t *testing.T) { Form: &form.AddressForm{ Action: "postcode", }, - Errors: validation.With("lookup-postcode", validation.EnterError{Label: "yourPostcode"}), + Errors: validation.With("lookup-postcode", validation.EnterError{Label: "yourPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/donor/your_independent_witness_address.go b/internal/page/donor/your_independent_witness_address.go index 9344325f75..3f1412eabd 100644 --- a/internal/page/donor/your_independent_witness_address.go +++ b/internal/page/donor/your_independent_witness_address.go @@ -12,12 +12,9 @@ import ( func YourIndependentWitnessAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error { - data := &chooseAddressData{ - App: appData, - ActorLabel: "independentWitness", - FullName: lpa.IndependentWitness.FullName(), - Form: &form.AddressForm{}, - } + data := newChooseAddressData(appData) + data.ActorLabel = "independentWitness" + data.FullName = lpa.IndependentWitness.FullName() if lpa.IndependentWitness.Address.Line1 != "" { data.Form.Action = "manual" diff --git a/internal/page/donor/your_independent_witness_address_test.go b/internal/page/donor/your_independent_witness_address_test.go index 278f2e475e..08d41cdc8d 100644 --- a/internal/page/donor/your_independent_witness_address_test.go +++ b/internal/page/donor/your_independent_witness_address_test.go @@ -27,6 +27,7 @@ func TestGetYourIndependentWitnessAddress(t *testing.T) { ActorLabel: "independentWitness", FullName: "John Smith", Form: &form.AddressForm{}, + TitleKeys: testTitleKeys, }). Return(nil) @@ -58,6 +59,7 @@ func TestGetYourIndependentWitnessAddressFromStore(t *testing.T) { Action: "manual", Address: &address, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -86,6 +88,7 @@ func TestGetYourIndependentWitnessAddressManual(t *testing.T) { Action: "manual", Address: &place.Address{}, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -107,6 +110,7 @@ func TestGetYourIndependentWitnessAddressWhenTemplateErrors(t *testing.T) { ActorLabel: "independentWitness", FullName: " ", Form: &form.AddressForm{}, + TitleKeys: testTitleKeys, }). Return(expectedError) @@ -247,7 +251,8 @@ func TestPostYourIndependentWitnessAddressManualWhenValidationError(t *testing.T Country: "GB", }, }, - Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1"}), + Errors: validation.With("address-line-1", validation.EnterError{Label: "addressLine1"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -287,6 +292,7 @@ func TestPostYourIndependentWitnessAddressSelect(t *testing.T) { LookupPostcode: "NG1", Address: expectedAddress, }, + TitleKeys: testTitleKeys, }). Return(nil) @@ -328,6 +334,7 @@ func TestPostYourIndependentWitnessAddressSelectWhenValidationError(t *testing.T }, Addresses: addresses, Errors: validation.With("select-address", validation.SelectError{Label: "anAddressFromTheList"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -368,6 +375,7 @@ func TestPostYourIndependentWitnessAddressLookup(t *testing.T) { LookupPostcode: "NG1", }, Addresses: addresses, + TitleKeys: testTitleKeys, }). Return(nil) @@ -409,6 +417,7 @@ func TestPostYourIndependentWitnessAddressLookupError(t *testing.T) { }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "couldNotLookupPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -455,6 +464,7 @@ func TestPostYourIndependentWitnessAddressInvalidPostcodeError(t *testing.T) { }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.EnterError{Label: "invalidPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -495,6 +505,7 @@ func TestPostYourIndependentWitnessAddressValidPostcodeNoAddresses(t *testing.T) }, Addresses: []place.Address{}, Errors: validation.With("lookup-postcode", validation.CustomError{Label: "noAddressesFound"}), + TitleKeys: testTitleKeys, }). Return(nil) @@ -523,7 +534,8 @@ func TestPostYourIndependentWitnessAddressLookupWhenValidationError(t *testing.T Form: &form.AddressForm{ Action: "postcode", }, - Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), + Errors: validation.With("lookup-postcode", validation.EnterError{Label: "aPostcode"}), + TitleKeys: testTitleKeys, }). Return(nil) diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index cbd2f4f095..90ff4bcf0d 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -113,7 +113,7 @@ func makeCertificateProvider() actor.CertificateProvider { Email: testEmail, Mobile: testMobile, Relationship: actor.Personally, - RelationshipLength: "gte-2-years", + RelationshipLength: actor.GreaterThanEqualToTwoYears, CarryOutBy: actor.Online, Address: place.Address{ Line1: "5 RICHMOND PLACE", diff --git a/lang/cy.json b/lang/cy.json index c5dc3aaebc..d15ce9799f 100644 --- a/lang/cy.json +++ b/lang/cy.json @@ -269,6 +269,7 @@ "donor": "Rhoddwr", "name": "Enw", "address": "Cyfeiriad", + "workAddress": "Welsh", "certificateProvider": "Darparwr tystysgrif", "certificateProviderMobile": "Welsh", "attorneys": "Atwrneiod", @@ -611,8 +612,11 @@ "useAnAddressYouAlreadyEntered": "Defnyddiwch gyfeiriad rydych chi eisoes wedi’i roi", "enterNewAddress": "Rhowch gyfeiriad newydd", "whatIsPersonsPostcode": "Beth yw cod post {{.FullNamePossessive}}?", + "whatIsPersonsWorkPostcode": "Welsh {{.FullNamePossessive}} Welsh", "selectAnAddressForPerson": "Dewiswch gyfeiriad ar gyfer {{.FullName}}", + "selectPersonsWorkAddress": "Welsh {{.FullNamePossessive}} Welsh", "personsAddress": "Cyfeiriad {{.FullName}}", + "personsWorkAddress": "{{.FullNamePossessive}} Welsh", "personToNotify": "Welsh", "thisIsAnImportantDecision": "Welsh", "lifeSustainingTreatmentContent": "
Welsh
Welsh
Welsh
", diff --git a/lang/en.json b/lang/en.json index ebef8af383..f4ddd0811f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -250,6 +250,7 @@ "donor": "Donor", "name": "Name", "address": "Address", + "workAddress": "Work address", "certificateProvider": "Certificate provider", "certificateProviderMobile": "certificate provider mobile", "attorneys": "Attorneys", @@ -561,8 +562,11 @@ "useAnAddressYouAlreadyEntered": "Use an address you’ve already entered", "enterNewAddress": "Enter a new address", "whatIsPersonsPostcode": "What is {{.FullNamePossessive}} postcode?", + "whatIsPersonsWorkPostcode": "What is {{.FullNamePossessive}} work postcode?", "selectAnAddressForPerson": "Select an address for {{.FullName}}", + "selectPersonsWorkAddress": "Select {{.FullNamePossessive}} work address", "personsAddress": "{{.FullNamePossessive}} address", + "personsWorkAddress": "{{.FullNamePossessive}} work address", "personToNotify": "Person to notify", "thisIsAnImportantDecision": "This is an important decision and should be thought about carefully.", "lifeSustainingTreatmentContent": "You must choose whether your attorneys can give or refuse consent to life-sustaining treatment on your behalf.
Life-sustaining treatment means care, surgery, medicine or other help from doctors that’s needed to keep you alive.
Decisions about life-sustaining treatment can be needed in unexpected circumstances, such as a routine operation that did not go as planned
", diff --git a/web/template/choose_address.gohtml b/web/template/choose_address.gohtml index a2bad730b4..c0003f617d 100644 --- a/web/template/choose_address.gohtml +++ b/web/template/choose_address.gohtml @@ -2,15 +2,15 @@ {{ define "pageTitle" }} {{ if eq .Form.Action "manual" }} - {{ trFormat .App "personsAddress" "FullNamePossessive" (tr .App .ActorLabel | possessive .App) "FullName" (tr .App .ActorLabel) }} + {{ trFormat .App .TitleKeys.Manual "FullNamePossessive" (tr .App .ActorLabel | possessive .App) "FullName" (tr .App .ActorLabel) }} {{ else if eq .Form.Action "postcode-select" "postcode-lookup" }} - {{ trFormat .App "selectAnAddressForPerson" "FullName" (tr .App .ActorLabel | lowerFirst) }} + {{ trFormat .App .TitleKeys.PostcodeSelectAndPostcodeLookup "FullNamePossessive" (tr .App .ActorLabel | possessive .App | lowerFirst) "FullName" (tr .App .ActorLabel | lowerFirst) }} {{ else if eq .Form.Action "postcode" }} - {{ trFormat .App "whatIsPersonsPostcode" "FullNamePossessive" (tr .App .ActorLabel | possessive .App | lowerFirst) }} + {{ trFormat .App .TitleKeys.Postcode "FullNamePossessive" (tr .App .ActorLabel | possessive .App | lowerFirst) }} {{ else if eq .Form.Action "reuse" "reuse-select" }} - {{ trFormat .App "selectAnAddressForPerson" "FullName" (tr .App .ActorLabel | lowerFirst) }} + {{ trFormat .App .TitleKeys.ReuseAndReuseSelect "FullName" (tr .App .ActorLabel | lowerFirst) }} {{ else }} - {{ trFormat .App "addPersonsAddress" "FullNamePossessive" (tr .App .ActorLabel | possessive .App | lowerFirst) }} + {{ trFormat .App .TitleKeys.ReuseOrNew "FullNamePossessive" (tr .App .ActorLabel | possessive .App | lowerFirst) }} {{ end }} {{ end }} @@ -23,7 +23,7 @@