Skip to content

Commit a38c0bf

Browse files
committed
perf(tests): move DOM-free jsdom suites to the node environment
Audited the 229 test files declaring @vitest-environment jsdom. 217 need a real DOM (React rendering, TipTap/ProseMirror, window/document/localStorage, DOMParser, ProgressEvent) and stay on jsdom; 12 exercise pure logic (yjs collab-doc conversion, http tool URL building, panel editor store, log utils, attachment upload, headless TipTap table commands, terminal-session tooltip helpers) and now run on node, skipping the jsdom boot. Dropped one redundant test in apply-streamed-markdown.test.ts: the hand-rolled one-shot peer case is a strict subset of the NON-OVERLAPPING two-peer test in apply-streamed-markdown.concurrent.test.ts, which also asserts CRDT convergence and exactly-once survival of the peer edit.
1 parent a7e42cc commit a38c0bf

12 files changed

Lines changed: 11 additions & 46 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/code-languages.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*
44
* Guards against drift between the code-block language picker and the Prism grammars actually
55
* registered by CodeBlockHighlight: every selectable language must have a registered grammar, or it

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/apply-streamed-markdown.test.ts‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -157,41 +157,6 @@ describe('agent-stream applier', () => {
157157
expect(freshText).toContain('Gamma paragraph')
158158
})
159159

160-
it('preserves a concurrent peer edit to a region the agent snapshot does not include', () => {
161-
// This is the core "AI as a CRDT peer" guarantee: the agent relays only its OWN delta (computed
162-
// against a private shadow), never a whole-document reconcile that would revert a peer's edit.
163-
const { editor, doc } = track(makeCollabEditor())
164-
165-
const session = beginAgentStream(editor)!
166-
applyAgentStreamFrame(editor, session, 'Alpha paragraph.\n\nBeta paragraph.')
167-
168-
// A peer edits the FIRST paragraph directly on the shared doc — the agent's later snapshot still
169-
// carries the ORIGINAL first paragraph (it was built from the base, before this edit).
170-
const peer = new Y.Doc()
171-
Y.applyUpdate(peer, Y.encodeStateAsUpdate(doc))
172-
const peerFrag = peer.getXmlFragment('default')
173-
peer.transact(() => {
174-
const firstPara = peerFrag.get(0) as Y.XmlElement
175-
const textNode = firstPara.get(0) as Y.XmlText
176-
textNode.insert(textNode.toString().length, ' EDITED')
177-
})
178-
Y.applyUpdate(doc, Y.encodeStateAsUpdate(peer, Y.encodeStateVector(doc)))
179-
peer.destroy()
180-
181-
// The agent appends a third paragraph. Its snapshot's first paragraph is the stale original, but the
182-
// shadow-relayed delta only inserts the new paragraph — so the peer's " EDITED" must survive.
183-
applyAgentStreamFrame(
184-
editor,
185-
session,
186-
'Alpha paragraph.\n\nBeta paragraph.\n\nGamma paragraph.'
187-
)
188-
endAgentStream(session)
189-
190-
const live = doc.getXmlFragment('default').toString()
191-
expect(live).toContain('EDITED')
192-
expect(live).toContain('Gamma paragraph')
193-
})
194-
195160
it('reuses cached binding metadata across frames, still emitting minimal per-frame deltas', () => {
196161
// The binding `meta` is built ONCE (first frame) and reused — `updateYFragment` maintains it in place,
197162
// so we skip an O(doc) `initProseMirrorDoc` rebuild per frame. This guards that caching preserves the

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image-drag-move.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*
44
* Dragging an image to reposition it inside a document must MOVE it, not import it again.
55
*

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { describe, expect, it } from 'vitest'
55
import {

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44

55
import { resolveDesktopZoom } from '@sim/desktop-bridge'

‎apps/sim/app/workspace/[workspaceId]/logs/utils.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { describe, expect, it } from 'vitest'
55
import { resolveLogWorkflowId, workflowEditorPath } from './utils'

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-attachment-upload.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { beforeEach, describe, expect, it, vi } from 'vitest'
55

‎apps/sim/lib/collab-doc/merge.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { FILE_DOC_SEED } from '@sim/realtime-protocol/file-doc'
55
import { describe, expect, it } from 'vitest'

‎apps/sim/lib/collab-doc/persist.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { beforeEach, describe, expect, it, vi } from 'vitest'
55
import * as Y from 'yjs'

‎apps/sim/lib/collab-doc/seed.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @vitest-environment jsdom
2+
* @vitest-environment node
33
*/
44
import { FILE_DOC_SEED } from '@sim/realtime-protocol/file-doc'
55
import { getSchema } from '@tiptap/core'

0 commit comments

Comments
 (0)