﻿---
url: https://docs.karamconnect.com/developers/workflows.md
---
# Staff workflows

These pages walk through what a staff member actually does in Karam Connect, one job at a time: adding a neighbor, checking someone in, writing a note, running a report. Each one is a script you can follow by hand to check that a feature still works after a change, and the most important ones are also run automatically by Playwright on every pull request that touches the staff app.

They describe the app as it is today, in demo mode: with no server connected, every screen runs on in-browser sample data (Lin Chen, Nadia Rahman, the Food box service and so on), so anyone can follow them from `pnpm run dev` in `client/` without a database. The same steps work against a real server seeded with `pnpm run dev:seed` in `server/`, except where a page says otherwise.

## The workflows

| Workflow                                                                                   | Who                            | Automated |
| ------------------------------------------------------------------------------------------ | ------------------------------ | --------- |
| [Sign in and out](/developers/workflows/sign-in)                                           | Any staff member               | Yes       |
| [Add a neighbor](/developers/workflows/add-a-neighbor)                                     | Front desk, case worker        | Yes       |
| [Check in a neighbor for a service](/developers/workflows/front-desk-check-in)             | Front desk                     | Yes       |
| [Serve neighbors from the check-in queue](/developers/workflows/check-in-queue)            | Front desk, case worker        | Yes       |
| [Write a note on a neighbor](/developers/workflows/write-a-note)                           | Case worker                    | Yes       |
| [Give a task and finish it](/developers/workflows/give-a-task)                             | Any staff member               | Yes       |
| [Export, archive and restore a neighbor](/developers/workflows/archive-and-export)         | Case worker, admin             | Yes       |
| [Run a report for the board](/developers/workflows/run-a-report)                           | Program manager                | Yes       |
| [Turn on Workforce Development](/developers/workflows/set-up-workforce)                    | Admin, case worker             | Yes       |
| [Record a household and relationships](/developers/workflows/households-and-relationships) | Case worker                    | By hand   |
| [Count people at an event](/developers/workflows/count-at-an-event)                        | Staff or volunteer at the door | By hand   |
| [Add a volunteer and log hours](/developers/workflows/add-a-volunteer)                     | Volunteer coordinator          | By hand   |
| [Invite a staff member with a role](/developers/workflows/invite-a-staff-member)           | Admin                          | By hand   |
| [Set up services and tags](/developers/workflows/set-up-services-and-tags)                 | Admin                          | By hand   |

## How a page is written

Every page has the same shape, so it reads as a checklist and a test can follow it:

* A table: **Who** does it, the permissions it **Needs**, where it **Starts from**, and the spec that **Automated** it (or "Not yet").
* One paragraph on why the job matters and what the walk-through proves.
* **Steps**, each a heading `### <number>. <what you do>`, with what to do and a **Check:** line saying what you should see. Use the app's own words for buttons and labels, in bold.
* **Try by hand as well** (or **Things to check along the way**): variations worth trying that aren't steps.

## How the automation follows the pages

The specs live in `client/e2e/`, one per automated workflow, named after the page. A spec opens its page with `workflow('<page name>')` and runs each step with `wf.step(<number>, '<heading>', …)`. The heading must match the page word for word, the page's steps must be numbered 1, 2, 3 with no gaps, and at the end `wf.done()` fails unless every step on the page ran, in order. So adding, removing, renumbering or retitling a step fails its spec until someone opens the spec and follows the page.

What the check can't see is a change to the text under a heading, such as a new **Check:** line. When you change one, change the spec's assertions with it: each `wf.step` asserts that step's **Check:** line.

Every run happens at the same moment: the browser's clock is frozen on a Tuesday at noon in New York (`NOW` in `client/e2e/workflow.ts`), and the demo data is generated around it, so dates never move at midnight or with daylight saving time. The pages say "today"; the specs use that Tuesday. The front-desk jobs (sign in, add a neighbor, check-in) run again at phone width, and counting at an event runs only there.

Run them from `client/`:

```sh
pnpm run test:e2e          # builds the app in demo mode, then runs every workflow
pnpm exec playwright test add-a-neighbor --headed   # one workflow, watching the browser
```

`test:e2e` builds into `dist-e2e/` with `--mode e2e`, and in that mode `client/vite.config.ts` blanks the settings that would leave demo mode, so your own `.env` (a `VITE_AUTH_URL` pointing at a server, say) doesn't leak into the run. Playwright then starts `vite preview` on port 4179 itself. Each test gets a fresh browser, so it starts from the same sample data. The first time, install the browser with `pnpm exec playwright install chromium`.

## Adding a workflow

1. Write the page in `docs/src/developers/workflows/`, add it to the table above and to the Developers sidebar (`docs/.vitepress/locales/en.ts`).
2. Walk it through by hand in demo mode. Write what you see, not what the code is meant to do.
3. To automate it, add `client/e2e/<page name>.spec.ts` with one `wf.step` per heading, asserting that step's **Check:** line, and change **Automated** on the page. Write `const wf = workflow('<page name>')` and import `test` and `expect` from `./workflow` (they carry the frozen clock), not from `@playwright/test`. Open pages with `openFromMenu(page, '<menu item>')`, which also works on a phone. Find elements the way a person does (`getByRole`, `getByLabel`, visible text), so a test that fails usually means a person would be stuck too.
