uttrflow / uttrflow/uttrflow-swift

Test that the clipboard watcher keeps a copy that has only HTML on the pasteboard, using its plain form

Open Beginner friendly
#741 0 comments 0 reactions 0 assignees View on GitHub
area:clipboard enhancement good first issue P2
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## What happens

`Sources/UttrflowClipboard/PasteboardWatcher.swift:120`: when a copy has no plain-text flavour but does have HTML (some web editors and mail composers put only HTML on the pasteboard), `newClip(at:)` derives the text with `RichTextPlainForm.plainText(fromHTML:)`. That `html.map(...)` has never run. Every watcher test writes plain text, either alone or next to HTML.

Also never run: `NoticedClip ==` comparing two clips' pictures (lines 190-193).

Measured on origin/main `26d7bc1` with `swift test --enable-code-coverage` (5,384 tests, all passing) and `xcrun llvm-cov export` over the test binary. The regions named below have an execution count of 0: no test runs them, so a change that breaks them passes `make verify`.

## Why it matters

Without this branch, copying from an HTML-only source records nothing, and the user's copy is missing from clipboard history with no explanation.

## How to reproduce

Run `swift test --enable-code-coverage`, then `xcrun llvm-cov show -instr-profile .build/debug/codecov/default.profdata .build/debug/UttrflowPackageTests.xctest/Contents/MacOS/UttrflowPackageTests Sources/UttrflowClipboard/PasteboardWatcher.swift` and look for the `0` counts on the lines named above.

## Acceptance criteria

- A test calls `clipboard.write(nil, html: "

Hello world

")`. `newClip(at:)` should return a clip whose `text` is "Hello world" and whose rich text is kept.
- A test writes HTML-only content that is blank once plain (`

`) and expects `nil`.
- Two `NoticedClip` values with the same clip but pictures of different sizes are not equal.
- Each new test fails when the branch it covers is broken. Check this by hand before opening the PR: temporarily change the branch (flip the condition or return the other value), see the test fail, then restore it.

## Where to start

- `Tests/UttrflowClipboardTests/PasteboardWatcherTests.swift`. `FakeClipboard.write(_:html:picture:from:marked:)` already accepts `nil` text.

Read `CONTRIBUTING.md` first. Iterate with `swift test --filter `, then run `make verify` before pushing. Only tests change; no product code needs to.

**Size:** S, under an hour.

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md, then open Tests/UttrflowClipboardTests/PasteboardWatcherTests.swift and use FakeClipboard.write(_:html:picture:from:marked:). Add coverage for HTML-only plain-text extraction, blank HTML, and NoticedClip picture equality; run the filtered suite and make verify. Done means each test fails when its covered branch is temporarily broken.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift
Domain
desktop, testing
Issue type
Bug
Difficulty
2/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.