Skip to content

Commit

Permalink
fix date calculation flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncaci committed Sep 3, 2024
1 parent 6c02dd5 commit 4367941
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions playwright/tests/office/txo/sitUpdates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ test.describe('TOO user', () => {
const timeDiff = oneMonthAgo.getTime() - twoMonthsAgo.getTime();
// get the days, converting milliseconds to days
const daysDiff = timeDiff / (1000 * 60 * 60 * 24);
// be inclusive of the last day
const totalDaysBetweenOneMonthInclusive = daysDiff + 1;
const totalDaysBetweenOneMonthInclusive = daysDiff;
// get sums
const totalDaysUsed = totalDaysBetweenOneMonthInclusive * 2; // Origin and Dest sit each used 1 month
const remainingDays = 90 - totalDaysUsed;
Expand All @@ -61,7 +60,7 @@ test.describe('TOO user', () => {

// get authorized end date as 90 days from the origin start date (two months ago)
const ninetyDaysFromStartDateInclusive = new Date(twoMonthsAgo);
ninetyDaysFromStartDateInclusive.setDate(ninetyDaysFromStartDateInclusive.getDate() + 89); // Use 89 because the last day is counted as a whole day
ninetyDaysFromStartDateInclusive.setDate(ninetyDaysFromStartDateInclusive.getDate() + 90);
// format
const day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(ninetyDaysFromStartDateInclusive);
const month = new Intl.DateTimeFormat('en', { month: 'short' }).format(ninetyDaysFromStartDateInclusive);
Expand Down Expand Up @@ -110,8 +109,8 @@ test.describe('TOO user', () => {
const destinationDaysDiff = destinationTimeDiff / (1000 * 60 * 60 * 24);
const originDaysDiff = originTimeDiff / (1000 * 60 * 60 * 24);
// be inclusive of the last day
const totalDaysBetweenDestinationInclusive = destinationDaysDiff + 1;
const totalDaysBetweenOriginInclusive = originDaysDiff + 1;
const totalDaysBetweenDestinationInclusive = destinationDaysDiff;
const totalDaysBetweenOriginInclusive = originDaysDiff;
// get sums
const totalDaysUsed = totalDaysBetweenDestinationInclusive + totalDaysBetweenOriginInclusive;
const remainingDays = 90 - totalDaysUsed;
Expand Down

0 comments on commit 4367941

Please sign in to comment.