Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🐛 Fix test assertion in datepicker tests #20188

Merged
merged 3 commits into from
Dec 7, 2022

Conversation

josephkmh
Copy link
Contributor

What

  • Fixes a bad assertion that relied on test running on a machine set to UTC

@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Dec 7, 2022
const TEST_UTC_TIMESTAMP = "2000-01-01T12:00:00Z";

const result = toEquivalentLocalTime(TEST_UTC_TIMESTAMP);

// Regardless of the timezone, the local time should be the same
expect(result?.toISOString().substring(0, 19)).toEqual(TEST_UTC_TIMESTAMP.substring(0, 19));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date.toISOString() is always set to the UTC timezone, so this assertion would only work in a UTC timezone.

Instead, we can assert that toEquivalentLocalTime() has the expected timezone offset with Date.getTimezoneOffset() and that dayjs.format(), which outputs a local timezone, will have the same YYYY-MM-DDTHH:mm:ss value.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, code review only as we discussed it in person.

@josephkmh josephkmh marked this pull request as ready for review December 7, 2022 19:52
@josephkmh josephkmh requested a review from a team as a code owner December 7, 2022 19:52
@josephkmh josephkmh merged commit 078ad42 into master Dec 7, 2022
@josephkmh josephkmh deleted the joey/fix-datepicker-test-assertion branch December 7, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants