test: cover viewport-aware paste positioning#699
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@k08200 is attempting to deploy a commit to the Grida Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR introduces a dedicated test suite for the document reducer's paste positioning functionality. The tests verify that pasted items are correctly positioned at viewport-centered coordinates and linked appropriately when pasting to both scene and container targets. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
editor/grida-canvas/reducers/__tests__/paste-position.test.ts (1)
74-82: Type the paste helper against the paste action contract (avoidas DocumentAction).The
targetparameter is typed asstring, butEditorPasteActionrequirestarget: NodeID | NodeID[]. Theas DocumentActioncast bypasses this validation and hides potential action-shape regressions.Proposed change
+type PasteAction = Extract<DocumentAction, { type: "paste" }>; + function paste( state: editor.state.IEditorState, - target: string + target: PasteAction["target"] ): editor.state.IEditorState { let id = 0; + const action: PasteAction = { type: "paste", target }; return documentReducer( state, - { type: "paste", target } as DocumentAction, + action, createReducerContext({ viewport: VIEWPORT, idgen: {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@editor/grida-canvas/reducers/__tests__/paste-position.test.ts` around lines 74 - 82, The paste helper is currently typed with target: string and casts the action to DocumentAction, bypassing the EditorPasteAction shape; update the paste function signature to accept target: NodeID | NodeID[] (the same type required by EditorPasteAction) and construct the action using that precise type (e.g., create an object matching EditorPasteAction or cast to EditorPasteAction instead of DocumentAction) before passing it to documentReducer; ensure imports/reference to EditorPasteAction and NodeID are used so the compiler enforces the correct action shape and remove the unsafe `as DocumentAction` cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@editor/grida-canvas/reducers/__tests__/paste-position.test.ts`:
- Around line 74-82: The paste helper is currently typed with target: string and
casts the action to DocumentAction, bypassing the EditorPasteAction shape;
update the paste function signature to accept target: NodeID | NodeID[] (the
same type required by EditorPasteAction) and construct the action using that
precise type (e.g., create an object matching EditorPasteAction or cast to
EditorPasteAction instead of DocumentAction) before passing it to
documentReducer; ensure imports/reference to EditorPasteAction and NodeID are
used so the compiler enforces the correct action shape and remove the unsafe `as
DocumentAction` cast.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f2c3dee2-5923-4a19-98c8-7a0771319b82
📒 Files selected for processing (1)
editor/grida-canvas/reducers/__tests__/paste-position.test.ts
|
Behavior verification update: I also exercised the actual editor API flow ( |
default.movis it right? |
Summary
Verification
Closes #368
Summary by CodeRabbit