@moltenship/calendar-testing 1.0.0-rc.1 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,9 @@ the registry views, your policies and your save logic.
20
20
  a mouse, a pen or a finger where the page is laid out.
21
21
  - **Assertions.** `settled()` waits for pending changes; `announcements()` and `lastAnnouncement()`
22
22
  read the `Announcer`; `placementOf(event)` says where an event shows, as comparable text.
23
+ - **Agents.** An AI agent's steps run through ui-sdk's real bridge inside `calendar.act`, with no
24
+ model involved, and `results` says each change's input was `"agent"`. See
25
+ [Changes an agent makes](https://time.molten.sh/docs/testing#changes-an-agent-makes).
23
26
 
24
27
  It uses only the public API of `@moltenship/calendar` and `@moltenship/calendar-recurrence`, and
25
28
  depends on no test runner: it works in Vitest with jsdom or happy-dom, and in Vitest's browser
@@ -54,6 +57,8 @@ pnpm add -D @moltenship/calendar-testing
54
57
  ```
55
58
 
56
59
  - React 19 and React DOM 19, peer dependencies.
60
+ - `@ui-sdk/core` and `@ui-sdk/react` 0.1 beta, peer dependencies since 2.0: the calendar's parts are
61
+ built on them. An app on `@moltenship/calendar` 2.0 already has both.
57
62
  - A runtime with `Temporal` (Node.js 26 and later include it). Elsewhere, add
58
63
  `if (!("Temporal" in globalThis)) await import("temporal-polyfill/global");` to your test setup
59
64
  file; the package never installs a polyfill itself.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { RecurrenceDate, RecurrencePeriod, RecurrenceRule, RecurringCalendarEvent } from "@moltenship/calendar-recurrence";
2
2
  import { ComponentType, ReactNode } from "react";
3
3
  import { AllDayCalendarEvent, AnyCalendarView, CalendarAnnouncementMessages, CalendarAvailability, CalendarClock, CalendarDiagnostic, CalendarDirection, CalendarEvent, CalendarEventChange, CalendarEventChangeHandler, CalendarEventProposal, CalendarFactory, CalendarFocus, CalendarMeta, CalendarPendingChanges, CalendarProposalDetail, CalendarPublicState, CalendarResource, CalendarRootProps, CalendarSelection, CalendarSemanticActions, CalendarTransactionResult, CalendarWeekRules, EventId, IsoDayOfWeek, ResourceAvailability, ResourceId, TimedCalendarEvent } from "@moltenship/calendar";
4
- //#region src/environment.d.ts
5
4
  /** A point in time: an `Instant`, a `ZonedDateTime`, or ISO text. */
6
5
  type DateTimeInput = Temporal.Instant | Temporal.ZonedDateTime | string;
7
6
  /** A date: a `PlainDate` or ISO text such as `"2026-10-08"`. */
@@ -66,8 +65,6 @@ interface TestClock extends CalendarClock {
66
65
  * advances fake timers; to show a new time at once, use a fixed `now` and the harness's `setNow`.
67
66
  */
68
67
  export declare function createTestClock(start?: DateTimeInput): TestClock;
69
- //#endregion
70
- //#region src/builders.d.ts
71
68
  interface EventBaseInput<TData, TEventId extends EventId, TResourceId extends ResourceId> {
72
69
  /** Defaults to the title. */
73
70
  readonly id?: TEventId;
@@ -163,8 +160,6 @@ export declare function withRecurrence<TData, TEventId extends EventId, TResourc
163
160
  * plus the rule and dates. Give `timeZone`, so the series repeats on that zone's wall clock.
164
161
  */
165
162
  export declare function buildRecurringEvent<TData = null, TEventId extends EventId = string, TResourceId extends ResourceId = string>(input: TimedEventInput<TData, TEventId, TResourceId> & Omit<RecurrenceInput, "duration">): RecurringCalendarEvent<NoInfer<TData>, NoInfer<TEventId>, NoInfer<TResourceId>>;
166
- //#endregion
167
- //#region src/changes.d.ts
168
163
  interface ApplyChangeOptions<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
169
164
  /**
170
165
  * The record a new event gets, from its change and the first `new-<n>` ID no event has; the
@@ -181,8 +176,6 @@ interface ApplyChangeOptions<TEvent, TEventId extends EventId = EventId, TResour
181
176
  * change carries, as an undone delete does. Returns a new array.
182
177
  */
183
178
  export declare function applyCanonicalChange<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId>(events: readonly TEvent[], change: CalendarEventChange<TEvent, TEventId, TResourceId>, options?: ApplyChangeOptions<TEvent, TEventId, TResourceId>): readonly TEvent[];
184
- //#endregion
185
- //#region src/queries.d.ts
186
179
  /**
187
180
  * Names an event: its ID or title as text (an ID wins), its ID as a number, or `{ id }`,
188
181
  * `{ title }` or `{ start }`. A `start` is a date for an all-day event, a date and time for a
@@ -209,8 +202,6 @@ export declare class CalendarQueryError extends Error {
209
202
  }
210
203
  /** Text with the thin and no-break spaces `Intl` output uses made plain, and trimmed. */
211
204
  export declare function normalizeText(text: string | null | undefined): string;
212
- //#endregion
213
- //#region src/keyboard.d.ts
214
205
  /** Modifier keys held with a key. */
215
206
  interface KeyModifiers {
216
207
  readonly altKey?: boolean;
@@ -288,8 +279,6 @@ interface KeyboardDriver<TEventId extends EventId = EventId, TResourceId extends
288
279
  /** Focuses the cell, starts a create, grows it by steps and drops it. */
289
280
  createEvent(cell: CellQuery<TResourceId>, steps?: KeyboardSteps): Promise<void>;
290
281
  }
291
- //#endregion
292
- //#region src/placement.d.ts
293
282
  /** Where an event shows, as text that compares with `===` and `toEqual`. */
294
283
  interface EventPlacementSummary<TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
295
284
  readonly id: TEventId;
@@ -309,8 +298,6 @@ interface EventPlacementSummary<TEventId extends EventId = EventId, TResourceId
309
298
  /** Whether it shows a change that isn't saved and in the events yet. */
310
299
  readonly isPending: boolean;
311
300
  }
312
- //#endregion
313
- //#region src/pointer.d.ts
314
301
  /** A point in the viewport, in CSS pixels. */
315
302
  interface Point {
316
303
  readonly x: number;
@@ -355,8 +342,6 @@ interface PointerDriver<TEventId extends EventId = EventId, TResourceId extends
355
342
  */
356
343
  createEvent(from: CellQuery<TResourceId>, to: CellQuery<TResourceId>, options?: PointerOptions): Promise<void>;
357
344
  }
358
- //#endregion
359
- //#region src/inspect.d.ts
360
345
  /** A resource: its ID, `null` for the unassigned row, or `{ title }`. */
361
346
  type ResourceQuery<TResourceId extends ResourceId = ResourceId> = TResourceId | null | {
362
347
  readonly title: string;
@@ -414,8 +399,6 @@ interface CalendarInspection<TEventId extends EventId = EventId, TResourceId ext
414
399
  readonly keyboard: KeyboardDriver<TEventId, TResourceId>;
415
400
  readonly pointer: PointerDriver<TEventId, TResourceId>;
416
401
  }
417
- //#endregion
418
- //#region src/harness.d.ts
419
402
  /**
420
403
  * Root props the harness owns; set the others through `rootProps`. The environment's `now`, or
421
404
  * the `clock` option, gives the time.
@@ -549,8 +532,6 @@ export declare function renderCalendar<TEvent, TResource, TViewDef extends AnyCa
549
532
  * test's own environment, so code that checks for `window` takes its browser branch there too.
550
533
  */
551
534
  export declare function hydrateCalendar<TEvent, TResource, TViewDef extends AnyCalendarView, TSelection, TFocus, TEventId extends EventId, TResourceId extends ResourceId>(Calendar: CalendarFactory<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>, options?: RenderCalendarOptions<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>): Promise<HydratedCalendarHarness<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>>;
552
- //#endregion
553
- //#region src/fixtures.d.ts
554
535
  /**
555
536
  * A ready dataset of canonical events for contract tests, with the environment, resources and
556
537
  * `Root` props it's meant for. Each field is a harness option, so
@@ -660,5 +641,4 @@ export declare function multiZoneSeriesFixture(): SeriesFixture<FixtureSeriesEve
660
641
  * day).
661
642
  */
662
643
  export declare function resourceDayFixture(): CalendarFixture<FixtureEvent, FixtureResource>;
663
- //#endregion
664
644
  export type { AllDayEventInput, ApplyChangeOptions, ArrowPresses, AvailabilityExceptionInput, AvailabilityInput, CalendarChangeResult, CalendarFixture, CalendarHarness, CalendarHarnessFor, CalendarHarnessRootProps, CalendarHarnessUpdate, CalendarInspection, CellQuery, DateInput, DateTimeInput, DstWeekOptions, EventFocusOptions, EventPlacementSummary, EventQuery, FixtureEvent, FixtureResource, FixtureSeriesEvent, HoursInput, HydratedCalendarHarness, KeyModifiers, KeyboardDriver, KeyboardSteps, Point, PointerDriver, PointerOptions, RecurrenceInput, RenderCalendarOptions, ResourceInput, ResourceQuery, SeriesFixture, SettleOptions, TestClock, TestEnvironment, TestEnvironmentOptions, TestEnvironmentRootProps, TimedEventInput };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { StrictMode, act, createElement, useLayoutEffect, useSyncExternalStore }
3
3
  import { createRoot, hydrateRoot } from "react-dom/client";
4
4
  import { renderToString } from "react-dom/server";
5
5
  import { eventIdOf, resourceIdOf, sameFocus } from "@moltenship/calendar";
6
- //#region src/environment.ts
6
+ // src/environment.ts
7
7
  /** What `createTestEnvironment` uses for each option left out. */
8
8
  const testDefaults = Object.freeze({
9
9
  direction: "ltr",
@@ -106,8 +106,7 @@ function createTestClock(start = testDefaults.now) {
106
106
  }
107
107
  });
108
108
  }
109
- //#endregion
110
- //#region src/builders.ts
109
+ // src/builders.ts
111
110
  /** The start events get without one: 09:00 on the default environment's date. */
112
111
  const defaultStart = "2026-10-08T09:00";
113
112
  const defaultDate = "2026-10-08";
@@ -256,8 +255,7 @@ function buildRecurringEvent(input) {
256
255
  rule
257
256
  });
258
257
  }
259
- //#endregion
260
- //#region src/changes.ts
258
+ // src/changes.ts
261
259
  /** Whether a record has the canonical event shape: a kind and ends of its own. */
262
260
  function isCanonicalEvent(record) {
263
261
  return typeof record === "object" && record !== null && "id" in record && "kind" in record && "start" in record && "end" in record;
@@ -298,8 +296,7 @@ function applyCanonicalChange(events, change, options = {}) {
298
296
  }
299
297
  return events.map((event) => event.id === change.eventId ? placed(event, change.proposed) : event);
300
298
  }
301
- //#endregion
302
- //#region src/real-time.ts
299
+ // src/real-time.ts
303
300
  /**
304
301
  * Milliseconds on the page's own clock, read through the `performance` object as it was when the
305
302
  * package loaded, so deadlines keep running when a test fakes `performance` later.
@@ -309,8 +306,7 @@ const now = page === void 0 ? void 0 : page.now.bind(page);
309
306
  function realNow() {
310
307
  return now?.() ?? 0;
311
308
  }
312
- //#endregion
313
- //#region src/queries.ts
309
+ // src/queries.ts
314
310
  /** Thrown when a query finds nothing, or more than one thing where it needs one. */
315
311
  var CalendarQueryError = class extends Error {
316
312
  constructor(message) {
@@ -394,8 +390,7 @@ function timeColumn(container, date, resourceId) {
394
390
  function resourceElements(container, resourceId) {
395
391
  return [...container.querySelectorAll("[data-resource-id]")].filter((element) => resourceIdOf(element) === resourceId);
396
392
  }
397
- //#endregion
398
- //#region src/announcements.ts
393
+ // src/announcements.ts
399
394
  const announcer = "[data-calendar-part=\"announcer\"]";
400
395
  /**
401
396
  * Records what every `Announcer` in a container says, in order: a live region's text after each
@@ -439,8 +434,7 @@ function recordAnnouncements(container) {
439
434
  stop: () => observer?.disconnect()
440
435
  };
441
436
  }
442
- //#endregion
443
- //#region src/keyboard.ts
437
+ // src/keyboard.ts
444
438
  /** `KeyboardEvent.code` for a key, on a US layout. */
445
439
  function codeOf(key) {
446
440
  if (key === " ") return "Space";
@@ -575,8 +569,7 @@ function createKeyboardDriver(context) {
575
569
  step
576
570
  });
577
571
  }
578
- //#endregion
579
- //#region src/placement.ts
572
+ // src/placement.ts
580
573
  function wall(instant, timeZone) {
581
574
  return instant.toZonedDateTimeISO(timeZone).toPlainDateTime().toString({ smallestUnit: "minute" });
582
575
  }
@@ -597,8 +590,7 @@ function summarizePlacement(event, timeZone) {
597
590
  wallRange: event.kind === "timed" ? `${wall(event.start, timeZone)}/${wall(event.end, timeZone)}` : range
598
591
  });
599
592
  }
600
- //#endregion
601
- //#region src/pointer.ts
593
+ // src/pointer.ts
602
594
  /** Thrown where pointer drivers need a layout the environment doesn't have, as in jsdom. */
603
595
  var PointerLayoutError = class extends Error {
604
596
  constructor(what) {
@@ -916,8 +908,7 @@ function createPointerDriver(context) {
916
908
  }
917
909
  });
918
910
  }
919
- //#endregion
920
- //#region src/inspect.ts
911
+ // src/inspect.ts
921
912
  /** A macrotask that fake timers don't hold back where `MessageChannel` exists. */
922
913
  function tick() {
923
914
  return new Promise((resolve) => {
@@ -1010,8 +1001,7 @@ function createInspection(context) {
1010
1001
  }
1011
1002
  });
1012
1003
  }
1013
- //#endregion
1014
- //#region src/harness.ts
1004
+ // src/harness.ts
1015
1005
  /** React's flag for test environments, which tells it to expect `act`. */
1016
1006
  const reactGlobals = globalThis;
1017
1007
  /** Thrown when a client render doesn't match the server's markup. */
@@ -1071,9 +1061,9 @@ function setUp(Calendar, initialOptions) {
1071
1061
  const { applyChange, createEvent } = options.get();
1072
1062
  events.set(applyChange === void 0 ? applyCanonicalChange(events.get(), change, { createEvent }) : applyChange(events.get(), change));
1073
1063
  }
1074
- const onEventChange = (change) => {
1064
+ const onEventChange = (change, detail) => {
1075
1065
  changes.push(change);
1076
- const outcome = options.get().onEventChange?.(change);
1066
+ const outcome = options.get().onEventChange?.(change, detail);
1077
1067
  if (isThenable(outcome)) return Promise.resolve(outcome).then(() => apply(change));
1078
1068
  apply(change);
1079
1069
  };
@@ -1298,8 +1288,7 @@ async function hydrateCalendar(Calendar, options = {}) {
1298
1288
  }
1299
1289
  return Object.freeze(Object.defineProperties({ serverMarkup }, Object.getOwnPropertyDescriptors(hydrated)));
1300
1290
  }
1301
- //#endregion
1302
- //#region src/fixtures.ts
1291
+ // src/fixtures.ts
1303
1292
  const sequence = (count) => Array.from({ length: count }, (_, index) => index);
1304
1293
  /**
1305
1294
  * Thursday 8 October 2026 in UTC, as busy as a day gets: 30 timed events and 3 all-day ones.
@@ -1639,5 +1628,4 @@ function resourceDayFixture() {
1639
1628
  })
1640
1629
  });
1641
1630
  }
1642
- //#endregion
1643
1631
  export { CalendarQueryError, HydrationMismatchError, PointerLayoutError, applyCanonicalChange, buildAllDayEvent, buildAvailability, buildEvent, buildRecurringEvent, buildResource, cleanup, createTestClock, createTestEnvironment, denseDayFixture, dstWeekFixture, hydrateCalendar, multiZoneSeriesFixture, normalizeText, renderCalendar, resourceDayFixture, withRecurrence };
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@moltenship/calendar-testing",
3
- "version": "1.0.0-rc.1",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Test helpers for apps built on Moltenship Time: a deterministic environment, typed builders and fixtures, a render and hydration harness, queries, and keyboard and pointer drivers.",
5
+ "keywords": [
6
+ "calendar",
7
+ "event-calendar",
8
+ "fixtures",
9
+ "react",
10
+ "temporal",
11
+ "test-utils",
12
+ "testing",
13
+ "typescript",
14
+ "vitest"
15
+ ],
5
16
  "homepage": "https://time.molten.sh/docs/testing",
6
17
  "bugs": {
7
18
  "url": "https://github.com/Moltenship/time/issues"
@@ -28,27 +39,30 @@
28
39
  "access": "public"
29
40
  },
30
41
  "dependencies": {
31
- "@moltenship/calendar": "1.0.0-rc.1",
32
- "@moltenship/calendar-recurrence": "1.0.0-rc.1"
42
+ "@moltenship/calendar": "2.0.0-beta.1",
43
+ "@moltenship/calendar-recurrence": "2.0.0-beta.1"
33
44
  },
34
45
  "devDependencies": {
35
46
  "@types/react": "19.3.0",
36
47
  "@types/react-dom": "19.3.0",
37
- "happy-dom": "20.14.5",
38
- "jsdom": "30.1.2",
39
- "react": "19.3.0",
40
- "react-dom": "19.3.0",
48
+ "@ui-sdk/core": "0.1.0-beta.16",
49
+ "@ui-sdk/react": "0.1.0-beta.16",
50
+ "happy-dom": "21.0.4",
51
+ "jsdom": "30.1.3",
52
+ "react": "19.3.1",
53
+ "react-dom": "19.3.1",
41
54
  "typescript": "^7.0.2",
42
- "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
43
- "vite-plus": "1.1.0"
55
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
56
+ "vite-plus": "1.4.0"
44
57
  },
45
58
  "peerDependencies": {
59
+ "@ui-sdk/core": "^0.1.0-beta.16",
60
+ "@ui-sdk/react": "^0.1.0-beta.16",
46
61
  "react": "^19.0.0",
47
62
  "react-dom": "^19.0.0"
48
63
  },
49
64
  "scripts": {
50
65
  "build": "vp pack",
51
- "check": "vp check",
52
66
  "dev": "vp pack --watch",
53
67
  "test": "vp test"
54
68
  }