Skip to content

test(datagrid): restore the shared clipboard after every test that installs one - #3165

Merged
datlechin merged 1 commit into
mainfrom
fix/clipboard-test-isolation
Sep 27, 2026
Merged

datlechin merged 1 commit into
mainfrom
fix/clipboard-test-isolation

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

main has failed Unit tests since #3160 (29ed299). Every PR that merges main in inherits the failure: #3150, #3153, #3154, #3155 and #3161 are red on it now.

The failing suite is RowOperationsManagerBinaryCopyTests, where every copy reads back as "".

Cause

ClipboardService.shared is process-wide, and 15 test installs in three files replaced it without putting the real provider back:

The one #3160 added installs a fake whose writeText does nothing, and the suite runs before RowOperationsManagerBinaryCopyTests. That suite asserted on NSPasteboard.general. With the fake still installed, the copy never reached the system pasteboard, so all five expectations read an empty string.

Reading NSPasteboard.general in a test is its own defect: the system pasteboard is not reliable on a headless runner.

Changes

  • Every unrestored install now has defer { ClipboardService.shared = NSPasteboardClipboardProvider() }, the shape the other suites already use.
  • RowOperationsManagerBinaryCopyTests installs a capturing clipboard for each copy and asserts on the TSV it received, never on the system pasteboard.
  • ClipboardInstallGuardTests scans TableProTests and fails on any ClipboardService.shared = … without a restoring defer within three lines. Run against main's test tree, it names exactly the 15 sites above.

Tests only. No app code changes, so no CHANGELOG entry.

Testing

  • verify.sh test with every suite that touches ClipboardService.shared plus the source-scan guard suites: 273 executed, 273 passed.
  • Confirmed the rewritten binary-copy tests, copyWritesAbsence and the new guard ran by name in the log.
  • swiftlint lint --strict on the five files: 0 violations.

@datlechin
datlechin merged commit 6111ba2 into main Sep 27, 2026
13 checks passed
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.

1 participant