File size: 4,542 Bytes
fb62a97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Import a recording (backup for odd, client-specific flows)
AI-designed scenarios built from business actions stay the core of Astra. A recording is only the backup for a flow no
one could design in advance: a consultant records it once, Astra converts it into business-action steps, and the result
is a **draft custom scenario** (origin `recording`). It goes the same way as every other scenario
([CUSTOM_CASES.md](CUSTOM_CASES.md)): a dry run on a pod, then a person's approval, before it joins the library. A raw
recorded selector never becomes a test.
## For consultants
1. `npx playwright codegen <pod url>`, click through the flow once, save the file it shows (TypeScript; the JSON-lines
target works too).
2. In Astra: Scenarios > Bring your own test cases > **Recording**. Choose the business area, paste or choose the file,
and **Preview the steps**. Read what was dropped and what needs a look, then **Create draft**.
3. Continue as for any custom scenario: build and try on a pod, approve what passed, run.
## What the conversion does (`coworker/platform/recording.py`)
- **Parse:** deterministic, line by line, into neutral events (action, role, label or name, value, URL). A line it cannot
read is not guessed: it is counted and listed.
- **Never kept:** sign-in pages, user name and password fields, the Sign In button, any password value. URLs lose
everything after `?` (and `#`). File names of uploads are not kept.
- **Business actions:** opening Create Invoice, Create Noncatalog Request, Create Order or Create Journal, filling
its fields and pressing Save / Submit / Post becomes `create_invoice`, `create_requisition`, `create_purchase_order`
(a later Submit becomes `submit_purchase_order`) or `create_journal` (a later Post becomes `post_journal`). The business
action uses the pod's own business unit, supplier and account, so those entries are folded into it (and said so);
amounts, quantities and prices become test values (`{{tv.amount}}`). Invoice Actions > Validate or Cancel Invoice after
a created invoice becomes `validate_invoice` / `cancel_invoice`; a status text checked afterwards becomes
`expect_invoice` (or the requisition, order, journal equivalent).
- **Everything else** becomes screen steps by label or name: `open_task` (a run of Navigator links), `enter`, `click`,
`save`, `cancel_without_saving`, `confirm_if_asked`, `expect_value`, `expect_message`, `menu_action`.
- **Values:** a recorded value that equals the chosen pod's test data becomes `{{pod.<area>.<key>}}`; a date in a date
field becomes `{{today}}`; a document number or name becomes `{{unique:REC}}`; else the literal value stays.
- **Dropped on purpose** (listed): sign-in, clicks into a field before typing, picks from a list Fusion offered, Tab and
Enter, waits, Navigator and Tasks panel clicks.
- **Flagged** (listed, not converted): an event with only a CSS / XPath / id / test-id locator and no label or name, a
direct jump to a URL, a key, tick box, tab, hover or text click that has no step. A recording that checks nothing gets a
`expect_no_error` and a warning to add a real check before approving.
- At most 40 steps (as for any custom scenario) and 200 KB of recording.
## Optional AI tidy-up
`ai_tidy: true` asks the step writer's model to fold screen steps into business actions. It goes through the same masked,
egress-checked call as the step writer (`step_writer._call`) and sees only the step structure: every recorded value is a
token (`[[v1]]`) that is put back afterwards. The answer is used only if it keeps the recording's own labels, uses allowed
actions of this area and invents no value; otherwise the deterministic steps stay and the reason is shown. Without an AI
model the deterministic result is used as it is.
## API
Permission `run.start` (consultant, QA approver, admin), audited as `recording.converted` (counts only, no values).
- `POST /api/recordings/preview` `{module, text, title?, pod_id?, ai_tidy?}` returns `{steps, text, test_values, dropped,
flagged, unparsed, ai}`; nothing is created.
- `POST /api/recordings` (same body) returns the same plus `{draft_id, key}`. The draft is batch `draft_id` of source
`recording`, not approved: continue with `/api/custom-cases/{draft_id}/build`, `/approve`, `/run`.
- More than 200 KB answers 413 `TOO_LARGE`.
Not verified against a real pod or a real codegen file yet: the TypeScript patterns follow Playwright's documented
codegen output, and the JSON-lines selector forms follow its `jsonl` target.
|