Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Both errors exit with status 2.
`vt_snapshot`. The fixture is also available when the project explicitly
loads the Syrupy and libvt plugin modules in `conftest.py`.

### Documentation

#### Assert effective colors alongside screen goldens (#190)

The {doc}`/topics/testing` guide shows how to resolve a cell's color
against the palette in its committed snapshot.

### Development

#### Design review and issue skills (#155)
Expand Down
31 changes: 31 additions & 0 deletions docs/topics/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,37 @@ styles:
r0[6..10]: fg=#ff8c00
```

### Assert a palette change

A boxed golden records the cell's color token, such as `fg=red`. To test
a theme change, read the cell and its palette from the same committed
{class}`~libvt.terminal.Snapshot`. {meth}`~libvt.style.Appearance.resolve_rgb`
returns the color that the palette assigns to that token.

```python
>>> from libvt import Snapshot, Terminal
>>> from libvt.testing import serialize_vt_snapshot
>>> def foreground(frame: Snapshot) -> tuple[int, int, int]:
... return frame.appearance.resolve_rgb(
... frame[0, 0].style.fg, default_rgb=frame.appearance.fg_rgb
... )
>>> term = Terminal(rows=1, cols=5)
>>> term.feed(b"\x1b[31mBOARD")
>>> original = term.committed
>>> term.feed(b"\x1b]4;1;#16b3cd\x07")
>>> themed = term.committed
>>> serialize_vt_snapshot(themed) == serialize_vt_snapshot(original)
True
>>> foreground(original), foreground(themed)
((205, 0, 0), (22, 179, 205))
>>> term.feed(b"\x1b]104;1\x07")
>>> foreground(term.committed) == foreground(original)
True
```

For a default-color change, assert `frame.appearance.fg_rgb` or
`frame.appearance.bg_rgb` directly.

### Scrubbing dynamic values without breaking box borders

Naive string replacement shifts right-hand `│` borders whenever a PID, port, or
Expand Down
Loading