Skip to content

test(tools): cover NotebookEdit cell-type switching, id collisions and unknown ids - #3377

Merged
Yeachan-Heo merged 1 commit into
ultraworkers:mainfrom
rohanb123:tests/test-tools-cover-notebookedit-cell-type
Nov 6, 2026
Merged

Yeachan-Heo merged 1 commit into
ultraworkers:mainfrom
rohanb123:tests/test-tools-cover-notebookedit-cell-type

Conversation

@rohanb123

Copy link
Copy Markdown
Contributor

Summary

  • Adds notebook_edit_replace_switches_cell_type_and_rejects_unknown_ids in rust/crates/tools/src/lib.rs, covering NotebookEdit paths that existing tests don't exercise:
    • default replace (no edit_mode, no cell_type) keeps the target cell's markdown type, and language falls back to python when the notebook has no kernelspec;
    • replacing a markdown cell with cell_type: "code" adds outputs: [] and execution_count: null;
    • inserting into a notebook whose existing cell is already named cell-2 returns cell-3, which exercises the collision-skipping make_cell_id from fix(tools): stop NotebookEdit reusing cell ids after a delete #3371 without a delete;
    • an unknown cell_id fails with Cell id not found: missing and leaves the notebook file byte-for-byte unchanged.
  • Test-only change. No behavior, CLI output, or schema changes.

Anti-slop triage

  • Classification: actionable-fix (test coverage only)
  • Evidence: new test exercises existing code paths in execute_notebook_edit, resolve_cell_index, and make_cell_id
  • Non-destructive review result: merge candidate

Verification

Ran in a clean rust:1 container:

# setup
rustup component add rustfmt && cd rust && cargo fetch --locked
# test
cd rust && cargo fmt -p tools --check && cargo test --locked -p tools --lib notebook_edit

Result: passed (exit 0). cargo fmt -p tools --check reported no formatting issues, and all 3 notebook_edit unit tests passed:

test tests::notebook_edit_rejects_invalid_inputs ... ok
test tests::notebook_edit_replace_switches_cell_type_and_rejects_unknown_ids ... ok
test tests::notebook_edit_replaces_inserts_and_deletes_cells ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 118 filtered out
  • Targeted tests/docs checks ran, or the gap is explicitly recorded.
  • git diff --check passes.
  • No live secrets, tokens, private logs, or unrelated generated churn are included.

Resolution gate

  • If this PR resolves an issue, the issue number and fix evidence are linked. (N/A: coverage follow-up to fix(tools): stop NotebookEdit reusing cell ids after a delete #3371)
  • If this PR should not merge, the rejection/defer rationale is evidence-backed and does not rely on vibes.
  • I did not merge/close remote PRs or issues from an automation lane without owner approval.

AI assistance: this change was prepared with Claude Code.

…d unknown ids

Co-Authored-By: Claude <noreply@anthropic.com>

@Yeachan-Heo Yeachan-Heo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

✅ Test Quality: The new test exercised real behavior with concrete assertions:

  • Cell-type switching: verifies replace can convert markdown → code, and preserves type when unspecified
  • ID collision handling: inserts new cell after cell-2 exists, verifies auto-ID generates cell-3 (avoids collision)
  • Error handling: tries unknown cell ID, confirms error message and file unchanged
  • Deterministic: uses temp_path() and cleanup; no flaky temp file issues

✅ No Duplication: Existing notebook_edit_replaces_inserts_and_deletes_cells test covers the broad workflow but doesn't explicitly test type switching in replace mode or error handling for unknown IDs. This test fills that gap.

✅ All Checks Pass:

  • cargo fmt: ✓ no formatting issues
  • cargo clippy -p tools: ✓ no warnings (all-targets, -D warnings)
  • cargo test -p tools notebook_edit: ✓ all 3 notebook_edit tests pass

—
repo owner's gaebal-gajae 🦞

@Yeachan-Heo
Yeachan-Heo merged commit ca48ec7 into ultraworkers:main Nov 6, 2026
6 checks passed
@rohanb123
rohanb123 deleted the tests/test-tools-cover-notebookedit-cell-type branch November 7, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants