File size: 7,886 Bytes
fb62a97 2d71dc3 fb62a97 2d71dc3 fb62a97 2d71dc3 fb62a97 2d71dc3 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # Custom test cases
People and other agents can give Patchwise their own test cases. Patchwise turns each scenario into a browser script,
tries it once on the chosen test environment (a dry run), and a person approves it. Approved scenarios join the script
library and run like any other test run. Nothing runs before a person approves it.
Who can use it: consultants, QA approvers and administrators can upload and build. Only consultants and administrators
can approve or reject (the same rule as approving scenarios in a run).
## The flow
1. **Give the cases** with `POST /api/custom-cases/parse`, in one of these forms:
- **Excel:** download the template from `GET /api/custom-cases/template.xlsx`, fill it in, and upload it as
`multipart/form-data` in the field `file`. At most 2 MB.
- **Word (`.docx`):** numbered or bulleted steps under a heading (`Area:` and `Priority:` lines, `Expected: ...` after
a step, or `action -> expected`), or a table with a Step / Action / Expected result header. Same field and size cap.
- **CSV** exported from a test tool: columns such as `Test Case`, `Step #`, `Step Description` / `Action` / `Test Step`,
`Expected Result` (and optionally `Priority`, `Module`). The delimiter and the encoding (UTF-8 or Windows) are detected.
- For files and text, an optional form field / JSON field `area` gives the business area of cases that don't say it;
without one it is guessed from the wording (Payables, Journal ...).
- **Plain text:** send JSON `{"text": "...", "area": "AP"}`. The area is optional; an `Area:` line in the text sets it.
- **JSON, for agents:** send `{"cases": [...]}` in the shape shown below. The schema is strict: an unknown field
refuses the whole batch.
The answer is a batch: `{batch_id, cases: [{key, title, area, priority, steps, mapping, warnings, state}], errors}`.
Nothing has run and nothing is in the library yet. `mapping` has one row per step as the consultant wrote it
(`text`, `expected`), what Astra will do (`does`, in plain words) and `origin`: `rule` (the fixed grammar), `model`
(the app's AI model, see below) or `unmapped` (`why` says why and how to fix it).
1b. **Steps the grammar can't map** go to the app's own model with `POST /api/custom-cases/{batch_id}/ask-astra`
(`{"keys": [...]}` optional; background, the batch `status` is `mapping` meanwhile; the web app calls it by itself).
Each such step is sent with its values replaced by `{{tv.x}}` placeholders (the values stay in the case and become the
scenario's test values), as `redacted` data through the router. Where no model may be used the steps stay `unmapped`
and `message` says why. A model answer is used only when it passes the same checks as a model-written scenario and
uses no value of its own. The consultant can reword a step or leave it out with
`PATCH /api/custom-cases/{batch_id}/{key}/steps/{n}` (`{"action": "...", "expected": "..."}` or `{"remove": true}`;
the first wording is kept as `original`), and says the model's steps look right with
`POST /api/custom-cases/{batch_id}/accept {"keys": [...]}`. A scenario with model-mapped steps is not built until then
(`needs_review`); this is not an approval, and the dry run and the approval below are unchanged.
2. **Build** with `POST /api/custom-cases/{batch_id}/build {"pod_id": 3}`. Each scenario becomes a steps draft in
`FPT_HOME/staging`, never in the library, and is then dry-run on the pod in the background. Poll
`GET /api/custom-cases/{batch_id}` until `status` is `built` (or `failed`, with the reason in `message`). Each scenario
ends in one of these states:
| State | Meaning |
|---|---|
| `dry_run_passed` | The script ran end to end. |
| `dry_run_failed` | `failed_step` and `message` say where and why it failed. |
| `not_scriptable` | A step couldn't be mapped to a browser step; `message` says which one. |
`script_preview` lists the steps as Patchwise will run them. `simulated: true` means nothing ran on a pod. That is
the case when browser runs are off, or when the pod is the practice app: the step runner drives only Oracle Fusion,
so the batch message then reads "Needs a Fusion pod".
3. **Approve or reject** with `POST /api/custom-cases/{batch_id}/approve {"keys": ["c1"]}`, or `/reject`. Only
scenarios whose dry run passed can be approved. Approval does the following:
- adds the scenario to the script library as `tests/cases/<AREA>-USR-<nnn>.yaml`, together with its entry spec;
- commits the addition to `library.git`;
- records who approved it and when.
If case write-back is off (`FPT_CASE_WRITEBACK=0`), the approved scenario stays in staging and can't be started as a
run.
4. **Run** with `POST /api/custom-cases/{batch_id}/run {"keys": ["c1"], "mode": "quick" | "browser"}`. This accepts
approved keys only; if any key isn't approved, nothing starts. It starts a normal test run of those scenarios
(`case_ids`) on the batch's pod and returns `{run_id}`. From there the run, its report and the Excel export work as
usual. `browser` needs a Fusion pod.
Batches expire 14 days after they are created. Approved scenarios stay in the library.
## The one shape
```json
{"cases": [{
"title": "Standard invoice is validated",
"area": "AP",
"priority": "P1",
"preconditions": ["A supplier with a pay site exists"],
"data": {"amount": "100"},
"steps": [
{"action": "Open Payables > Invoices > Create Invoice", "expected": "The Create Invoice page opens"},
{"action": "Enter {{pod.ap.supplier}} in Supplier"},
{"action": "Set Amount to 100"},
{"action": "Save"},
{"action": "Run invoice action Validate"},
{"action": "Check Status is Validated", "expected": "The invoice shows Validated"}
]
}]}
```
Limits per batch: 50 scenarios, 40 steps per scenario, 500 characters per step, and 50,000 characters of text.
- **`area`:** a business-area code such as AP, PO, GL or P2P.
- **`priority`:** P1 to P4. P2 is used when it's empty.
Plain text uses the same fields:
```
Scenario: Standard invoice is validated
Area: AP
Priority: P1
1. Open Payables > Invoices > Create Invoice -> The Create Invoice page opens
2. Enter {{pod.ap.supplier}} in Supplier
3. Check Status is Validated -> The invoice shows Validated
```
## How steps are written
Each action is mapped to the step runner by a fixed grammar. A sign-in step is added at the start when it's missing.
| Write | Becomes |
|---|---|
| `Sign in` | `sign_in` |
| `Open Payables > Invoices > Create Invoice` | `open_task` |
| `Enter 100 in Amount`, `Set Amount to 100` | `enter` |
| `Click Save and Close` | `click` |
| `Save` | `save` |
| `Add line 100` | `add_line` |
| `Run invoice action Validate` | `invoice_action` |
| `Check Status is Validated` | `expect_status` |
| `Check Amount is 100` | `expect_value` |
| `Check Supplier is filled` | `expect_filled` |
| `Remember Invoice Number as inv` | `remember` |
| `Confirm if asked` | `confirm_if_asked` |
| `Cancel without saving` | `cancel_without_saving` |
Placeholders keep pod-specific data out of the file:
- `{{pod.ap.supplier}}` and `{{pod.ap.business_unit}}`: values from the pod;
- `{{today}}`: today's date;
- `{{unique:TAG}}`: a value unique to this run;
- `{{saved.name}}`: a value saved earlier with `remember`.
## Privacy
User-written cases can contain client data. The fixed grammar always goes first and never uses a model. Only a step it
can't map is sent to the app's model, with every name, amount and number replaced by a placeholder first and under the
router's privacy rules; where no model may be used, the step is reported back to be reworded rather than guessed. More in [SECURITY.md](SECURITY.md#custom-test-cases-excel-text-json).
A recorded flow (Playwright codegen) can become a draft here too: [RECORDINGS.md](RECORDINGS.md).
|