test(runner): the batched drop is one commit, and stays one (DEV-2500) - #199
Open
danielzytohoc wants to merge 1 commit into
Open
test(runner): the batched drop is one commit, and stays one (DEV-2500)#199danielzytohoc wants to merge 1 commit into
danielzytohoc wants to merge 1 commit into
Conversation
Closes audit gap G3 (DEV-2500 item h): the batched addFiles contract was untested. The ticket calls the batched onAddFiles necessary, not cosmetic — N sequential addFile calls would mean N setFiles renders and, on a Tier-2 framework, N container pushes each invalidating the last — yet until now that contract survived only as a code comment above addFiles. A regression to a per-file loop would have passed the whole suite: the multi-file drop e2e only checks that the rows appear. Three pieces: - The map transform moves out of App.tsx's addFiles into apps/authoring/src/addFiles.ts as applyDroppedFiles(current, dropped) — behavior-identical, dependency-free like demoOwners.ts and markdownActions.ts so the pipeline tests can import it under --experimental-strip-types. The empty-drop guard becomes "returns current reference-equal", which App.tsx compares against to skip the commit — the same early return as before, now observable. - pipeline/add-files.test.mjs pins the contract: one drop returns ONE new map with every file (input untouched), a colliding path overwrites in place (the FILES tree has already asked before the batch gets here), an empty drop returns the same map. - A source grep in the same spec slices addFiles out of App.tsx (balanced-paren scan, fragility noted honestly and hedged with sanity assertions) and holds it to the one-commit shape: setFiles exactly once, one filesRef assignment, the map built via applyDroppedFiles. Verified it bites: a second setFiles call fails the test. App.tsx keeps every side effect where it was: the ref commit, the render, the variadic markDirty, the per-file runtime writes, the container syncing feedback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes audit gap G3 (DEV-2500 item h): the batched
addFilescontract was untested.DEV-2500's ticket calls the batched
onAddFilesnecessary, not cosmetic: N sequentialaddFilecalls would mean NsetFilesrenders and, on a Tier-2 framework, N container pushes each invalidating the last. Until now that contract survived only as a code comment aboveaddFiles— a naive per-file loop would have passed the entire suite, because the multi-file drop e2e only checks that the rows appear.The extraction (behavior-identical)
The map transform moves out of
App.tsx'saddFilesintoapps/authoring/src/addFiles.tsasapplyDroppedFiles(current, dropped)— dependency-free likedemoOwners.tsandmarkdownActions.ts, so the pipeline tests can import it under--experimental-strip-types(its one import is type-only, which the stripper erases). The empty-drop guard becomes "returnscurrentreference-equal", whichApp.tsxcompares against to skip the commit — the same early return as before, now observable. Every side effect stays inApp.tsxwhere it was: the ref commit, the render, the variadicmarkDirty, the per-file runtime writes, the container syncing feedback.The new unit contract
pipeline/add-files.test.mjs(node --test,markdown-actions.test.mjsconventions):FileTree.commit()has already asked ("Overwrite" vs "Keep both") and "Keep both" renamed before the call; a collision arriving here means overwrite.The source guard
The same spec slices
addFilesout ofApp.tsx(balanced-paren scan; the fragility is noted honestly and hedged with sanity assertions that fail loudly if the scan breaks) and holds it to the one-commit shape:setFiles(exactly once, onefilesRef.currentassignment, the map built viaapplyDroppedFiles. Mutation-checked: temporarily adding a secondsetFiles(call insideaddFilesfails the test.Verification
pnpm typecheckgreen,pnpm testgreen (413 tests, 4 new)pnpm build+pnpm --filter @handsontable/demo-authoring buildgreenpnpm e2e e2e/files-drop.spec.ts— all 10 drop e2e tests passNote: this PR touches product code (the extraction in
App.tsx+ the newaddFiles.ts), not only tests — kept as its own PR per the repo owner's review preference.Note
Low Risk
Behavior-preserving refactor with new unit and source-structure tests; no API or auth changes.
Overview
Closes audit gap G3: the batched drag-and-drop path (
onAddFiles/ DEV-2500) was only documented in comments—N per-fileaddFilecalls would still pass e2e.The workspace map merge moves into
applyDroppedFilesinaddFiles.ts(pure, importable under pipeline tests).App.tsxaddFilesdelegates to it, skips commit when the result is reference-equal tofilesRef.current(empty drop), and still does onesetFiles, one ref assignment, dirty dots, runtime writes, and container syncing.pipeline/add-files.test.mjscovers the helper (one new map, overwrite on collision, empty → same reference) and grepsaddFilesinApp.tsxfor exactly onesetFilesand onefilesRefassignment viaapplyDroppedFiles.Reviewed by Cursor Bugbot for commit 6cb9eb8. Bugbot is set up for automated code reviews on this repo. Configure here.