Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUT-1466: Show end of telephone number on MFA resend screen #1694

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/components/resend-mfa-code/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
{% set showBack = true %}
{% set hrefBack = 'enter-code' %}

{% if isResendCodeRequest %}
{% set phoneNumberMessage %}
{{ 'pages.resendMfaCode.phoneNumber.isResendCodeRequest' | translate }} <span class='govuk-!-font-weight-bold'>{{ phoneNumber }}</span>
{% endset %}
{% else %}
{% set phoneNumberMessage = 'pages.resendMfaCode.phoneNumber.default' | translate | replace("[mobile]", phoneNumber) %}
{% endif %}
{% set phoneNumberMessage %}
{{ 'pages.resendMfaCode.phoneNumber.isResendCodeRequest' | translate }} <span class='govuk-!-font-weight-bold'>{{ phoneNumber | returnLastCharacters({limit: 3}) }}</span>
{% endset %}

{% block content %}
<form action="/resend-code" method="post" novalidate="novalidate">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import request from "supertest";
import { describe } from "mocha";
import { sinon } from "../../../../test/utils/test-utils";
import { expect, sinon } from "../../../../test/utils/test-utils";
import nock = require("nock");
import * as cheerio from "cheerio";
import decache from "decache";
Expand Down Expand Up @@ -61,6 +61,18 @@ describe("Integration:: resend mfa code", () => {

it("should return resend mfa code page", (done) => {
request(app).get(PATH_NAMES.RESEND_MFA_CODE).expect(200, done);

it("should include the last three digits of the user's telephone number", (done) => {
request(app)
.get(PATH_NAMES.RESEND_MFA_CODE)
.expect(function (res) {
const $ = cheerio.load(res.text);
expect($(".govuk-inset-text").text()).to.eq(
"We will send a code to your phone number ending with 867"
);
})
.expect(200, done);
});
});

it("should return error when csrf not present", (done) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/phone-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ export function returnLastCharactersOnly(
value: string,
options: { limit: number } = { limit: 4 }
): string {
return value.slice(-options.limit);
return value?.length ? value.slice(-options.limit) : "";
}
3 changes: 3 additions & 0 deletions test/unit/utils/phone-number.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,8 @@ describe("phone-number", () => {
).to.equal(i);
});
});
it("should return an empty string if passed empty string", () => {
expect(returnLastCharactersOnly("", { limit: 3 })).to.equal("");
});
});
});
Loading