envision 0.17.0

A ratatui framework for collaborative TUI development with headless testing support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
use super::*;

// Test row type (shared with tests.rs)
#[derive(Clone, Debug, PartialEq)]
struct TestRow {
    name: String,
    value: String,
}

impl TestRow {
    fn new(name: &str, value: &str) -> Self {
        Self {
            name: name.into(),
            value: value.into(),
        }
    }
}

impl TableRow for TestRow {
    fn cells(&self) -> Vec<crate::component::cell::Cell> {
        use crate::component::cell::Cell;
        vec![Cell::new(&self.name), Cell::new(&self.value)]
    }
}

fn test_columns() -> Vec<Column> {
    vec![
        Column::new("Name", Constraint::Length(10)).sortable(),
        Column::new("Value", Constraint::Length(10)).sortable(),
    ]
}

fn test_rows() -> Vec<TestRow> {
    vec![
        TestRow::new("Charlie", "30"),
        TestRow::new("Alice", "10"),
        TestRow::new("Bob", "20"),
    ]
}

#[test]
fn test_view_renders() {
    let state = TableState::new(test_rows(), test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_with_header() {
    let state = TableState::new(test_rows(), test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_with_sort_indicator() {
    let mut state = TableState::new(test_rows(), test_columns());
    Table::<TestRow>::update(&mut state, TableMessage::SortAsc(0));

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_focused() {
    let state = TableState::new(test_rows(), test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(
                &state,
                &mut RenderContext::new(frame, frame.area(), &theme).focused(true),
            );
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}
#[test]
fn test_view_empty() {
    let state: TableState<TestRow> = TableState::new(vec![], test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_descending_sort_indicator() {
    let mut state = TableState::new(test_rows(), test_columns());
    // Set descending sort directly
    Table::<TestRow>::update(&mut state, TableMessage::SortDesc(0));

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_unfocused() {
    let state = TableState::new(test_rows(), test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn test_view_multi_column_sort_indicators() {
    let mut state = TableState::new(test_rows(), test_columns());
    // Sort by name ascending (primary), then add value ascending (secondary)
    Table::<TestRow>::update(&mut state, TableMessage::SortAsc(0));
    Table::<TestRow>::update(&mut state, TableMessage::AddSortAsc(1));

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

// =====================================================================
// Phase 3 Task B: Render snapshot tests for Phase 2 features.
// =====================================================================
//
// These tests pin the rendered visual output of features added in Phase 2:
//   #10  Status column visibility (rendered iff any row is non-None).
//   #11  Per-cell `CellStyle` propagation (Default/Success/Warning/Error/
//        Muted/Custom + a mixed-styles row).
//   #8   Sort indicator visibility (appears on Sort{Asc,Desc,Toggle},
//        disappears on `SortClear`).
//   #15b Render-layer half of `sort_toggle_arrow_persists_on_repeated_press`
//        — the arrow character must remain present in the header row across
//        repeated `SortToggle` dispatches.

// ---------- #10: status column visibility ----------

/// Row type whose status is governed by a per-instance field, so individual
/// fixture rows can opt into a non-`None` row status without us having to
/// invent a fresh `TableRow` impl per test.
#[derive(Clone, Debug)]
struct StatusRow {
    name: String,
    value: String,
    status: crate::component::cell::RowStatus,
}

impl StatusRow {
    fn new(name: &str, value: &str, status: crate::component::cell::RowStatus) -> Self {
        Self {
            name: name.into(),
            value: value.into(),
            status,
        }
    }
}

impl TableRow for StatusRow {
    fn cells(&self) -> Vec<crate::component::cell::Cell> {
        use crate::component::cell::Cell;
        vec![Cell::new(&self.name), Cell::new(&self.value)]
    }

    fn status(&self) -> crate::component::cell::RowStatus {
        self.status.clone()
    }
}

fn status_columns() -> Vec<Column> {
    vec![
        Column::new("Name", Constraint::Length(10)).sortable(),
        Column::new("Value", Constraint::Length(10)).sortable(),
    ]
}

#[test]
fn snapshot_table_no_status_column_when_all_rows_status_none() {
    use crate::component::cell::RowStatus;

    // Every row returns `RowStatus::None` ⇒ no status column should render.
    // Layout must match the no-status-column variant exactly.
    let rows = vec![
        StatusRow::new("Alice", "10", RowStatus::None),
        StatusRow::new("Bob", "20", RowStatus::None),
        StatusRow::new("Carol", "30", RowStatus::None),
    ];
    let state = TableState::new(rows, status_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<StatusRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

#[test]
fn snapshot_table_renders_status_column_when_any_row_non_none() {
    use crate::component::cell::RowStatus;

    // Mixed: one Healthy, one Warning, one None. The status column must
    // appear for ALL rows (with an empty cell for the None row).
    let rows = vec![
        StatusRow::new("Alice", "10", RowStatus::Healthy),
        StatusRow::new("Bob", "20", RowStatus::Warning),
        StatusRow::new("Carol", "30", RowStatus::None),
    ];
    let state = TableState::new(rows, status_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<StatusRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    insta::assert_snapshot!(terminal.backend().to_string());
}

// ---------- #11: per-cell `CellStyle` ----------

/// A row carrying a single user-supplied `Cell` so each per-style snapshot
/// test can construct exactly the styled cell it wants without inventing a
/// new `TableRow` impl per variant.
#[derive(Clone, Debug)]
struct StyledRow {
    cells: Vec<crate::component::cell::Cell>,
}

impl TableRow for StyledRow {
    fn cells(&self) -> Vec<crate::component::cell::Cell> {
        self.cells.clone()
    }
}

fn styled_columns() -> Vec<Column> {
    vec![
        Column::new("Name", Constraint::Length(10)).sortable(),
        Column::new("Value", Constraint::Length(10)).sortable(),
    ]
}

/// Renders a single-row table containing the given pre-built cells and
/// returns both the plain-text output (for snapshotting) and the ANSI
/// output (for color-level assertions). Centralizes the per-style
/// boilerplate.
///
/// Selection is explicitly cleared via `set_selected_index(None)` because
/// ratatui's row-highlight style overrides per-cell fg colors on the
/// selected row — leaving the default `Some(0)` selection in place would
/// mask the very styling these tests are meant to pin.
///
/// Plain text alone cannot distinguish a `Cell::success` from a
/// `Cell::warning` because color is stripped — the ANSI string is the
/// only place where the per-cell style is observable in test output.
fn render_styled_single_row(cells: Vec<crate::component::cell::Cell>) -> (String, String) {
    let mut state = TableState::new(vec![StyledRow { cells }], styled_columns());
    state.set_selected_index(None);

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<StyledRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    let plain = terminal.backend().to_string();
    let ansi = terminal.backend().to_ansi();
    (plain, ansi)
}

#[test]
fn snapshot_table_cells_with_default_style() {
    use crate::component::cell::Cell;

    // Baseline — no style overrides. Compared against the styled variants
    // below to confirm the layout is invariant under per-cell styling.
    let cells = vec![Cell::new("alpha"), Cell::new("beta")];
    let (plain, _ansi) = render_styled_single_row(cells);
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_with_success_style() {
    use crate::component::cell::Cell;

    let cells = vec![Cell::success("alpha"), Cell::new("beta")];
    let (plain, ansi) = render_styled_single_row(cells);
    // Plain-text snapshot pins layout; ANSI assertion pins the green color
    // applied by `CellStyle::Success` (default theme: success = green).
    assert!(
        ansi.contains("\x1b[32m"),
        "expected green ANSI fg for Success-styled cell, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_with_warning_style() {
    use crate::component::cell::Cell;

    let cells = vec![Cell::warning("alpha"), Cell::new("beta")];
    let (plain, ansi) = render_styled_single_row(cells);
    // Default theme: warning = yellow.
    assert!(
        ansi.contains("\x1b[33m"),
        "expected yellow ANSI fg for Warning-styled cell, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_with_error_style() {
    use crate::component::cell::Cell;

    let cells = vec![Cell::error("alpha"), Cell::new("beta")];
    let (plain, ansi) = render_styled_single_row(cells);
    // Default theme: error = red.
    assert!(
        ansi.contains("\x1b[31m"),
        "expected red ANSI fg for Error-styled cell, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_with_muted_style() {
    use crate::component::cell::Cell;

    let cells = vec![Cell::muted("alpha"), Cell::new("beta")];
    let (plain, ansi) = render_styled_single_row(cells);
    // Muted is hardcoded to dark gray in render.rs (the theme has no
    // dedicated muted accessor at present).
    assert!(
        ansi.contains("\x1b[90m"),
        "expected dark-gray ANSI fg for Muted-styled cell, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_with_custom_style() {
    use crate::component::cell::{Cell, CellStyle};
    use ratatui::style::{Color, Style};

    let custom =
        Cell::new("alpha").with_style(CellStyle::Custom(Style::default().fg(Color::Magenta)));
    let cells = vec![custom, Cell::new("beta")];
    let (plain, ansi) = render_styled_single_row(cells);
    // Custom(Style::default().fg(Magenta)) → magenta ANSI fg = \x1b[35m.
    assert!(
        ansi.contains("\x1b[35m"),
        "expected magenta ANSI fg for Custom-styled cell, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_mixed_styles_in_one_row() {
    use crate::component::cell::Cell;

    // First column uses Cell::success, second uses Cell::error — and we
    // override the column count to fit three styled cells in a single row
    // for full coverage.
    let columns = vec![
        Column::new("S", Constraint::Length(8)),
        Column::new("E", Constraint::Length(8)),
        Column::new("M", Constraint::Length(8)),
    ];
    let row = StyledRow {
        cells: vec![
            Cell::success("ok"),
            Cell::error("fail"),
            Cell::muted("idle"),
        ],
    };
    let mut state = TableState::new(vec![row], columns);
    // See `render_styled_single_row` — clearing selection prevents the
    // row-highlight style from overriding per-cell fg colors.
    state.set_selected_index(None);

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<StyledRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    let plain = terminal.backend().to_string();
    let ansi = terminal.backend().to_ansi();
    // All three semantic colors must appear in the rendered ANSI output.
    assert!(
        ansi.contains("\x1b[32m"),
        "expected green (Success) in mixed row, got:\n{ansi}",
    );
    assert!(
        ansi.contains("\x1b[31m"),
        "expected red (Error) in mixed row, got:\n{ansi}",
    );
    assert!(
        ansi.contains("\x1b[90m"),
        "expected dark-gray (Muted) in mixed row, got:\n{ansi}",
    );
    insta::assert_snapshot!(plain);
}

// ---------- #8: sort indicator visibility ----------

#[test]
fn snapshot_table_sort_indicator_appears_on_sort_asc() {
    let mut state = TableState::new(test_rows(), test_columns());
    Table::<TestRow>::update(&mut state, TableMessage::SortAsc(0));

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    let rendered = terminal.backend().to_string();
    // Sanity assert above the snapshot: the ascending arrow MUST appear
    // somewhere in the rendered output. Pinning by name protects this
    // against future cleanup that strips the indicator silently.
    assert!(
        rendered.contains('\u{2191}'),
        "expected ascending sort indicator (↑) to appear in rendered output:\n{rendered}",
    );
    insta::assert_snapshot!(rendered);
}

#[test]
fn snapshot_table_sort_indicator_disappears_on_sort_clear() {
    let mut state = TableState::new(test_rows(), test_columns());
    Table::<TestRow>::update(&mut state, TableMessage::SortAsc(0));
    Table::<TestRow>::update(&mut state, TableMessage::SortClear);

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    let rendered = terminal.backend().to_string();
    // Sanity assert: NEITHER arrow may appear after `SortClear`.
    assert!(
        !rendered.contains('\u{2191}') && !rendered.contains('\u{2193}'),
        "expected no sort indicator after SortClear, but rendered output contained one:\n{rendered}",
    );
    insta::assert_snapshot!(rendered);
}

// ---------- #15b: render-layer assertion for repeated SortToggle ----------

/// The render-layer half of test #15. Dispatches `SortToggle(0)` ten times
/// and, after each dispatch, asserts that the rendered header row contains
/// a sort indicator character. This is an assertion-based test (no snapshot)
/// because the *direction* alternates between iterations, so a single
/// pinned snapshot would not cover all states; what we want is the
/// invariant "the indicator never disappears".
///
/// Pinned by name so future cleanup of the cell-unification work can't
/// silently regress this end-user-visible behavior.
#[test]
fn sort_toggle_arrow_persists_on_repeated_press() {
    let mut state = TableState::new(test_rows(), test_columns());

    for i in 0..10 {
        let _ = Table::<TestRow>::update(&mut state, TableMessage::SortToggle(0));

        let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);
        terminal
            .draw(|frame| {
                Table::<TestRow>::view(
                    &state,
                    &mut RenderContext::new(frame, frame.area(), &theme),
                );
            })
            .unwrap();

        let rendered = terminal.backend().to_string();
        let has_arrow = rendered.contains('\u{2191}') || rendered.contains('\u{2193}');
        assert!(
            has_arrow,
            "iteration {i}: sort indicator missing from rendered output:\n{rendered}",
        );
    }
}

#[test]
fn test_view_no_outer_border_when_chrome_owned() {
    let state = TableState::new(test_rows(), test_columns());

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 8);

    terminal
        .draw(|frame| {
            Table::<TestRow>::view(
                &state,
                &mut RenderContext::new(frame, frame.area(), &theme).chrome_owned(true),
            );
        })
        .unwrap();

    let display = terminal.backend().to_string();
    insta::assert_snapshot!("view_chrome_owned_no_outer_border", display);
}

#[test]
fn snapshot_table_cells_with_severity_style() {
    use crate::component::cell::Cell;
    use crate::theme::Severity;

    // Render four severity bands in one row. Default theme: Good=Green,
    // Mild=Yellow, Bad=Yellow (collapses with Mild on Default — documented
    // behavior from D6+D9), Critical=Red+BOLD.
    let columns = vec![
        Column::new("G", Constraint::Length(8)),
        Column::new("M", Constraint::Length(8)),
        Column::new("B", Constraint::Length(8)),
        Column::new("C", Constraint::Length(8)),
    ];
    let cells = vec![
        Cell::severity("good", Severity::Good),
        Cell::severity("mild", Severity::Mild),
        Cell::severity("bad", Severity::Bad),
        Cell::severity("crit", Severity::Critical),
    ];
    let mut state = TableState::new(vec![StyledRow { cells }], columns);
    state.set_selected_index(None);

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);
    terminal
        .draw(|frame| {
            Table::<StyledRow>::view(&state, &mut RenderContext::new(frame, frame.area(), &theme));
        })
        .unwrap();

    let plain = terminal.backend().to_string();
    let ansi = terminal.backend().to_ansi();

    // ANSI assertions pin per-band coloring. Default theme: Mild and Bad
    // both render as Color::Yellow (\x1b[33m) — the documented collapse
    // from D6+D9 means severity bands degrade from four to three on
    // Default. Critical stays distinguishable via BOLD.
    assert!(
        ansi.contains("\x1b[32m"),
        "expected green (32m) for Severity::Good, got:\n{ansi}",
    );
    assert!(
        ansi.contains("\x1b[33m"),
        "expected yellow (33m) for Severity::Mild and Severity::Bad, got:\n{ansi}",
    );
    assert!(
        ansi.contains("\x1b[31m"),
        "expected red (31m) for Severity::Critical, got:\n{ansi}",
    );
    assert!(
        ansi.contains("\x1b[1m"),
        "expected BOLD (1m) for Severity::Critical, got:\n{ansi}",
    );

    insta::assert_snapshot!(plain);
}

#[test]
fn snapshot_table_cells_severity_disabled_renders_dark_gray_no_bold() {
    use crate::component::cell::{Cell, CellStyle};
    use crate::theme::Severity;

    // Same row as snapshot_table_cells_with_severity_style, but the
    // RenderContext is marked disabled. Disabled override wins: every
    // cell renders dark-gray (\x1b[90m), no BOLD.
    let columns = vec![
        Column::new("G", Constraint::Length(8)),
        Column::new("M", Constraint::Length(8)),
        Column::new("B", Constraint::Length(8)),
        Column::new("C", Constraint::Length(8)),
    ];
    let cells = vec![
        Cell::new("good").with_style(CellStyle::Severity(Severity::Good)),
        Cell::new("mild").with_style(CellStyle::Severity(Severity::Mild)),
        Cell::new("bad").with_style(CellStyle::Severity(Severity::Bad)),
        Cell::new("crit").with_style(CellStyle::Severity(Severity::Critical)),
    ];
    let mut state = TableState::new(vec![StyledRow { cells }], columns);
    state.set_selected_index(None);

    let (mut terminal, theme) = crate::component::test_utils::setup_render(40, 10);
    terminal
        .draw(|frame| {
            Table::<StyledRow>::view(
                &state,
                &mut RenderContext::new(frame, frame.area(), &theme).disabled(true),
            );
        })
        .unwrap();

    let plain = terminal.backend().to_string();
    let ansi = terminal.backend().to_ansi();

    // Disabled override: all cells render as dark-gray. No severity-band
    // colors should appear.
    assert!(
        ansi.contains("\x1b[90m"),
        "expected dark-gray (90m) for all cells under disabled, got:\n{ansi}",
    );
    assert!(
        !ansi.contains("\x1b[32m"),
        "did not expect green (32m) under disabled — Severity::Good should collapse to dark-gray, got:\n{ansi}",
    );
    assert!(
        !ansi.contains("\x1b[31m"),
        "did not expect red (31m) under disabled — Severity::Critical should collapse to dark-gray, got:\n{ansi}",
    );
    assert!(
        !ansi.contains("\x1b[1m"),
        "did not expect BOLD (1m) under disabled — Severity::Critical's BOLD must drop, got:\n{ansi}",
    );

    insta::assert_snapshot!(plain);
}