|
9 | 9 | // dynamically `import()` it, then call the real `safeParse`/`parse` on the |
10 | 10 | // real Zod object it exports — not a string match. |
11 | 11 | // |
12 | | -// Covers the three Criticals + Important 5 found by that review, plus a |
13 | | -// codegen-time WARNING for Important 4 (added on top after the initial fix |
14 | | -// was reviewed clean — a cheap generation-time detect for the one runtime gap |
15 | | -// left documented-not-fixed: filtering a date-mode timestamp throws at |
16 | | -// request time; see runGen's warning + filter-parser.ts's limitation note): |
| 12 | +// Covers the three Criticals + Important 5 found by that review. Important 4 |
| 13 | +// (filtering a date-mode timestamp threw at request time) was originally shipped |
| 14 | +// as a generation-time WARNING because the runtime fix was deferred; that fix has |
| 15 | +// since landed — the generated allowlist carries `dateValues` and runtime-ts's |
| 16 | +// parser coerces with `new Date(...)` — so the warning was removed and the last |
| 17 | +// describe block below now pins its ABSENCE. The behavioral pins for the fix |
| 18 | +// itself live in runtime-ts's filter-parser-date-mode test and in |
| 19 | +// templates/filter-allowlist.test.ts. |
17 | 20 | // CRITICAL 1 — z.date() rejects every JSON wire value; fix is z.coerce.date(). |
18 | 21 | // CRITICAL 2 — sqlite/D1 + date mode used to emit non-compiling code (a |
19 | 22 | // regression #281 itself introduced); fix normalizes the mode |
@@ -269,27 +272,19 @@ describe('IMPORTANT 4: runGen warns (once) when timestampMode: "date" meets a @f |
269 | 272 | } |
270 | 273 | } |
271 | 274 |
|
272 | | - test('warns exactly once, naming every offending entity+field, when dialect:"postgres" + timestampMode:"date"', async () => { |
273 | | - const { warnings } = await runWithMetadata(TWO_FILTERABLE_TIMESTAMPS, "postgres", "date"); |
274 | | - const hits = warnings.filter((w) => w.includes('timestampMode: "date"')); |
275 | | - expect(hits.length).toBe(1); // once per run, not once per field/entity |
276 | | - expect(hits[0]).toContain("Post.updatedAt"); |
277 | | - expect(hits[0]).toContain("Comment.postedAt"); |
278 | | - expect(hits[0]).not.toContain("archivedAt"); // non-filterable — not named |
279 | | - }); |
280 | | - |
281 | | - test('silent in the default "string" mode (timestampMode omitted)', async () => { |
282 | | - const { warnings } = await runWithMetadata(TWO_FILTERABLE_TIMESTAMPS, "postgres"); |
283 | | - expect(warnings.filter((w) => w.includes('timestampMode: "date"'))).toEqual([]); |
284 | | - }); |
285 | | - |
286 | | - test('silent when no field is both @filterable and a timestamp, even in date mode', async () => { |
287 | | - const { warnings } = await runWithMetadata(NO_FILTERABLE_TIMESTAMP, "postgres", "date"); |
288 | | - expect(warnings.filter((w) => w.includes('timestampMode: "date"'))).toEqual([]); |
289 | | - }); |
290 | | - |
291 | | - test('silent under dialect:"sqlite" — timestampMode normalizes to "string" (Critical 2), so Important 4 never fires', async () => { |
292 | | - const { warnings } = await runWithMetadata(TWO_FILTERABLE_TIMESTAMPS, "sqlite", "date"); |
293 | | - expect(warnings.filter((w) => w.includes('timestampMode: "date"'))).toEqual([]); |
| 275 | + test("no warning is emitted in any mode — the limitation it announced is fixed", async () => { |
| 276 | + // The warning was correct while date-mode filtering threw at request time. Now |
| 277 | + // that the allowlist carries `dateValues` and the parser coerces, it would be |
| 278 | + // crying wolf, so it is gone. Pinned in all four combinations so a revert of |
| 279 | + // the fix cannot quietly re-land the warning instead of the behavior. |
| 280 | + for (const [json, dialect, mode] of [ |
| 281 | + [TWO_FILTERABLE_TIMESTAMPS, "postgres", "date"], |
| 282 | + [TWO_FILTERABLE_TIMESTAMPS, "postgres", undefined], |
| 283 | + [NO_FILTERABLE_TIMESTAMP, "postgres", "date"], |
| 284 | + [TWO_FILTERABLE_TIMESTAMPS, "sqlite", "date"], |
| 285 | + ] as const) { |
| 286 | + const { warnings } = await runWithMetadata(json, dialect, mode); |
| 287 | + expect(warnings.filter((w) => w.includes('timestampMode: "date"'))).toEqual([]); |
| 288 | + } |
294 | 289 | }); |
295 | 290 | }); |
0 commit comments