improvise-gk51: the pivot branch too, a shipped-document enumeration, and the argument
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -50,6 +50,51 @@ fn every_shipped_document_loads() {
|
||||
}
|
||||
}
|
||||
|
||||
/// improvise-gk51: in every shipped document, pivot and records mode, a cell
|
||||
/// projected as a `Record` is one the host would accept a write to.
|
||||
#[test]
|
||||
fn every_record_a_shipped_document_projects_is_writable() {
|
||||
use improvise::command::key::{KeyCode, KeyEvent, KeyModifiers};
|
||||
use improvise::protocol::CellId;
|
||||
use improvise::ui::app::App;
|
||||
use improvise_command::ui::project::{Viewport, grid_of};
|
||||
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let mut records = 0;
|
||||
let mut refused = Vec::new();
|
||||
for path in shipped_documents(root) {
|
||||
let workbook = improvise::persistence::load(&path).expect("every shipped document loads");
|
||||
let mut app = App::new(workbook, None);
|
||||
for _mode in ["pivot", "records"] {
|
||||
let whole = Viewport {
|
||||
row_offset: 0,
|
||||
col_offset: 0,
|
||||
rows: app.layout.row_count(),
|
||||
cols: app.layout.col_count(),
|
||||
};
|
||||
let grid = grid_of(&app, whole);
|
||||
for cell in grid.cells.iter().flatten() {
|
||||
if let Some(CellId::Record(record)) = &cell.id {
|
||||
records += 1;
|
||||
if let Some(why) = app.unwritable(record) {
|
||||
refused.push(format!("{}: {why}", path.display()));
|
||||
}
|
||||
}
|
||||
}
|
||||
let r = KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE);
|
||||
let _ = app.handle_key(r);
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
records > 0,
|
||||
"precondition: the shipped documents project records"
|
||||
);
|
||||
assert!(
|
||||
refused.is_empty(),
|
||||
"projected as Record, then refused: {refused:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A scratch repository, so each way of shipping a document is set up for real.
|
||||
fn scratch_repo() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().expect("a temp dir");
|
||||
|
||||
Reference in New Issue
Block a user