From c877a81efe8268cca42afdb3a6155ec2f913c885 Mon Sep 17 00:00:00 2001 From: KM Koushik Date: Mon, 16 Nov 2026 11:35:52 +1100 Subject: [PATCH] test: fail when the email editor would load two copies of a ProseMirror core package --- apps/web/src/editor-dependencies.unit.test.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 apps/web/src/editor-dependencies.unit.test.ts diff --git a/apps/web/src/editor-dependencies.unit.test.ts b/apps/web/src/editor-dependencies.unit.test.ts new file mode 100644 index 00000000..2c79c382 --- /dev/null +++ b/apps/web/src/editor-dependencies.unit.test.ts @@ -0,0 +1,30 @@ +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; +import { describe, expect, it } from "vitest"; + +/** + * The email editor (Tiptap/ProseMirror) breaks if two copies of a ProseMirror + * core package end up in the bundle: typing moves the cursor but no text is + * added, and the browser logs "looks like multiple versions of prosemirror-model + * were loaded". That happened from Oct 26 to Nov 16 2026, when an override bumped + * prosemirror-view, whose copy of prosemirror-model then differed from @tiptap/pm's. + * + * If this fails after a dependency change, make every package below resolve to one + * version, e.g. by upgrading @tiptap/* or adding a matching pnpm override. + */ +const SINGLE_COPY = ["prosemirror-model", "prosemirror-state", "prosemirror-transform", "prosemirror-view"]; + +function lockfileVersions(lockfile: string, name: string) { + const packages = lockfile.slice(lockfile.indexOf("\npackages:\n"), lockfile.indexOf("\nsnapshots:\n")); + const escaped = name.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&"); + const pattern = new RegExp(`^ '?${escaped}@([^:'(]+)'?:`, "gm"); + return [...packages.matchAll(pattern)].map((match) => match[1]); +} + +describe("email editor dependencies", () => { + const lockfile = readFileSync(resolve(__dirname, "../../../pnpm-lock.yaml"), "utf8"); + + it.each(SINGLE_COPY)("installs exactly one version of %s", (name) => { + expect(lockfileVersions(lockfile, name)).toHaveLength(1); + }); +});