UK-Export-Finance / dtfs2

Digital Trade Finance
MIT License
11 stars 1 forks source link

feat(DTFS2-7296): refactor e2e date constants #3664

Closed BethThomas141 closed 1 week ago

BethThomas141 commented 2 weeks ago

Introduction :pencil2:

The aim of this PR is to improve the dateConstants.js file used across E2E tests. Currently it's a very long file, with inconsistent namings. This PR changes it so that every date has an object associated with it:

{
    date,
    day: format(date, shortDayFormat),
    dayLong: format(date, longDayFormat),
    month: format(date, shortMonthFormat),
    monthLong: format(date, longMonthFormat),
    year: format(date, longYearFormat),
    ddMMMyyyy: format(date, ddMMMyyyyFormat),
    dMMMMyyyy: format(date, dMMMMyyyyFormat),
    ddMMMMyyyy: format(date, ddMMMMyyyyFormat),
    unixSecondsString: getUnixTime(date).toString(),
    unixMillisecondsString: date.valueOf().toString(),
    unixMilliseconds: date.valueOf(),
  };

so if I want to use say a day 2 days in the future in an E2E test, I can use e.g.: twoDays.date to use the Date value, or use say twoDays.year for the year, or twoDays.unixMilliseconds.

Resolution :heavy_check_mark:

List all changes made to the codebase.

Miscellaneous :heavy_plus_sign:

List any additional fixes or improvements.

ttbarnes commented 2 weeks ago

@Zainzzkk Could you take a look at this as well please?

I will have another look with a fresh mind next week 👍

sonarcloud[bot] commented 1 week ago

Quality Gate Failed Quality Gate failed

Failed conditions
53.5% Duplication on New Code (required ≤ 40%)

See analysis details on SonarCloud