Skip to content

Commit

Permalink
fix date issue
Browse files Browse the repository at this point in the history
  • Loading branch information
abigailsmith97 committed Jul 31, 2024
1 parent 3226acf commit 698d0b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions playwright-e2e/pages/applicantsDetails.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default class AddApplicants {

async dob(): Promise<void> {
const today = new Date();
const dayString = `${today.getDate()}`;
const monthString = `${today.getMonth()}`;
const yearString = `${today.getFullYear() - 21}`;
const dayString = String(today.getDate());
const monthString = String(today.getMonth() + 1); //getMonth() uses zero-based index so + 1 is needed to convert it to correct month for inputting in test
const yearString = String(today.getFullYear() - 21);

await this.dayField.fill(dayString);
await this.monthField.fill(monthString);
Expand Down
4 changes: 2 additions & 2 deletions playwright-e2e/pages/childDetails.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default class ChildDetails {

async childsDob(): Promise<void> {
const today = new Date();
const day = String(today.getDate()).padStart(2, '0');
const month = String(today.getMonth() + 1).padStart(2, '0');
const day = String(today.getDate());
const month = String(today.getMonth() + 1); //getMonth() uses zero-based index so + 1 is needed to convert it to correct month for inputting in test
const year = String(today.getFullYear() - 5);

await this.day.fill(day);
Expand Down
13 changes: 7 additions & 6 deletions playwright-e2e/pages/dateChildMoved.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export default class DateChildMoved {
}

async dateChildMovedInToday(): Promise<void> {

const today = new Date();
const day = String(today.getDate()).padStart(2, '0');
const month = String(today.getMonth() + 1).padStart(2, '0');
const year = String(today.getFullYear() - 1);
const dayMoveIn = String(today.getDate());
const monthMoveIn = String(today.getMonth() + 1); //getMonth() uses zero-based index so + 1 is needed to convert it to correct month for inputting in test
const yearMoveIn = String(today.getFullYear() - 1);

await this.day.fill(day);
await this.month.fill(month);
await this.year.fill(year);
await this.day.fill(dayMoveIn);
await this.month.fill(monthMoveIn);
await this.year.fill(yearMoveIn);
}
}

0 comments on commit 698d0b5

Please sign in to comment.