fix: Infinite loop in timezones on the negative side of UTC (#12063)

* fix: Infinite loop in timezones on the negative side of UTC

* Update packages/features/calendars/lib/getAvailableDatesInMonth.test.ts

* Revert back to real system time after test

* Handle all dates as local time, given this all happens in the browser
This commit is contained in:
Alex van Andel authored and GitHub committed 2023-10-25 17:18:25 +04:00
1 parent 327159c2ae
commit efc7be0b6b
4 files changed
+58 -5

No files matched your search

+21
View File
@@ -1,6 +1,13 @@
import { defineWorkspace } from "vitest/config";
const packagedEmbedTestsOnly = process.argv.includes("--packaged-embed-tests-only");
const timeZoneDependentTestsOnly = process.argv.includes("--timeZoneDependentTestsOnly");
// eslint-disable-next-line turbo/no-undeclared-env-vars
const envTZ = process.env.TZ;
if (timeZoneDependentTestsOnly && !envTZ) {
throw new Error("TZ environment variable is not set");
}
// defineWorkspace provides a nice type hinting DX
const workspaces = packagedEmbedTestsOnly
? [
@@ -11,6 +18,19 @@ const workspaces = packagedEmbedTestsOnly
},
},
]
: // It doesn't seem to be possible to fake timezone per test, so we rerun the entire suite with different TZ. See https://github.com/vitest-dev/vitest/issues/1575#issuecomment-1439286286
timeZoneDependentTestsOnly
? [
{
test: {
name: `TimezoneDependentTests:${envTZ}`,
include: ["packages/**/*.timezone.test.ts", "apps/**/*.timezone.test.ts"],
// TODO: Ignore the api until tests are fixed
exclude: ["**/node_modules/**/*", "packages/embeds/**/*"],
setupFiles: ["setupVitest.ts"],
},
},
]
: [
{
test: {
@@ -20,6 +40,7 @@ const workspaces = packagedEmbedTestsOnly
setupFiles: ["setupVitest.ts"],
},
},
{
test: {
name: "@calcom/closecom",