Skip to content

Commit 062465d

Browse files
Standardize Series 4 sections: remove Summary, rename Key Patterns to Key Design Decisions
1 parent 9d6db2f commit 062465d

4 files changed

Lines changed: 3 additions & 55 deletions

File tree

blogs/series-4-playwright-testing/4.2-playwright-page-object-model.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -616,19 +616,6 @@ All pagination, search, permission checks, form submission, and success verifica
616616

617617
---
618618

619-
## 🎓 Summary
620-
621-
The Page Object Model prevents selector duplication by centralizing locators and interactions in classes rather than scattering them across test files.
622-
623-
**The two-level hierarchy in AngularNetTutorial:**
624-
625-
* **`BaseListPage`** — navigation, row access (with header-skip), search, pagination, CRUD clicks, permission checks
626-
* **`BaseFormPage`** — form waiting, submit, cancel, validation detection, dropdown helper, three-fallback success verification
627-
* **`EmployeeListPage`** — extends `BaseListPage`, adds readable aliases like `getEmployeeCount()` and `clickEmployee()`
628-
* **`EmployeeFormPage`** — extends `BaseFormPage`, adds `formControlName`-based locators and `fillForm()`
629-
630-
The result: tests read like user stories. Selectors live in one place. New entities get full test infrastructure by extending two classes.
631-
632619
## 🌟 Why This Matters
633620

634621
The Page Object Model is the most impactful investment you can make in a test suite's long-term maintainability. A selector change in a component template is a one-file update in the Page Object — not a search-and-replace across twenty test files. The `BaseListPage` / `BaseFormPage` hierarchy means common actions like "click edit", "verify table has rows", and "submit form" are written once and inherited everywhere.

blogs/series-4-playwright-testing/4.3-playwright-role-based-testing.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ This workflow test also validates **data relationships** — the employee is cre
544544

545545
---
546546

547-
## 💡 Key Patterns
547+
## 🔑 Key Design Decisions
548548

549549
**Test RBAC at two layers independently.** Template directives hide buttons. Route guards block navigation. A bug in either layer is a security issue. Test both: "is the button visible?" and "does direct URL navigation get blocked?"
550550

@@ -558,17 +558,6 @@ This workflow test also validates **data relationships** — the employee is cre
558558

559559
---
560560

561-
## 🎓 Summary
562-
563-
Testing RBAC with Playwright means going beyond "can the user log in?" and verifying the entire permission surface:
564-
565-
* **What buttons are visible** — using `isVisible()` to assert presence and absence
566-
* **What routes are accessible** — using direct URL navigation to bypass the UI
567-
* **That switching users clears the previous role** — using the cross-role test
568-
* **That workflow tasks work end-to-end** — using multi-step workflow tests
569-
570-
The three-role structure in AngularNetTutorial (Employee, Manager, HRAdmin) maps cleanly to three `test.describe` blocks, each with its own `beforeEach` login. The cross-role test ties them together by asserting the permission hierarchy in a single browser session.
571-
572561
## 🌟 Why This Matters
573562

574563
Role-based access control is one of the hardest things to test with confidence. Unit tests can verify that a guard function returns `false` — but only E2E tests can verify that the right buttons appear for the right users, that direct URL navigation is blocked, and that switching users mid-session actually clears the previous role. The three-`describe`-block pattern makes this systematic.

blogs/series-4-playwright-testing/4.4-playwright-jwt-token-testing.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ Before doing so, consider these design implications:
520520

521521
---
522522

523-
## 💡 Key Patterns
523+
## 🔑 Key Design Decisions
524524

525525
**Decode without a library.** `Buffer.from(parts[1], 'base64').toString()` gives you the raw JSON. `JSON.parse()` gives you the claims object. No `jsonwebtoken`, `jwt-decode`, or other dependencies required.
526526

@@ -534,19 +534,6 @@ Before doing so, consider these design implications:
534534

535535
---
536536

537-
## 🎓 Summary
538-
539-
JWT token testing with Playwright fills the gap between "login works" and "the API will accept this token with the right permissions":
540-
541-
* **Two extraction methods** — `getStoredToken()` (browser storage, fast) and `getTokenFromProfile()` (Profile page, robust)
542-
* **One-liner decode** — `JSON.parse(Buffer.from(parts[1], 'base64').toString())`
543-
* **Claims to verify** — `sub`, `exp > now`, `iss`, `aud`, `role`, `scope`
544-
* **Role verification** — each role gets different claims; assert all three
545-
* **Tamper detection** — swap the signature, expect 401 from the API
546-
* **Direct API calls** — use the extracted token with `request.get()` for API-layer testing
547-
548-
When IdentityServer configuration changes, these tests tell you before the UI does.
549-
550537
## 🌟 Why This Matters
551538

552539
JWT token testing fills the gap between "login works" and "the API will accept this token with the right permissions." When IdentityServer configuration changesa missing `role` claim, a wrong audience, an expired token lifetimethese tests catch it before the Angular UI does. The `payload.exp > now` assertion alone prevents an entire class of silent authentication failures.

blogs/series-4-playwright-testing/4.5-playwright-api-testing.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ These tests verify that the API accepts pagination and search parameters without
655655

656656
---
657657

658-
## 💡 Key Patterns
658+
## 🔑 Key Design Decisions
659659

660660
**`test.beforeAll` for token, `test.afterEach` for cleanup.** Token acquisition is slowdo it once per suite. Record cleanup is per-testdo it after every test, even failing ones.
661661

@@ -681,21 +681,6 @@ This simple test catches a common misconfiguration: the API returning HTML error
681681

682682
---
683683

684-
## 🎓 Summary
685-
686-
Playwright's `request` fixture turns E2E tests into a full API test suite:
687-
688-
* **`getTokenForRole()`**spins up a temporary headless browser, completes the OIDC flow, returns a real token
689-
* **`test.beforeAll`**acquires the token once per suite with a timeout safety net
690-
* **`test.afterEach`**deletes records created during the test
691-
* **Full CRUD**GET list, GET by ID, POST create, PUT update, DELETE with verify-by-404
692-
* **Error cases**400 invalid data, 404 not found, 401/403 wrong role
693-
* **Response shape flexibility**`data.data || data.items || data` normalization
694-
* **Cache behavior**`X-Cache-Status` headers, cache invalidation on write, concurrent request consistency
695-
* **Pagination and search**query parameter pass-through
696-
697-
The `request` fixture completes the test pyramid: unit tests at the bottom, API tests in the middle, and full E2E UI tests at the topall within the same Playwright project.
698-
699684
## 🌟 Why This Matters
700685

701686
Playwright's `request` fixture turns an E2E test suite into a full API test suite — without a second testing framework. The `getTokenForRole()` pattern (headless browser for OIDC token acquisition, then bare HTTP client for API calls) solves the hardest problem in OAuth-protected API testing: getting a real token programmatically when PKCE is the only allowed grant.

0 commit comments

Comments
 (0)