> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testorim.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reusable flows

> Saved procedures replay a recorded test exactly, without planning it again.

A **procedure** is a saved test: a fixed, ordered list of steps that replays
exactly as recorded.

Replays do not call the planner. They are cheaper, faster and deterministic:
the same steps every time, so a change in the result means a change in your
site, not a change in how the test was interpreted.

Procedures are what schedules run, what CI triggers, what the GitHub PR bot
fires, and what fuzzing and visual baselines attach to.

## Saving one

Press **Save as test** on a finished run.

What gets saved is **what actually worked**:

* An Enter key the page ignored, recovered by clicking the field's own submit
  button, saves as that click.
* A typed value a combobox committed as a selection saves as the selection.
* A click skipped because the page was already there saves as nothing at all.
* Coverage-gap placeholders are stripped.

So the procedure you replay tomorrow is the sequence that worked today, not the
first guess at it.

## Running one

| From       | How                                                      |
| ---------- | -------------------------------------------------------- |
| The app    | **Run** on the project overview or the saved-tests panel |
| A schedule | Project settings → Schedules, a cron expression          |
| The CLI    | `testorim run <procedure-id>`                            |
| The API    | `POST /api/runs/trigger` with `procedureId`              |
| GitHub     | Automatically, on a pull request in a linked repository  |

Each of those accepts an [environment](/projects/environments) and a base-URL
override, so the same procedure can run against staging, production, or a PR
preview.

## Login and auth mode

Every procedure has an auth mode that decides how its browser starts.

| Mode                | Behaviour                                                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fresh_logged_out`  | Start from a clean browser every time. Correct for sign-in, sign-up and sign-out tests, because otherwise a saved session makes them meaningless. |
| `reuse_login_state` | Preload the project's saved login state. Correct for dashboard workflows that assume a signed-in user.                                            |
| `unknown`           | Legacy behaviour, preserved for older procedures.                                                                                                 |

New procedures get a conservative guess from their name and steps; change it in
the saved-tests panel if the guess is wrong.

### Capturing a login state

Mark a sign-in procedure as the project's **login-setup** test. When it passes,
the browser's storage state is captured, encrypted and stored on the project.
Every later run that reuses login state starts already signed in.

Re-run the login-setup procedure whenever the session expires.

## Exporting

`GET /api/procedures/{id}/export` returns the procedure as a standalone
Playwright spec, useful for taking a flow into your own repository, or for
seeing exactly what a step does.

## Maintenance

A procedure is only as good as the page it was recorded against. When a redesign
moves things:

* The [flakiness dashboard](/troubleshooting/reliability#flake-tracking) on the
  project overview sorts your tests worst-first, so the ones drifting show up
  before they fail outright.
* A failed replay is attributed: `test` means the step no longer matches the
  page, `app` means the site is genuinely broken.
* Re-record by describing the flow in chat again and saving the new run.


## Related topics

- [Create your first test](/getting-started/first-test.md)
- [Create a project](/getting-started/create-a-project.md)
- [Reliability](/troubleshooting/reliability.md)
- [Browser failures](/troubleshooting/browser-failures.md)
- [Slack](/integrations/slack.md)
