Skip to content

Commit

Permalink
LIME-771: Added additonal acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gds-jbentham committed Aug 3, 2023
1 parent db848f8 commit 2b763a9
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/app/drivingLicence/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ module.exports = {
validate: [
"required",
"date",
{
type: "before",
arguments: [],
},
{
type: "beforeNow",
fn: fields.beforeNow,
Expand All @@ -83,6 +87,10 @@ module.exports = {
validate: [
"required",
"date",
{
type: "before",
arguments: [],
},
{
type: "beforeNow",
fn: fields.beforeNow,
Expand Down
3 changes: 2 additions & 1 deletion src/app/drivingLicence/fieldsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ module.exports = {
let dateFormat = 'YYYY-MM-DD';
let test = moment(_value, dateFormat);
let comparator;
comparator = moment().subtract(timePeriod, timeUnit);
// One additional day subtracted so that the check is inclusive of the current date minus X time
comparator = moment().subtract(timePeriod, timeUnit).subtract(1, "days");

return _value === '' || validators.date(_value) && test.isAfter(comparator);
}
Expand Down
18 changes: 16 additions & 2 deletions src/app/drivingLicence/fieldsHelper.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fields = require("./fieldsHelper");
const moment = require('moment');

describe("custom validation fields test", () => {
it("should be false when first and middle name combined greater than 30 characters", () => {
Expand Down Expand Up @@ -102,7 +103,7 @@ describe("custom validation fields test", () => {
});

it("should be false when licence issued greater than 10 years ago", () => {
const issueDate = "2013-08-01";
const issueDate = moment().subtract(10, "years").subtract(1, "days").format("YYYY-MM-DD");
const validator = fields.beforeNow.bind({
values: {
issueDate: issueDate,
Expand All @@ -115,7 +116,20 @@ describe("custom validation fields test", () => {
});

it("should be true when licence issued less than 10 years ago", () => {
const issueDate = "2013-08-04";
const issueDate = moment().subtract(10, "years").add(1, "days").format("YYYY-MM-DD");
const validator = fields.beforeNow.bind({
values: {
issueDate: issueDate,
},
});

expect(
validator(issueDate, 10, "years")
).to.be.true;
});

it("should be true when licence issued is issued exactly 10 years ago", () => {
const issueDate = moment().subtract(10, "years").format("YYYY-MM-DD");
const validator = fields.beforeNow.bind({
values: {
issueDate: issueDate,
Expand Down
4 changes: 2 additions & 2 deletions test/browser/features/DVA_Driving_Licence.feature
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ Feature: DVA Driving licence CRI Error Validations
|DVADrivingLicenceSubject |InvalidValidToDay|InvalidValidToMonth|InvalidValidToYear|
|DrivingLicenceSubjectHappyBilly| 10 | 01 | 2010 |

@mock-api:dva-ConsentError @validation-regression @build @staging
@mock-api:dva-ConsentError @validation-regression @build @staging1
Scenario Outline: DVA Driving Licence error validation when DVA consent checkbox is unselected
Given User enters DVA data as a <DVADrivingLicenceSubject>
And DVA consent checkbox is unselected
When User clicks on continue
Then I can see the DVA consent error summary as You must give your consent to continue
And I can see the DVA consent error on the checkbox as Error: You must give your consent to continue
And I can see the DVA consent error on the checkbox as You must give your consent to continue
And I check the page Title Error: Enter your details exactly as they appear on your UK driving licence – Prove your identity – GOV.UK
Examples:
|DVADrivingLicenceSubject |
Expand Down
30 changes: 29 additions & 1 deletion test/browser/features/DVLADrivingLicence.feature
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,34 @@ Feature: DVLA Driving licence CRI Error Validations
|DrivingLicenceSubjectHappyPeter| & | ^% | £$ ^ |
|DrivingLicenceSubjectHappyPeter| | | |

@mock-api:dl-success @validation-regression @build @staging
Scenario: DVLA Driving Licence Issue date that is greater than 10 years old date error validation
Given User enters DVLA data as a DrivingLicenceSubjectHappyPeter
Then User enters date of issue as current date
And User enters year of issue as current year minus 10
And User enters day of issue as current day minus 1
When User clicks on continue
Then I see issue date error in summary as Enter the date as it appears on your driving licence
And I see invalid issue date field error as Enter the date as it appears on your driving licence
And I check the page Title Error: Enter your details exactly as they appear on your UK driving licence – Prove your identity – GOV.UK

@mock-api:dl-success @validation-regression @build @staging
Scenario: DVLA Driving Licence Issue date that is exactly 10 years old date error validation
Given User enters DVLA data as a DrivingLicenceSubjectHappyPeter
Then User enters date of issue as current date
And User enters year of issue as current year minus 10
When User clicks on continue
Then Proper error message is displayed as We could not find your details

@mock-api:dl-success @validation-regression @build @staging
Scenario: DVLA Driving Licence Issue date that is 1 day under 10 years old date error validation
Given User enters DVLA data as a DrivingLicenceSubjectHappyPeter
Then User enters date of issue as current date
And User enters year of issue as current year minus 10
And User enters day of issue as current day plus 1
When User clicks on continue
Then Proper error message is displayed as We could not find your details

@mock-api:dl-success @validation-regression @build @staging
Scenario Outline: DVLA Driving Licence Issue date in the future error validation
Given User enters DVLA data as a <DrivingLicenceSubject>
Expand Down Expand Up @@ -308,7 +336,7 @@ Feature: DVLA Driving licence CRI Error Validations
Given User enters DVLA data as a <DrivingLicenceSubject>
And DVLA consent checkbox is unselected
When User clicks on continue
And I can see the DVLA consent error on the checkbox as Error: You must give your consent to continue
And I can see the DVLA consent error on the checkbox as You must give your consent to continue
Then I can see the DVLA consent error summary as You must give your consent to continue
And I check the page Title Error: Enter your details exactly as they appear on your UK driving licence – Prove your identity – GOV.UK
Examples:
Expand Down
24 changes: 24 additions & 0 deletions test/browser/pages/DrivingLicencePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { expect: expect } = require("chai");
const moment = require('moment');
const TestDataCreator = require("../util/TestDataCreator");

exports.DrivingLicencePage = class PlaywrightDevPage {
Expand Down Expand Up @@ -228,14 +229,37 @@ exports.DrivingLicencePage = class PlaywrightDevPage {
await this.licenceIssueDay.fill(InvalidDayOfIssue);
}

async userReEntersDayOfIssueAsCurrentDateMinus(days) {
await this.licenceIssueDay.fill(moment().subtract(days, "days").format("DD"));
}

async userReEntersDayOfIssueAsCurrentDatePlus(days) {
await this.licenceIssueDay.fill(moment().add(days, "days").format("DD"));
}

async userReEntersMonthOfIssue(InvalidMonthOfIssue) {
await this.licenceIssueMonth.fill(InvalidMonthOfIssue);
}

async userReEntersMonthOfIssueAsCurrentDateMinus(months) {
await this.licenceIssueMonth.fill(moment().subtract(months, "months").format("MM"));
}

async userReEntersYearOfIssue(InvalidYearOfIssue) {
await this.licenceIssueYear.fill(InvalidYearOfIssue);
}

async userReEntersYearOfIssueAsCurrentDateMinus(years) {
await this.licenceIssueYear.fill(moment().subtract(years, "years").format("YYYY"));
}

async userReEntersIssueDateAsCurrentDate() {
await this.licenceIssueYear.fill(moment().format("YYYY"));
await this.licenceIssueMonth.fill(moment().format("MM"));
await this.licenceIssueDay.fill(moment().format("DD"));

}

async userReEntersValidToDay(InvalidValidToDay) {
await this.licenceValidToDay.fill(InvalidValidToDay);
}
Expand Down
36 changes: 36 additions & 0 deletions test/browser/step_definitions/DrivingLicenceStepDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ Then(
}
);

Then(
/^User enters date of issue as current date$/,
{ timeout: 2 * 5000 },
async function () {
const drivingLicencePage = new DrivingLicencePage(this.page);
await drivingLicencePage.userReEntersIssueDateAsCurrentDate();
}
);

Then(
/^User re-enters day of issue as (.*)$/,
{ timeout: 2 * 5000 },
Expand All @@ -119,6 +128,24 @@ Then(
}
);

Then(
/^User enters day of issue as current day minus (.*)$/,
{ timeout: 2 * 5000 },
async function (daysToSubtract) {
const drivingLicencePage = new DrivingLicencePage(this.page);
await drivingLicencePage.userReEntersDayOfIssueAsCurrentDateMinus(daysToSubtract);
}
);

Then(
/^User enters day of issue as current day plus (.*)$/,
{ timeout: 2 * 5000 },
async function (daysToAdd) {
const drivingLicencePage = new DrivingLicencePage(this.page);
await drivingLicencePage.userReEntersDayOfIssueAsCurrentDatePlus(daysToAdd);
}
);

Then(
/^User re-enters month of issue as (.*)$/,
{ timeout: 2 * 5000 },
Expand All @@ -137,6 +164,15 @@ Then(
}
);

Then(
/^User enters year of issue as current year minus (.*)$/,
{ timeout: 2 * 5000 },
async function (yearsToSubtract) {
const drivingLicencePage = new DrivingLicencePage(this.page);
await drivingLicencePage.userReEntersYearOfIssueAsCurrentDateMinus(yearsToSubtract);
}
);

Then(
/^User re-enters valid to day as (.*)$/,
{ timeout: 2 * 5000 },
Expand Down
6 changes: 3 additions & 3 deletions test/browser/util/TestDataCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.getDVLATestUserFromMap = function (
birthYear: "1962",
licenceIssueDay: "23",
licenceIssueMonth: "05",
licenceIssueYear: "1982",
licenceIssueYear: "2018",
issueNumber: "12",
consentDVLACheckbox: "true",
middleNames: "BENJAMIN",
Expand All @@ -32,7 +32,7 @@ exports.getDVLATestUserFromMap = function (
birthYear: "1965",
licenceIssueDay: "19",
licenceIssueMonth: "04",
licenceIssueYear: "2001",
licenceIssueYear: "2018",
issueNumber: "23",
consentDVLACheckbox: "true",
middleNames: " ",
Expand Down Expand Up @@ -67,7 +67,7 @@ exports.getDVATestUserFromMap = function (
birthYear: "1981",
licenceIssueDay: "19",
licenceIssueMonth: "04",
licenceIssueYear: "2001",
licenceIssueYear: "2018",
consentDVACheckbox: "true",
middleNames: "",
lastName: "BATSON",
Expand Down

0 comments on commit 2b763a9

Please sign in to comment.