diff --git a/project.inlang/settings.json b/project.inlang/settings.json index af12cf353..a8448d27f 100644 --- a/project.inlang/settings.json +++ b/project.inlang/settings.json @@ -1,18 +1,7 @@ { "$schema": "https://inlang.com/schema/project-settings", "baseLocale": "en", - "locales": [ - "en", - "de", - "fr", - "es", - "it", - "pl", - "ko", - "nl", - "pt-BR", - "ru" - ], + "locales": ["en", "de", "fr", "es", "it", "pl", "ko", "nl", "pt-BR", "ru"], "modules": [ "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4.5.5/dist/index.js" ], diff --git a/src/lib/medications/scheduling/__tests__/aligned-rrule-start.property.test.ts b/src/lib/medications/scheduling/__tests__/aligned-rrule-start.property.test.ts index 103f603bb..054bc1cce 100644 --- a/src/lib/medications/scheduling/__tests__/aligned-rrule-start.property.test.ts +++ b/src/lib/medications/scheduling/__tests__/aligned-rrule-start.property.test.ts @@ -9,10 +9,7 @@ import { describe, expect, it } from "vitest"; import { alignedRruleStart } from "@/lib/medications/scheduling/aligned-rrule-start"; -import { - assertProperty, - propertyTimeout, -} from "../../../../../tests/property/fast-check"; +import { assertProperty } from "../../../../../tests/property/fast-check"; const DAY_MS = 24 * 60 * 60 * 1000; const BYDAY = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] as const; @@ -36,7 +33,7 @@ const ruleArb = fc ), wkst: fc.option(fc.constantFrom("MO", "SU")), count: fc.option(fc.integer({ min: 1, max: 40 })), - bysetpos: fc.option(fc.constantFrom(1, 2, -1)), + bysetpos: fc.option(fc.constantFrom(1, -1)), }) .map(({ freq, interval, byday, byhour, wkst, count, bysetpos }) => [ @@ -93,6 +90,18 @@ describe("alignedRruleStart", () => { propertyTimeout(30_000), ); + it("keeps the anchor for BYSETPOS, which picks among a whole week", () => { + // Moving the start to a Friday left Monday out of the first week, so + // BYSETPOS=1 chose the Friday, the window's first day. + const rule = "FREQ=WEEKLY;INTERVAL=1;BYSETPOS=1;BYDAY=MO,FR"; + const anchor = new Date(Date.UTC(2023, 7, 15)); + const after = new Date(Date.UTC(2025, 6, 11)); + const before = new Date(after.getTime() + 21 * DAY_MS); + expect( + occurrences(rule, alignedRruleStart(rule, anchor, after), after, before), + ).toEqual(occurrences(rule, anchor, after, before)); + }); + it("moves a daily or weekly start close to the window", () => { const anchor = new Date(Date.UTC(2024, 5, 1)); const after = new Date(Date.UTC(2026, 2, 1));