temporalio / temporalio/ui

Broken timezone related unit tests off of `main`

Open
#1,915 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
431
Forks
179
Avg merge
2d 9h
Merged PRs (30d)
71

Description

Describe the bug
Running pnpm vitest results in failures related to timezones.

To Reproduce

 gh repo clone temporalio/ui
 cd ui
 pnpm install
 pnpm test  # passes green
 pnpm vitest

Expected behavior

pass green

Desktop (please complete the following information):

  • OS: macOS
  • Browser: n/a
  • Darwin Kernel Version 23.3.0

Additional context

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 11 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/lib/utilities/to-duration.test.ts > toDate > should produce a date based on a duration
AssertionError: expected '2019-10-02T23:00:00.000Z' to be '2019-10-03T00:00:00.000Z' // Object.is equality

- Expected
+ Received

- 2019-10-03T00:00:00.000Z
+ 2019-10-02T23:00:00.000Z

 ❯ src/lib/utilities/to-duration.test.ts:109:20
    107|
    108|     const result = toDate({ days: 90 });
    109|     expect(result).toBe(ninetyDaysEarlier);
       |                    ^
    110|   });
    111|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/11]⎯

 FAIL  src/lib/utilities/to-duration.test.ts > toDate > should produce a date based on a duration string
AssertionError: expected '2019-10-02T23:00:00.000Z' to be '2019-10-03T00:00:00.000Z' // Object.is equality

- Expected
+ Received

- 2019-10-03T00:00:00.000Z
+ 2019-10-02T23:00:00.000Z

 ❯ src/lib/utilities/to-duration.test.ts:116:20
    114|
    115|     const result = toDate('90 days');
    116|     expect(result).toBe(ninetyDaysEarlier);
       |                    ^
    117|   });
    118| });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/11]⎯

 FAIL  src/lib/utilities/to-duration.test.ts > fromDate > should produce a duration based on a 90 days in the past
AssertionError: expected { Object (years, months, ...) } to match object { months: 2, days: 29 }

- Expected
+ Received

  Object {
-   "days": 29,
+   "days": 28,
+   "hours": 23,
+   "minutes": 0,
    "months": 2,
+   "seconds": 0,
+   "years": 0,
  }

 ❯ src/lib/utilities/to-duration.test.ts:160:20
    158|
    159|     const result = fromDate(ninetyDaysEarlier);
    160|     expect(result).toMatchObject({ months: 2, days: 29 });
       |                    ^
    161|   });
    162|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/11]⎯

 FAIL  src/lib/utilities/to-duration.test.ts > fromDate > should produce a duration based on a 60 days in the past
AssertionError: expected { Object (years, months, ...) } to match object { months: 2 }

- Expected
+ Received

  Object {
-   "months": 2,
+   "days": 30,
+   "hours": 23,
+   "minutes": 0,
+   "months": 1,
+   "seconds": 0,
+   "years": 0,
  }

 ❯ src/lib/utilities/to-duration.test.ts:167:20
    165|
    166|     const result = fromDate(sixtyDaysEarlier);
    167|     expect(result).toMatchObject({ months: 2 });
       |                    ^
    168|   });
    169|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/11]⎯

 FAIL  src/lib/utilities/format-time.test.ts > getDuration > should get months/days/hours/minutes/seconds duration of a start and end date
AssertionError: expected { Object (years, months, ...) } to strictly equal { Object (days, hours, ...) }

- Expected
+ Received

  Object {
    "days": 11,
-   "hours": 5,
+   "hours": 4,
    "minutes": 5,
    "months": 7,
    "seconds": 45,
    "years": 0,
  }

 ❯ src/lib/utilities/format-time.test.ts:104:22
    102|     const distance = formatDistance({ start, end });
    103|     const abbvDistancer = formatDistanceAbbreviated({ start, end });
    104|     expect(duration).toStrictEqual({
       |                      ^
    105|       days: 11,
    106|       hours: 5,

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/11]⎯

 FAIL  src/lib/utilities/format-date.test.ts > formatDate > should format local time
AssertionError: expected '2022-04-13 EDT 12:29:35.63' to deeply equal '2022-04-13 UTC 16:29:35.63'

- Expected
+ Received

- 2022-04-13 UTC 16:29:35.63
+ 2022-04-13 EDT 12:29:35.63

 ❯ src/lib/utilities/format-date.test.ts:51:39
     49|
     50|   it('should format local time', () => {
     51|     expect(formatDate(date, 'local')).toEqual('2022-04-13 UTC 16:29:35.63');
       |                                       ^
     52|   });
     53|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/11]⎯

 FAIL  src/lib/utilities/format-date.test.ts > formatDate > should shorten format for local and other timezones
AssertionError: expected '2022-04-13 12:29:35 PM' to deeply equal '2022-04-13 16:29:35 PM'

- Expected
+ Received

- 2022-04-13 16:29:35 PM
+ 2022-04-13 12:29:35 PM

 ❯ src/lib/utilities/format-date.test.ts:71:61
     69|
     70|   it('should shorten format for local and other timezones', () => {
     71|     expect(formatDate(date, 'local', { abbrFormat: true })).toEqual(
       |                                                             ^
     72|       '2022-04-13 16:29:35 PM',
     73|     );

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[7/11]⎯

 FAIL  src/lib/utilities/format-date.test.ts > formatDate > should shorten format without seconds if there are none for local and other timezones
AssertionError: expected '2022-04-13 12:29 PM' to deeply equal '2022-04-13 16:29 PM'

- Expected
+ Received

- 2022-04-13 16:29 PM
+ 2022-04-13 12:29 PM

 ❯ src/lib/utilities/format-date.test.ts:83:7
     81|     expect(
     82|       formatDate(dateWithoutSeconds, 'local', { abbrFormat: true }),
     83|     ).toEqual('2022-04-13 16:29 PM');
       |       ^
     84|     expect(formatDate(dateWithoutSeconds, 'utc', { abbrFormat: true })).toEqual(
     85|       '2022-04-13 16:29 PM',

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[8/11]⎯

 FAIL  src/lib/utilities/format-date.test.ts > getLocalTime > should get the local timezone
AssertionError: expected 'Eastern Daylight Time (EDT)' to be 'UTC' // Object.is equality

- Expected
+ Received

- UTC
+ Eastern Daylight Time (EDT)

 ❯ src/lib/utilities/format-date.test.ts:129:28
    127| describe('getLocalTime', () => {
    128|   it('should get the local timezone', () => {
    129|     expect(getLocalTime()).toBe('UTC');
       |                            ^
    130|   });
    131| });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[9/11]⎯

 FAIL  src/lib/utilities/format-date.test.ts > getSelectedTimezone > should get the local timezone
AssertionError: expected 'Eastern Daylight Time (EDT)' to be 'UTC' // Object.is equality

- Expected
+ Received

- UTC
+ Eastern Daylight Time (EDT)

 ❯ src/lib/utilities/format-date.test.ts:141:42
    139|
    140|   it('should get the local timezone', () => {
    141|     expect(getSelectedTimezone('local')).toBe('UTC');
       |                                          ^
    142|   });
    143|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[10/11]⎯

 FAIL  src/lib/stores/time-format.test.ts > getTimezone > should return the local timezone if the time format is local
AssertionError: expected 'America/New_York' to be 'UTC' // Object.is equality

- Expected
+ Received

- UTC
+ America/New_York

 ❯ src/lib/stores/time-format.test.ts:23:34
     21|
     22|   test('should return the local timezone if the time format is local', () => {
     23|     expect(getTimezone('local')).toBe('UTC');
       |                                  ^
     24|   });
     25|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[11/11]⎯

 Test Files  4 failed (4)
      Tests  11 failed | 123 passed (134)
   Start at  16:15:58
   Duration  1.25s


 FAIL  Tests failed. Watching for file changes...
       press h to show help, press q to quit

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running pnpm vitest and review the failures in src/lib/utilities/to-duration.test.ts, src/lib/utilities/format-time.test.ts, src/lib/utilities/format-date.test.ts, and src/lib/stores/time-format.test.ts. Trace the timezone-dependent expectations and related utilities; done means the 134-test Vitest run passes consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.