- add examples/ with a ready-to-import self-test: environment, credential, snippets and a scenario that creates, runs and checks another scenario through the liqa REST API and UI, then cleans up - add test/examples.spec.ts: imports every example and parses its code - link the examples from README, docs/scenario.md and CLAUDE.md Closes #6
Self-test
A scenario that tests the liqa instance it runs on. It drives liqa through its own REST API and web UI: it creates a small scenario, runs it, checks the result and deletes it again. It shows the main liqa features in one place:
- an environment with the URLs and test values the steps read with
context.getEnv() - a credential, assigned to the scenario as
fixtureand read withcontext.getCredential() - three snippets, called with
context.runSnippet(), one of them from the other two - assertions (
context.assert()and Playwright'sexpect), step outputs (context.getStepOutput()) and run logs
Everything is in self-test.yaml.
Run it
-
Start liqa with the default docker compose deployment (
docker compose up -d --buildat the repo root). It's served at http://localhost:13000. -
Import self-test.yaml: open Import in the UI and pick the file, or run
curl -X POST http://localhost:13000/api/v1/import \ -H 'Content-Type: application/yaml' \ --data-binary @examples/self-test/self-test.yamlEvery item has a fixed id, so importing the file again updates the same resources instead of adding copies.
-
Open the liqa self-test scenario and click Run. Its default environment,
liqa-self-test, is preselected.
The run takes a few seconds. The run page shows every assertion as a log entry, and the target scenario's run while it exists.
What's in the file
| Kind | Name | Purpose |
|---|---|---|
| Environment | liqa-self-test |
liqa_url (REST API base), ui_url (web UI base), temp_prefix (name prefix of the temporary resources), greeting (test value) |
| Credential | liqa-self-test-fixture |
Test data (username, token) that the self-test passes on to the scenario it creates. It's not a real secret |
| Snippet | liqa-api |
runSnippet("liqa-api", method, path, body?): calls liqa_url + /api/v1 + path, returns the parsed JSON and throws on an error status |
| Snippet | liqa-run-and-wait |
runSnippet("liqa-run-and-wait", scenarioId, environmentId): starts a run and returns it once it has finished. Uses liqa-api |
| Snippet | self-test-cleanup |
Deletes every scenario, credential and environment whose name starts with temp_prefix and returns how many it deleted. Uses liqa-api |
| Scenario | liqa self-test |
The self-test itself (below) |
The scenario's steps:
- Check the instance is up: checks
GET /health, then runsself-test-cleanupto remove anything a failed earlier run left behind (and logs a warning if it found some). - Create the target scenario: creates a temporary environment, a temporary credential (holding the
fixturecredential's data) and the target scenario[self-test] target scenario, and assigns the credential to it assecret. The target has two steps: one readsgreetingand thesecrettoken, the other renders the greeting on a page and checks it withexpect. - Run the target scenario: runs it with
liqa-run-and-waitand checks the result: the run and both steps passed, the step outputs hold the greeting and the token's length, and the target logged its passing assertion. - Check the run in the UI: opens the target's run page at
ui_urland checks that it shows the scenario name and the assertion. - Clean up: runs
self-test-cleanupagain, and checks that it deleted the three temporary resources and that the target scenario is gone.
Addresses
Steps run inside the liqa server, so liqa_url and ui_url are addresses as seen from the server, not from your machine. In the docker compose deployment the server listens on port 3000 inside the container, published as 13000 on the host, so both are http://localhost:3000.
When running the server locally (npm run start:dev, see docs/development.md), liqa_url stays http://localhost:3000. The UI is then served by the Vite dev server: set ui_url to http://localhost:5173.
When it fails
A failed step stops the run, so the temporary resources (named [self-test] ...) are left in place to inspect. The next self-test run deletes them in its first step.