testing
Technical notes on web development, DevOps, and AI integration.
83 articles
- 07:25backend
A GET-Only Door for External Data
A read-only API gateway for external data: env-JSON allowlist, Redis cache, static error bodies, and 20 offline tests behind one GET-only door.
TL;DR: Rather than expose upstream API credentials in the browser, the author built a small FastAPI read-only gateway for KotaPortal's feeds. It allows GET only via per-source allowlists, caches JSON in Redis with clamped TTLs, and hides upstream errors. All 20 tests run offline; the one gap is a missing Allow header on 405 responses.
#fastapi#redis#httpx - 01:05testing
An E2E Leg Hung Waiting for Two Identical Frames
An E2E leg that hangs with no error can be waiting for a stability condition the page can never satisfy. The fix is a synchronous scroll.
TL;DR: A capture run stalled silently because scrollIntoViewIfNeeded waits for element stability that lazy-loading lists can never satisfy. Switching to synchronous Element.scrollIntoView plus per-leg log markers fixed the hang and made stalls locatable. The takeaway: check what a leg waits on before raising timeouts, and name every leg.
#playwright#testing#e2e - 00:51testing
Test Data Prepared Before the Run, Not Inside It
A deep-CRUD E2E suite kept leaving rows behind until data preparation moved ahead of the run and cleanup became a verified sweep ending at zero.
TL;DR: A deep-CRUD suite's final COUNT check kept failing because leftover rows survived cleanup. Scattering deletes inside tests made things worse; the real fix was preparing data upfront with shared fixtures and owning cleanup centrally. A two-phase afterAll sweep ending in a zero-count check, plus sequential workers, makes failures point at the test, not the product.
#playwright#testing#e2e - 23:07testing
Five Field Dashboards Captured with the Superadmin Face
Screenshot manuals recorded five field dashboards as the superadmin view; per-test identity moved to session cookies inside one context.
TL;DR: The screenshot manual showed one dashboard for all five field roles, but four dashboards actually differ structurally. Fix: keep one superadmin storageState as seed, then each capture test logs in via API and overwrites cookies on the same context. New roles now need just one capture test plus a roleItemHtml mapping entry.
#playwright#testing#automation - 02:27testing
Green recording, a dialog that never appeared
A passing QA test does not guarantee the filled dialog appears in the feature-tour recording. Measured pauses and element screenshots make the moment real.
TL;DR: A test passed, yet the recording never showed the dialogs being filled. Assertions verify final state and can succeed in a window shorter than one frame, while the recorder blindly captures whatever's on screen. The fix: deliberate pauses and named screenshots before each action, plus keeping the test tab in the foreground.
#playwright#qa#e2e - 01:38backend
Where's the CRUD? Two Contracts Behind the Word "Delete"
A product owner asked where the CRUD was. The API had add and edit only, and the delete was hiding in a status flag all along.
TL;DR: A product owner's "where's the CRUD?" question made the author assume delete was missing, but the code revealed the module uses logical deletion via a Nonaktif status, keeping data recoverable. Adding physical delete would've introduced an unwanted contract and data-loss risk. The real fix was documentation: explicitly stating capabilities, the delete contract, and why permanent purging isn't provided.
#api-design#crud#dokumentasi - 01:21testing
KotaPortal's Silent E2E Cleanup Leak and the 401 Nobody Read
A cleanup sweep that ran in full still leaked: every request came back 401, fetch never rejected, and six demo entities stayed behind.
TL;DR: KotaPortal's E2E cleanup sweep silently failed because every DELETE got a 401, yet the hook passed since fetch resolves normally on non-2xx statuses. Playwright's storageState only saves cookies and LocalStorage, not Authorization headers, so requests went out unauthenticated. The fix: extract the token from state, attach it as a Bearer header, and fail hard when any response isn't okay.
#playwright#e2e#http - 22:40testing
An Automatic PDF Manual from Playwright Captures
One manifest from the Playwright capture tours generates the user manual: an HTML page per tour group, an index, and an A4 PDF with an automatic size guard.
TL;DR: Playwright test videos only save after the context closes, so ffmpeg conversion must move to afterAll. A single manifest then drives three HTML outputs and an A4 PDF via Chromium. Cleanup needs trash before permanent delete, and a node:assert size guard flags empty manuals.
#playwright#documentation#automation - 20:27testing
A Killed Test Run Never Reports What It Created
Leftover e2e rows from a killed run broke the zero-left assert; a prefix-based sweep replaced the createdIds list.
TL;DR: Ctrl-C killed a test run before teardown, leaving e2e-parity- rows no later cleanup could find. Fix: sweep by prefix in afterAll using the two-step delete contract (trash then permanent), and seed event_date so records stay visible in the 9-row page. Trade-off: sweeps break concurrent runs, so add a RUN_STARTED_AT cutoff if parallelizing.
#e2e-testing#playwright#test-data