analyze what's changed in this PR, and write playwright test accordingly. the test…
- User
analyze what's changed in this PR, and write playwright test accordingly.
the test should attempt to dispense medicines via encounter (encounter > medicines tab > dispense history tab > dispense. now it should add two medication line items of the same item, but quantity of both line items together should exceed the available stock. single line item cannot be tested here, since front-end validation prevents the batch-request from firing itself in the first place.
refer how existing playwrights are written. do not try to assume anything, always ask. we have strict guidelines on coding practices and standards.
do not push to the same branch, we'll create a stacked PR once ready.
Assistant
I will first rename the session, then analyze the PR changes.
Assistant
Now I will read the Playwright guide and the dispense UI.
Assistant
Backend is up. I will now find the backend error message for insufficient stock.
Assistant
I analyzed the PR. Here is a summary.
What changed
src/Utils/request/batch.ts:useBatchRequestnow detects a batch-shaped error body. On a batch failure it sends each failed sub-request error to the global error handler, and it stays silent for the successful sub-requests. It adds asilentoption and re-throws a silentHTTPErrorso the caller still sees the failure.DispensedMedicationList.tsx: removed the genericonErrortoast.en.json: removederror_updating_medication_dispenses.README.md: new documentation.
Backend behaviour I confirmed (
care/emr/api/viewsets/medication_dispense.py:92-94): a create fails withValidationError("Inventory item does not have enough stock").emr_exception_handlerreturns{"errors": [{"type": "validation_error", "msg": "..."}]}with status 400. The batch view returns 400 with aresultsarray.So before the fix the user saw 2 generic "Something went wrong" toasts. After the fix the user sees 1 toast with the real message.
I have questions before I write the test.
Assistant
I will start the setup in the background while I write the test.
Assistant
Dependencies installed. I will start the build in the background while I write the test.
Assistant
Build is done and the DB snapshot exists. Now I will write the test.
Assistant
Now I will run the test against the local backend.
Assistant
Test passes. Now I will verify it fails without the PR fix.
Assistant
The test correctly fails without the fix. I will restore the fixed code and confirm again.
Assistant
Done. The test is committed to
rithviknishad/dispense-stock-error-test, which stacks on the ENG-846 branch. I did not push.New file:
tests/facility/patient/encounter/medicine/dispense/insufficientStock.spec.tsWhat the test does
- Opens the encounter Medicines tab by URL with
getFacilityId(),getPatientId()andgetEncounterId(). - Opens the Dispense History tab, clicks Dispense, and selects the
Pharmacylocation. - Adds
Paracetamolas a line item, then reads the stock from the lot badge in the UI. - Adds a second
Paracetamolline item. - Sets each quantity to
floor(stock / 2) + 1. Each quantity stays below the stock, but the total is more than the stock. - Confirms the dispense.
Assertions
- The toast is visible.
- Opens the encounter Medicines tab by URL with