Something went wrong

Thank you for being patient! We're working hard on resolving the issue

Ops Fixtures - Lona Docs Log in

Ops Fixtures

An ops fixture is a pure JSON document describing a scripted sequence of operations against a Sheet. Run via the ops subcommand; reused by the test harness as a regression suite.

Schema

interface OpsFixtureInput {
  // Path to a starting .sheet.json (resolved relative to cwd):
  input: string;

  // Optional: human-readable comment shown in CLI output:
  description?: string;

  // The scripted ops to run, in order:
  ops: Op[];

  // Optional: assertions to validate after the run:
  expected?: {
    cells?: ExpectedCell[];
    aliasInstances?: ExpectedAliasInstance[];
    treeShape?: string;
  };
}

Op kinds

type Op =
  | { kind: "addRow"; type: string; label: string; parentRow?: string; attrs?: Record<string, unknown> }
  | { kind: "removeRow"; row: string }
  | { kind: "setCell"; row: string; date: string; value: unknown; cellId?: string }
  | { kind: "setProp"; row: string; prop: string; value: unknown }
  | { kind: "setExpression"; row: string; expression: string }
  | { kind: "renameRow"; row: string; newLabel: string }
  | { kind: "reparent"; row: string; newParent: string; index?: number }
  | { kind: "writeCell"; row: string; date: string; value: unknown }   // multi-cardinality
  | AssertOp;

AssertOp runs an inline check between ops:

type AssertOp =
  | { kind: "assertCell"; row: string; date: string; value: unknown }
  | { kind: "assertEvent"; type: string; rowMatching?: string }
  | { kind: "assertTreeShape"; shape: string };

row accepts a label string. The harness resolves it to a SheetRow via rowByLabel(sheet, label).

Date format

Dates use NaiveDate.Partial.parse syntax:

FormExample
Dayymd-2026-4-18
Weekyw-2026-1
Monthym-2026-4
Yeary-2026

Minimal example

{
  "input": "tento/tento-lona-js/sheets/tests.shared/sheets/empty.sheet.json",
  "description": "Add Weight, set 3 cells, verify",
  "ops": [
    { "kind": "addRow", "type": "number", "label": "Weight" },
    { "kind": "setCell", "row": "Weight", "date": "ymd-2026-4-18", "value": 200 },
    { "kind": "setCell", "row": "Weight", "date": "ymd-2026-4-20", "value": 210.5 },
    { "kind": "assertCell", "row": "Weight", "date": "ymd-2026-4-18", "value": 200 }
  ],
  "expected": {
    "cells": [
      { "row": "Weight", "date": "ymd-2026-4-18", "value": 200 },
      { "row": "Weight", "date": "ymd-2026-4-20", "value": 210.5 }
    ]
  }
}

Formula propagation

{
  "input": "tento/tento-lona-js/sheets/tests.shared/sheets/empty.sheet.json",
  "ops": [
    { "kind": "addRow", "type": "number", "label": "Weight" },
    { "kind": "setCell", "row": "Weight", "date": "ymd-2026-4-18", "value": 200 },
    { "kind": "addRow", "type": "formula", "label": "Weight Plus 10",
      "attrs": { "expression": "(+ (rows[\"Weight\"]) 10)" } },
    { "kind": "assertCell", "row": "Weight Plus 10", "date": "ymd-2026-4-18", "value": 210 }
  ]
}

Notice: a setCell on the source row triggers the formula to recompute. The CLI's per-op output shows the cascade as [event] ColumnDataChanged lines for both rows.

Alias lifecycle

{
  "input": "tento/tento-lona-js/sheets/tests.shared/sheets/empty.sheet.json",
  "ops": [
    { "kind": "addRow", "type": "alias", "label": "Weather",
      "attrs": { "template": "weather", "props": { "location": "Berlin" } } },
    { "kind": "setProp", "row": "Weather", "prop": "showLogs", "value": true },
    { "kind": "assertTreeShape", "shape": "alias > column > [renderer, renderer]" }
  ],
  "expected": {
    "aliasInstances": [
      { "row": "Weather", "template": "weather",
        "props": { "location": "Berlin", "showLogs": true } }
    ]
  }
}

Where fixtures live

  • tento/tento-lona-js/sheets/tests/<topic>/*.ops.json — regression fixtures (auto-discovered by the test runner)
  • tento/tento-lona-js/sheets/tests/demo/*.ops.json — canonical scripted scenarios (formula propagation, alias lifecycle)

Drop a new .ops.json into either tree; the test harness picks it up next run.

See also

  • ops — running fixtures
  • Snapshot Testing — pairing ops fixtures with --json snapshots
  • tento/tento-lona-js/sheets/src/ops.ts — the canonical Op type definitions