Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor: clean up LGraphCanvas.cloneZIndex.test.ts (follow-up from #10361)
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Follow-up cleanup for `LGraphCanvas.cloneZIndex.test.ts`
Tracked from review comments in #10361.
### 1. Move describe-level mutable state into individual `it` blocks
**Comment by DrJKL:** [link](https://github.com/Comfy-Org/ComfyUI_frontend/pull/10361#discussion_r3047062466)
The `graph`, `canvas`, and `previousVueNodesMode` variables are declared at `describe` scope and mutated in `beforeEach`. DrJKL flagged this as a cross-test contamination risk even with two tests — each `it` block should instantiate its own local variables rather than sharing mutable describe-level state.
### 2. Extract `createCanvas` into a shared test utility
**Comment by DrJKL:** [link](https://github.com/Comfy-Org/ComfyUI_frontend/pull/10361#discussion_r3019705055)
The `createCanvas` helper in this test file is duplicated from `LGraphCanvas.groupSelection.test.ts`. It should be extracted into a shared test utility to avoid copy-paste drift.
### 3. Replace or improve the bespoke `TestNode` class
**Comment by DrJKL:** [link](https://github.com/Comfy-Org/ComfyUI_frontend/pull/10361#discussion_r3047072468)
A custom `TestNode` class is defined inline for the test. Prefer either:
- Using a real registered node type instead of a bespoke class, or
- If `TestNode` is kept, update its constructor to accept all setup options (position, size) directly so post-instantiation mutation is not required.
### 4. Remove unnecessary type casts
**Comment by DrJKL:** [link](https://github.com/Comfy-Org/ComfyUI_frontend/pull/10361#discussion_r3047075122)
The cloned nodes are cast as `as LGraphNode` in the test assertions. These casts should either be removed if the types are already correct, or the reason should be documented if they are genuinely needed.
---
Backlink: PR #10361 (https://github.com/Comfy-Org/ComfyUI_frontend/pull/10361)
Requested by: @dante01yoon
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11169-refactor-clean-up-LGraphCanvas-cloneZIndex-test-ts-follow-up-from-10361-33f6d73d36508103bbfcf6261dffe704) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.