Files
calendar/packages/lib/__tests__/timeShift.test.ts
T
Kartik LabhshetwarGitHubcubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
8dc8d87ad0 feat: add time shift badge for recurring events with shifted local times (#25568)
* feat: highlight recurring bookings with time shift badge across DST

* Update packages/lib/__tests__/timeShift.test.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* refactor: show time shift badge only on first shift in bookings view and occurrences

* refactor: update recurring bookings display logic and wrap booking title text

* refactor: add getFirstShiftFlags helper for time shift flags and update components

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-12-11 20:18:00 +00:00

54 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import dayjs from "@calcom/dayjs";
import { getTimeShiftFlags } from "../timeShift";
describe("getTimeShiftFlags", () => {
it("returns empty array for no dates", () => {
expect(getTimeShiftFlags({ dates: [], timezone: "Europe/Berlin" })).toEqual([]);
});
it("marks only shifting occurrences as true for a DST forward change", () => {
const tz = "Europe/Berlin";
const first = dayjs.tz("2026-03-17T01:00:00", tz);
const second = dayjs.tz("2026-03-24T01:00:00", tz);
const third = dayjs.tz("2026-03-31T02:00:00", tz);
const dates = [first.toISOString(), second.toISOString(), third.toISOString()];
const flags = getTimeShiftFlags({ dates, timezone: tz });
expect(flags).toEqual([false, false, true]);
});
it("marks only shifting occurrences as true for a DST backward change", () => {
const tz = "Europe/Berlin";
const first = dayjs.tz("2026-10-18T02:00:00", tz);
const second = dayjs.tz("2026-10-25T02:00:00", tz);
const third = dayjs.tz("2026-11-01T01:00:00", tz);
const dates = [first.toISOString(), second.toISOString(), third.toISOString()];
const flags = getTimeShiftFlags({ dates, timezone: tz });
expect(flags).toEqual([false, false, true]);
});
it("handles non shifting occurrences", () => {
const tz = "America/New_York";
const first = dayjs.tz("2026-04-01T09:00:00", tz);
const second = dayjs.tz("2026-04-08T09:00:00", tz);
const third = dayjs.tz("2026-04-15T09:00:00", tz);
const dates = [first.toISOString(), second.toISOString(), third.toISOString()];
const flags = getTimeShiftFlags({ dates, timezone: tz });
expect(flags).toEqual([false, false, false]);
});
});