Uji Waras — Testing

Test Mbak Arini's pharmacy app Waras: role queries, MSW, snapshots, Playwright, the test pyramid. 14 levels, right in the browser.

What the levels ask

  1. Ms. Arini's first morning writing real tests for Waras. Grandma Marni reports that the Tebus button for her blood pressure medicine is dead, though it is in stock. Three phones lie on the counter: Waras today, Waras with Grandma Marni's report, and Waras as Ms. Arini will have tidied it tomorrow (the button moves into a shared Tombol component). Choose how the test finds the Tebus button.
  2. Mr. Tono reports that Captopril is out of stock and its button looks grey, yet when he pressed Enter on the keyboard, his order went through. The test already finds the Tebus button by its role. Choose the assertion that checks what Mr. Tono complains about.
  3. Mrs. Lastri reports that she hit Kirim pesanan before ticking 'Saya sudah bertanya ke apoteker' (I have asked the pharmacist), and her order went through. In today's Waras the order fields sit inside a <fieldset disabled> until that box is ticked. The test already has a fake kirim. Choose how the test presses the button, the way Mrs. Lastri's thumb did.
  4. Mrs. Sari reports that Waras says her paracetamol has 'Sisa strip' left, with the number missing. The StokObat component asks the stock server, then writes what is left. In the test that server is faked by MSW, which always answers { sisa: 12 }. Choose how the test finds the text 'Sisa 12 strip'.
  5. Mrs. Ijah reports that when the pharmacy's server broke, Waras said 'Stok habis' (out of stock), so she bought antacid in town though the pharmacy had it. Today's Waras handles an answer that is not ok by asking the villager to try again. Choose the MSW handler's answer so the test checks the situation Mrs. Ijah ran into.
  6. Mrs. Yanti reports that Waras always says 'Coba lagi' (try again), though the pharmacy's server is up. The test comes from the old suite: its handler answers 500 and it waits for the try again message. The trouble is that the 'Coba lagi' screen also shows when nobody answers the request at all. Choose how the MSW server is set up, and the handler's address.
  7. Grandma Marni is back with her medicine label: 'My metformin label says three tablets at once. Good thing I asked Ms. Arini first.' Her doctor wrote 3 x sehari 1 tablet (one tablet three times a day). The old suite has a snapshot test for this label, and last week someone ran vitest -u while the test was red. Choose the assertion for this label.
  8. The neighbourhood head checks the pharmacy's prescription book and finds Amlodipin stock at minus one: someone took more than there was. The tebus function is tested against real Postgres (PGlite), filled once: Amlodipin, 12 strips. All three tests take from the same row. The runner runs each test alone, all three in order, and all three in three shuffled orders. Choose the hook that starts every test from 12 strips.
  9. Ms. Wulan brings a letter from the community health centre: next week their prescription server changes version. Waras reads nama, dosis and kaliSehari from every medicine in a prescription. This contract test starts the health centre's real server and reads its answer. On this level the report phone is the new server version that renames dosis to takaran, and the tidied phone is a version that only adds fields. Choose the contract check.
  10. Mr. Karim reports from the jetty: he pressed Tebus and 'Pesanan gagal dikirim' (order failed to send) appeared. The test is end to end now: Playwright opens the real Waras in Chromium and WebKit at a phone's size, presses Tebus, then waits for the sign that the order was received. The runner runs everything on a fast network (the server answers in 0.3 seconds) and on a slow one like the jetty's (2.5 seconds). Choose how the test waits.
  11. Mrs. Ratna reports that on her phone the Tebus button is covered by a vitamin C promo banner and cannot be pressed at all. On the report phone the banner moved to the middle of the screen. Playwright opens Waras at a phone's size in Chromium and WebKit. Choose how the test presses Tebus.
  12. Three reports arrive at once. The neighbourhood head: his 30 day Metformin allowance shows half of it. Mr. Tono: Captopril that is out of stock can be ordered again. Mrs. Ratna: a banner covers the Tebus button. For each report a test is already written in three layers: unit (the function alone), component (Vitest and jsdom), and e2e (Playwright in Chromium and WebKit). This suite will run on Ms. Arini's old laptop every time she saves code. Choose a layer for each report: every bug caught, at the smallest cost in time.

And more, 14 levels in all.