diff --git a/app/main/views/two_factor.py b/app/main/views/two_factor.py index e9140e8aa..1d3eee998 100644 --- a/app/main/views/two_factor.py +++ b/app/main/views/two_factor.py @@ -24,7 +24,8 @@ def two_factor_email_sent(): title = 'Email resent' if request.args.get('email_resent') else 'Check your email' return render_template( 'views/two-factor-email.html', - title=title + title=title, + redirect_url=request.args.get('next') ) diff --git a/app/templates/views/two-factor-email.html b/app/templates/views/two-factor-email.html index 82e2c749e..81315863e 100644 --- a/app/templates/views/two-factor-email.html +++ b/app/templates/views/two-factor-email.html @@ -13,7 +13,7 @@
We’ve emailed you a link to sign in to Notify.
Clicking the link will open Notify in a new browser window, so you can close this one.
{{ page_footer( - secondary_link=url_for('main.email_not_received'), + secondary_link=url_for('main.email_not_received', next=redirect_url), secondary_link_text='Not received an email?' ) }} diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py index 2c2c9dd2e..49a41a037 100644 --- a/tests/app/main/views/test_two_factor.py +++ b/tests/app/main/views/test_two_factor.py @@ -11,6 +11,32 @@ from tests.conftest import ( ) +@pytest.mark.parametrize('redirect_url', [ + None, + 'blob', +]) +@pytest.mark.parametrize('email_resent, page_title', [ + (None, 'Check your email'), + (True, 'Email resent') +]) +def test_two_factor_email_sent_page( + client, + email_resent, + page_title, + redirect_url +): + response = client.get(url_for('main.two_factor_email_sent', next=redirect_url, email_resent=email_resent)) + assert response.status_code == 200 + + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.h1.string == page_title + # there shouldn't be a form for updating mobile number + assert page.find('form') is None + resend_email_link = page.find('a', class_="govuk-link govuk-link--no-visited-state page-footer-secondary-link") + assert resend_email_link.text == 'Not received an email?' + assert resend_email_link['href'] == url_for('main.email_not_received', next=redirect_url) + + def test_should_render_two_factor_page( client, api_user_active,