From 91e70d108e0f9c9cfb5f7cd1c7e205e66c8bdf65 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 27 Aug 2026 22:02:21 +0000 Subject: [PATCH] test(format): lock DATE+N offsets from issue 1704 Issue #1704 reported {{DATE:YYYY-MM-DD+3}} concatenating +3 and {{DATE+3}} left unparsed. The formatter already applies the offset (including case-insensitive date tokens). Assert the documented examples so concatenation cannot regress silently. Co-authored-by: Christian Bager Bach Houmann --- .../formatSyntax.docs-examples.test.ts | 11 +++++++++++ src/formatters/formatter-datesnap.test.ts | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/formatters/formatSyntax.docs-examples.test.ts b/src/formatters/formatSyntax.docs-examples.test.ts index c5ccd058..a591f3f2 100644 --- a/src/formatters/formatSyntax.docs-examples.test.ts +++ b/src/formatters/formatSyntax.docs-examples.test.ts @@ -297,6 +297,17 @@ describe("Format Syntax documentation examples", () => { } }); + it("applies documented DATE +N day offsets instead of concatenating them", async () => { + const formatter = new DocsExampleFormatter(); + + await expect(formatter.render("Review on {{DATE+7}}")).resolves.toBe( + "Review on 2026-05-14", + ); + await expect(formatter.render("{{DATE:YYYY-MM-DD+3}}")).resolves.toBe( + "2026-05-10", + ); + }); + it("collects requirements from the current and 2.12.0 examples", async () => { for (const example of CURRENT_AND_2120_EXAMPLES) { const collector = new RequirementCollector(makeApp(), makePlugin()); diff --git a/src/formatters/formatter-datesnap.test.ts b/src/formatters/formatter-datesnap.test.ts index eebb3590..704c29f9 100644 --- a/src/formatters/formatter-datesnap.test.ts +++ b/src/formatters/formatter-datesnap.test.ts @@ -111,6 +111,23 @@ describe("{{DATE}} snap through replaceDateInString", () => { expect(f.renderDate("{{DATE:YYYY-MM-DD+7|startof:week}}")).toBe("2023-06-04"); }); + it("renders the documented +N day offsets from issue #1704", () => { + expect(f.renderDate("{{DATE}}")).toBe("2023-06-01"); + expect(f.renderDate("{{DATE:YYYY-MM-DD}}")).toBe("2023-06-01"); + expect(f.renderDate("{{DATE+3}}")).toBe("2023-06-04"); + expect(f.renderDate("{{DATE:YYYY-MM-DD+3}}")).toBe("2023-06-04"); + expect(f.renderDate("{{DATE+-3}}")).toBe("2023-05-29"); + // DATE_REGEX is case-insensitive; lowercase must not fall through to + // Moment as a format suffix (the 2026-08-26+3 concatenation symptom). + expect(f.renderDate("{{date+3}}")).toBe("2023-06-04"); + expect(f.renderDate("{{date:YYYY-MM-DD+3}}")).toBe("2023-06-04"); + expect( + f.renderDate( + "# works\n{{DATE:YYYY-MM-DD}}\n\n{{DATE}}\n\n# buggy\n{{DATE:YYYY-MM-DD+3}}\n\n{{DATE+3}}\n", + ), + ).toBe("# works\n2023-06-01\n\n2023-06-01\n\n# buggy\n2023-06-04\n\n2023-06-04\n"); + }); + it("keeps a literal pipe byte-identical and a [literal |startof: x] intact", () => { expect(f.renderDate("{{DATE:YYYY|MM}}")).toBe("2023|06"); expect(