Spaces:
Sleeping
Sleeping
|
Download docs/CUSTOM_CASES.md from EnergyVenom/patch-testing-coworker: direct link, hf CLI and curl.
- Browser
- Download file 5.79 kB
-
https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/docs/CUSTOM_CASES.md
- Command line
-
hf download hf://spaces/EnergyVenom/patch-testing-coworker/docs/CUSTOM_CASES.md
-
curl -L -o CUSTOM_CASES.md https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/docs/CUSTOM_CASES.md
5.79 kB
| # 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 three 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`. Use `.xlsx` only, at most 2 MB. | |
| - **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, warnings, state}], errors}`. Nothing | |
| has run and nothing is in the library yet. A `warning` names a step that can't be turned into a browser step: reword | |
| it and parse again. | |
| 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, so they are never sent to an AI model, frontier or local. If a step can't | |
| be mapped, it is reported back to be reworded rather than guessed. More in [SECURITY.md](SECURITY.md#custom-test-cases-excel-text-json). | |