# Headless browser tests for the dashboard. Boots the assay binary
# (built by assay-lua:build), starts a demo worker that emits the
# canonical pipeline_state.steps[] shape, and drives the dashboard
# with Playwright. The lifecycle script is `run.lua` in this dir,
# written in assay Lua — see docs/modules/process.md for the
# process.spawn API it uses.

language: "typescript"
layer: "automation"
stack: "frontend"

tasks:
  install:
    command: "npm install --no-audit --no-fund"
    inputs:
      - "package.json"
      - "package-lock.json"
    outputs:
      - "node_modules"
    options:
      cache: true
      runInCI: true

  install-browsers:
    command: "npx playwright install --with-deps chromium"
    deps:
      - "install"
    options:
      # Browser binaries land in ~/.cache/ms-playwright (out of repo);
      # CI caches that path explicitly via actions/cache.
      cache: false
      runInCI: true

  test:
    # The Lua runner (v0.13.0+) boots the `assay-engine` HTTP server
    # against an ephemeral SQLite, spawns the worker via `assay` (Lua
    # runtime), and drives the dashboard with Playwright. assay-lua:build
    # builds the whole workspace-release target, so both binaries are
    # ready when this runs.
    command: "../../../target/release/assay run run.lua"
    deps:
      - "assay-lua:build"
      - "install-browsers"
    inputs:
      - "**/*.{ts,json,lua}"
      - "fixtures/**/*"
      - "/crates/assay-dashboard/src/**/*"
      - "/crates/assay-workflow/src/api/**/*"
      - "/crates/assay-engine/src/**/*"
    env:
      ASSAY_REPO_ROOT: "$workspaceRoot"
    options:
      cache: true
      runInCI: true
      retryCount: 1
