AI-Powered Full Stack Tutorial 0/70 lessons ~6 min read Lesson 55

    End-to-End Testing with Playwright

    Lessons 52 through 54 can prove a purge, a tenant fence, and a template string without opening a browser.

    Course progress0%
    Focus
    24 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    AI-Powered Full Stack Development · Lesson 55 · Full-Stack Security, Testing and Deployment

    Lesson Overview

    Lessons 52 through 54 can prove a purge, a tenant fence, and a template string without opening a browser. They cannot prove that Northwind's instructor sees "Waiting for approval," that the button is a real button, or that the page never calls a model host. That gap is where a UI regression hides: the API returns awaiting_approval, and the panel still renders "Sent" because a toast was copied from the mail success state.

    This lesson uses Playwright to drive the operations panel. The instructor project loads a synthetic storage state, fixture_northwind_instructor, which is not a production session secret. The reminder route is fulfilled by page.route, so the test does not need MODEL_API_KEY and does not need a live enrollment service. A request to any host other than 127.0.0.1 fails the test. A learner project uses a different storage state and must not see the remind button.

    The Playwright course is the reference for the runner, locators, fixtures, storage state, and traces. This lesson does not repeat that course. It binds those tools to TechLearningPro's rules: session tenant, no model key in the browser, no Contoso id on a Northwind screen, and copy that says the run is waiting.

    Planning assumptions:

    • The app under test is served at http://127.0.0.1:3000 by npm run start:e2e, which boots fixture ports and refuses to start when MODEL_API_KEY is set.
    • Storage state files live in e2e/fixtures/. Cookie values are the literal strings fixture_northwind_instructor and fixture_northwind_learner.
    • Playwright's baseURL is loopback. Tests fail if a request leaves that host.
    • Traces are on-first-retry in CI. The lab UI shows counts and status, not emails, so a trace of this spec is safe to attach to a pull request.
    • Deep locator and runner theory stays on Locators, getByRole, Fixtures, Storage State, and Route Mocking.

    Learning Objectives

    By the end of this lesson you will be able to:

    1. Point teammates at the Playwright course for runner fundamentals and keep this lesson focused on the product seams.
    2. Configure playwright.config.ts with a loopback baseURL, trace: "on-first-retry", and a web server that does not require a model key.
    3. Sign in for a test with storage state whose cookie value is a fixture marker, not a live session.
    4. Use getByRole for the remind button and the status region, as getByRole recommends.
    5. Mock POST /api/ops/reminders with page.route and return awaiting_approval, count 2, ticket tkt_01.
    6. Fail the test if the browser requests any host other than 127.0.0.1.
    7. Assert the panel shows "Waiting for approval" and the text "2 learners."
    8. Assert lrn_contoso and @ are absent from the page.
    9. Show a 503 from the reminder API as "Reminder unavailable," with no "Sent" text.
    10. Run a learner project whose storage state cannot see the remind button.
    11. Keep email and transcript screens out of screenshots for this suite.
    12. Retry in CI only through Playwright's project retries, and read a trace with Trace Viewer when a retry was used.
    13. Isolate projects so the instructor cookie never leaks into the learner project. Browser context isolation is the mechanism.
    14. Leave prompt scoring in Lesson 54. The browser checks copy and calls, not grounding phrases.
    15. Hand a tagged smoke project to the CI lesson that follows.

    Prerequisites

    What is End-to-End Testing with Playwright?

    An end-to-end test here opens the operations panel in a browser, with a cookie, and checks what a person can see and what the browser is willing to call. Playwright supplies the browser, the context, the locators, and the trace. TechLearningPro supplies the rules those tools must not weaken.

    Storage state is a saved cookie jar. Storage State shows how to capture one after a real login. This lesson commits a jar you write by hand because the value must stay synthetic. A captured production cookie is a secret and does not belong in git.

    Route mocking is page.route. Route Mocking and API Mocking cover the API. This lesson uses it so the panel's success and failure copy can be tested while Lesson 54's fixtures remain the authority on model strings. The browser test does not re-score grounding.

    Projects are Playwright projects: one for the instructor, one for the learner. Each has its own storage state. Parallel execution is safe because the contexts do not share cookies.

    TermMeaning in this lesson
    SmokeThe instructor pause path and the learner hidden button
    Storage statee2e/fixtures/*.json with fixture cookie values
    RouteA fulfilled POST /api/ops/reminders
    StatusThe role="status" region with the waiting copy
    TracePlaywright trace on first retry, from Trace Viewer
    Host fenceAny request whose host is not loopback fails the test

    Why Do We Need It?

    text
    API tests say awaiting_approval
    |
    v
    The panel toast still says Sent, or the browser calls a model host
    |
    v
    Playwright, storage state, route fulfill, host fence
    |
    v
    Waiting copy, count 2, no Contoso id, learner button absent
    |
    v
    CI smoke on pull request, wider projects nightly

    Benefits:

    • Copy regressions are caught with the same words support uses.
    • A client-side model SDK fails the host fence before a key could be added.
    • Instructor and learner cookies cannot leak across projects.
    • The suite stays free of MODEL_API_KEY, matching Lessons 52–54.
    • Traces exist when CI retries, and failure analysis has something to open.

    Real World Example

    The instructor storage state is loaded. The test fulfills the reminder POST with { "status": "awaiting_approval", "recipientCount": 2, "ticketId": "tkt_01" }. The instructor clicks "Remind stalled learners." The status region reads "Waiting for approval." The page shows "2 learners." It does not show lrn_contoso or an @.

    A second test fulfills the same URL with status 503. The status region reads "Reminder unavailable." The word "Sent" is absent. A learner project opens /ops/reminders and the remind button count is 0. The learner sees the lesson player heading instead.

    The same pattern is how a bank UI test checks that a wire says "Pending approval" while the core banking call is mocked, how a hospital portal test checks that a chart route never leaves the clinic host, and how Amazon-style and Shopify-style admin tests isolate a merchant cookie per project. Microsoft 365 and Google Workspace admin tests use a saved test tenant, not a customer's session. Netflix-style account screens mask personal fields before a screenshot. TechLearningPro's version is the fixture cookie and the waiting copy.

    Internal Working

    1. playwright.config.ts sets baseURL to http://127.0.0.1:3000, forbidOnly when CI is set, and retries: process.env.CI ? 2 : 0.
    2. use.trace is on-first-retry. Video stays off for this suite so a personal frame is harder to capture by accident. Screenshot testing is a different project and is not turned on here.
    3. webServer.command is npm run start:e2e. The script exits if MODEL_API_KEY is present, which keeps a laptop env from quietly making the browser suite "more real."
    4. The instructor project sets storageState to e2e/fixtures/northwind-instructor.json. The learner project sets the learner file. Projects document the split.
    5. Before navigation, the spec records every request host. After the click, assertLoopback requires each host to be 127.0.0.1:3000. A model host fails that assertion in the test body, where Playwright reports it.
    6. page.route("**/api/ops/reminders", ...) reads the post data, asserts it has no @ and no TEST_ONLY_MODEL_TOKEN, and fulfills JSON. Network interception is the feature in use.
    7. page.route("**/api/model/**", ...) fulfills 500 and then expect fails the test via the host fence or via an explicit call count. The handler exists so a mistaken client call is visible in the trace.
    8. The click uses getByRole("button", { name: "Remind stalled learners" }). Auto-waiting waits for the button to be actionable. The status assertion uses getByRole("status").
    9. Text assertions use toHaveCount(0) for lrn_contoso and for a locator that would match @ in the main region.
    10. The 503 spec fulfills { status: 503, body: "" } and expects "Reminder unavailable."
    11. The learner spec does not register the reminder fulfill as a success path. It expects the button count to be 0. If the button is present, the test fails even if a click would have 403'd. Hidden controls are part of the product.
    12. A failure on retry writes a trace. You open it with npx playwright show-trace as Trace Viewer describes. You do not re-record the trace with a real customer cookie to "compare."

    Architecture

    sequenceDiagram
      participant Spec as Playwright spec
      participant Browser as Browser context
      participant App as 127.0.0.1:3000
      participant Route as page.route
    
      Spec->>Browser: storageState fixture cookie
      Spec->>Route: fulfill /api/ops/reminders
      Browser->>App: GET /ops/reminders
      Browser->>App: POST /api/ops/reminders
      Route-->>Browser: awaiting_approval count 2
      Spec->>Browser: expect status Waiting for approval
    text
    playwright.config.ts
    |
    +--> webServer start:e2e (no MODEL_API_KEY)
    +--> project instructor + fixture cookie
    +--> project learner + fixture cookie
    |
    v
    spec
    |
    +--> host fence on every request
    +--> route fulfill for the reminder API
    +--> getByRole click and status
    |
    +--> pass --> smoke is green
    +--> retry once in CI --> trace zip for Trace Viewer

    Request flow from the page stays on loopback. Response flow into the status region is the JSON the route fulfilled. The model string from Lesson 54 is not re-parsed here.

    Deep Dive

    Why storage state is synthetic

    Authentication strategies include signing in through the UI, signing in through an API, and reusing storage state. A full UI login is the right test for the login page itself, and it belongs with Lesson 48's flow, tagged separately so it does not run fifty times. The operations specs reuse state so they test the panel.

    The committed cookie value fixture_northwind_instructor works only because start:e2e maps that exact string to a Northwind instructor session. Production auth rejects it. That mapping is the control that makes the file safe to commit. A value copied from a real Set-Cookie header is not safe, even if it is expired. Token handling in the Playwright security module is the longer warning. This lesson follows it by refusing real tokens in e2e/fixtures/.

    httpOnly is true on the fixture cookie so page JavaScript cannot read it. secure is false only because the lab origin is http://127.0.0.1. The production cookie is secure. The fixture file is not a template you paste into production config. Session management covers the production attributes.

    Locators that survive a redesign of color

    getByRole("button", { name: "Remind stalled learners" }) follows locator best practices and getByRole. A CSS class locator would pass a button that is not exposed to assistive tech. The accessible name is also the product copy, so a rename is a conscious test edit.

    The status region is role="status" because the copy changes after the click and a screen reader should hear it. Locator assertions and auto assertions retry until the text appears or the timeout fires. You do not waitForTimeout. Timeouts belong on the expect, at the Playwright default, unless a trace shows the app is slower for a reason you accept.

    getByText("lrn_contoso") with toHaveCount(0) is a fence, not a locator you click. getByText is the right tool for "this string must not exist."

    The host fence

    Mocking one URL is not enough. A new widget can call api.model-vendor.example and the reminder mock will still fulfill. The request listener checks every host. Loopback is the allow-list. This is stricter than a typical demo, and it is the point of putting Playwright in a security module.

    The listener must ignore the browser's own internal URLs if your Playwright version reports them, and it must allow only the origin you set. If a font CDN appears, you vendor the font in the e2e build. You do not open the fence to the internet to make the spec quieter.

    Failure copy

    The 503 path is the one support will see during an enrollment outage. "Reminder unavailable" is honest. "Sent" would be a false completion and a worse incident than the outage. The test fulfills 503 with an empty body so the UI cannot accidentally print a stack that contains a connection string. Lesson 52's redaction still applies on the server. The browser test checks the status region only.

    Projects, isolation, and tags

    Browser context isolation gives each test a fresh context. Projects add a different storage state on top. The learner spec lives in e2e/learner/ and is matched by the learner project's testDir or grep. Instructor specs do not import the learner cookie.

    Tag the pause spec @smoke using tags. Lesson 56 can run --grep @smoke on the pull request and the full e2e nightly. Retries stay at 2 in CI for browser timing only. A test that fails twice still needs a product fix. Flaky tests are a debugging topic, not a reason to raise retries to 5.

    Page objects, used lightly

    A small ReminderPage with remind() and status() keeps the spec readable. Page object model warns against hiding assertions inside the object so deeply that the spec no longer states the product rule. This lesson keeps expect in the spec. The page object only returns locators.

    Traces and privacy

    Trace Viewer will show the DOM, the route, and the cookie name. Because the cookie value is the fixture marker, a trace attached to CI is not a credential leak. If a future spec opens a transcript page, mask the text before any screenshot, and prefer not to trace that spec on success. Handling flaky visual tests is a separate decision. This lesson does not add snapshot images of the panel.

    Code Examples

    Place config at the repo root and specs in e2e/. The start script is part of the app package. It must boot without a provider key.

    Simple example: storage state and config

    e2e/fixtures/northwind-instructor.json

    json
    {
    "cookies": [
    {
    "name": "tlp_session",
    "value": "fixture_northwind_instructor",
    "domain": "127.0.0.1",
    "path": "/",
    "httpOnly": true,
    "secure": false,
    "sameSite": "Lax",
    "expires": -1
    }
    ],
    "origins": []
    }

    e2e/fixtures/northwind-learner.json is the same file with value set to fixture_northwind_learner.

    playwright.config.ts

    typescript
    import { defineConfig, devices } from "@playwright/test";
    const baseURL = "http://127.0.0.1:3000";
    /**
    * E2E stays on loopback. start:e2e must exit if MODEL_API_KEY is set.
    * Trace only after a retry so green runs do not collect DOM dumps.
    */
    export default defineConfig({
    testDir: "e2e",
    forbidOnly: Boolean(process.env.CI),
    retries: process.env.CI ? 2 : 0,
    use: {
    baseURL,
    trace: "on-first-retry",
    video: "off",
    },
    webServer: {
    command: "npm run start:e2e",
    url: baseURL,
    reuseExistingServer: !process.env.CI,
    },
    projects: [
    {
    name: "instructor",
    testDir: "e2e/instructor",
    use: { ...devices["Desktop Chrome"], storageState: "e2e/fixtures/northwind-instructor.json" },
    },
    {
    name: "learner",
    testDir: "e2e/learner",
    use: { ...devices["Desktop Chrome"], storageState: "e2e/fixtures/northwind-learner.json" },
    },
    ],
    });

    secure: false is honest for HTTP loopback. Do not copy that flag into the production session config from Lesson 48.

    Intermediate example: the panel page object

    e2e/pages/reminder-page.ts

    typescript
    import type { Page, Locator } from "@playwright/test";
    /** Locators only. Assertions stay in the spec so the product rule stays visible. */
    export class ReminderPage {
    constructor(private readonly page: Page) {}
    remindButton(): Locator {
    return this.page.getByRole("button", { name: "Remind stalled learners" });
    }
    status(): Locator {
    return this.page.getByRole("status");
    }
    async open(): Promise<void> {
    await this.page.goto("/ops/reminders");
    }
    }

    The class does not read env vars and does not know a provider URL. If it grows a login() that types a password, that password must be the fixture user from Lesson 48's test realm, and this smoke path should still prefer storage state.

    Enterprise example: pause, outage, and learner fence

    e2e/support/host-fence.ts

    typescript
    import { expect, type Page } from "@playwright/test";
    const ALLOWED_HOST = "127.0.0.1:3000";
    /**
    * Records hosts during the test. Assert after the click.
    * An expect() inside the listener races the test body and is easy to miss.
    */
    export function fenceToLoopback(page: Page): string[] {
    const hosts: string[] = [];
    page.on("request", (request) => {
    hosts.push(new URL(request.url()).host);
    });
    return hosts;
    }
    export function assertLoopback(hosts: readonly string[]): void {
    const leaked = hosts.filter((host) => host !== ALLOWED_HOST);
    expect(leaked, "requests left loopback").toEqual([]);
    }

    e2e/instructor/reminder-pause.spec.ts

    typescript
    import { expect, test } from "@playwright/test";
    import { ReminderPage } from "../pages/reminder-page";
    import { assertLoopback, fenceToLoopback } from "../support/host-fence";
    test("instructor sees a paused reminder and no foreign learner @smoke", async ({ page }) => {
    const hosts = fenceToLoopback(page);
    await page.route("**/api/ops/reminders", async (route) => {
    const body = route.request().postData() ?? "";
    expect(body.includes("@")).toBe(false);
    expect(body.includes("TEST_ONLY_MODEL_TOKEN")).toBe(false);
    await route.fulfill({
    status: 200,
    contentType: "application/json",
    body: JSON.stringify({ status: "awaiting_approval", recipientCount: 2, ticketId: "tkt_01" }),
    });
    });
    await page.route("**/api/model/**", async (route) => {
    await route.fulfill({ status: 500, body: "" });
    });
    const panel = new ReminderPage(page);
    await panel.open();
    await panel.remindButton().click();
    await expect(panel.status()).toHaveText(/Waiting for approval/);
    await expect(page.getByText("2 learners")).toBeVisible();
    await expect(page.getByText("lrn_contoso")).toHaveCount(0);
    await expect(page.getByText("Sent", { exact: true })).toHaveCount(0);
    assertLoopback(hosts);
    });
    test("a reminder outage does not render Sent", async ({ page }) => {
    const hosts = fenceToLoopback(page);
    await page.route("**/api/ops/reminders", async (route) => {
    await route.fulfill({ status: 503, body: "" });
    });
    const panel = new ReminderPage(page);
    await panel.open();
    await panel.remindButton().click();
    await expect(panel.status()).toHaveText(/Reminder unavailable/);
    await expect(page.getByText("Sent", { exact: true })).toHaveCount(0);
    assertLoopback(hosts);
    });

    e2e/learner/no-remind.spec.ts

    typescript
    import { expect, test } from "@playwright/test";
    import { ReminderPage } from "../pages/reminder-page";
    import { assertLoopback, fenceToLoopback } from "../support/host-fence";
    test("a learner does not see the remind button", async ({ page }) => {
    const hosts = fenceToLoopback(page);
    const panel = new ReminderPage(page);
    await panel.open();
    await expect(panel.remindButton()).toHaveCount(0);
    await expect(page.getByRole("heading", { name: "Lesson player" })).toBeVisible();
    assertLoopback(hosts);
    });

    package.json script, described so the server contract is explicit:

    json
    {
    "scripts": {
    "start:e2e": "node scripts/start-e2e.mjs",
    "test:e2e": "playwright test",
    "test:e2e:smoke": "playwright test --grep @smoke"
    }
    }

    scripts/start-e2e.mjs checks process.env.MODEL_API_KEY and exits 1 when it is non-empty. It then listens on port 3000 and maps tlp_session=fixture_northwind_instructor to the instructor session. The script contains no token literal besides those fixture markers.

    Run:

    bash
    npx playwright test
    npx playwright test --grep @smoke
    npx playwright show-trace test-results/**/trace.zip

    The third command is for a failed retry. A green run may have no zip, because trace is on-first-retry. That is the intended cost and privacy trade.

    Architecture Diagram

    text
    npm run start:e2e
    |
    +--> exit if MODEL_API_KEY is set
    +--> map fixture_northwind_instructor
    +--> map fixture_northwind_learner
    |
    v
    Playwright projects
    |
    +--> instructor storageState --> reminder-pause.spec.ts
    | |
    | +--> host fence
    | +--> route 200 awaiting_approval
    | +--> route 503 Reminder unavailable
    |
    +--> learner storageState --> no-remind.spec.ts
    |
    +--> button count 0
    +--> Lesson player heading
    |
    v
    Trace on first retry --> Trace Viewer

    Links into the Playwright course that this diagram relies on:

    Real-Time Enterprise Example

    The pull request runs npm run test:e2e:smoke, which is the instructor pause spec. Nightly CI runs both projects in Chrome. A failure uploads the trace zip. The on-call opens it in Trace Viewer and sees the fulfilled JSON and the status text. They do not see a provider host, because the fence would have failed first.

    Production sign-in is Lesson 48. The e2e server's cookie map does not ship in the production image. A pipeline check can grep the production bundle for fixture_northwind_instructor and fail if the marker leaked into the client JavaScript. The marker is allowed in e2e/ and in scripts/start-e2e.mjs only.

    Challenge: marketing asks for a screenshot test of the panel, a third project must run against a staging URL, and a flaky font request trips the host fence. Screenshot the status region only if product insists, and mask nothing because the region has no email. A staging project uses a test tenant and a CI secret for that tenant's password, injected as an env var the repository does not contain, and it does not replace the loopback smoke. Fonts are served by the e2e app. The fence stays closed.

    Multi-tenant: add a Contoso instructor storage state later and assert Northwind names are absent. Do not put both cookies in one context. Multi-tenant platform testing on the Playwright track shows the project layout. High traffic is not simulated here. A 503 is the outage signal this suite owns.

    Performance Optimization

    Smoke is one browser, one click, one fulfill. Keep it that way on the pull request. Nightly can add a second browser via browser engine support when the panel's CSS warrants it. Starting WebKit on every pull request is a cost you measure first.

    reuseExistingServer outside CI saves local startup. CI always starts clean so a leftover process cannot hide a broken start:e2e. Traces on retry cost disk only when something failed. Video is off. Screenshots of the full page are off.

    Do not raise the expect timeout to 30 seconds to swallow a slow mock. The route fulfill returns immediately. A long timeout hides a locator that never matches. Performance analysis is available when the app itself is slow. This spec's budget is the app's fixture mode, which does no model work.

    Parallel execution across projects is fine. Instructor and learner do not share a user. If you later hit a real database, give each worker a user id, a pattern SaaS dashboard automation covers. This lesson's server is in-memory and does not need that yet.

    Security

    • Authentication. The fixture cookie is accepted only by start:e2e. Production rejects it.
    • Authorization. The learner project asserts the button is absent, which is the UI half of Lesson 48. The API must still return 403 if the button is forced. That API test lives in Lesson 53's style. This spec does not replace it.
    • Least privilege. The Playwright process has no model key. start:e2e exits if one is set.
    • Validation. The route handler asserts the POST body has no email and no fixture token.
    • Secrets. Storage state values are fixture_northwind_instructor and fixture_northwind_learner. There is no password in the spec.
    • Tenant isolation. Northwind's page must not show lrn_contoso. A future Contoso project gets its own file.
    • Injection. The test does not page.evaluate model text into innerHTML. The app renders status as text.
    • OWASP. The relevant issues are broken access control in the UI and sensitive data in automation assets. The controls are the learner project, the synthetic cookie, and the host fence.

    OWASP automation ideas and authorization checks in the Playwright course are the broader catalog. This spec implements two of them: role-based visibility and "the browser stays on our origin."

    Common Mistakes

    1. Committing a real storage state. Symptom: a session cookie from staging is in git. Cause: playwright codegen was run against a live site and the file was committed. Fix: write the fixture JSON by hand with fixture_northwind_instructor. Rotate any cookie that was committed.
    2. Letting the browser call the model "just to see." Symptom: the host fence fails, or someone removes the fence. Cause: the spec was used as a manual demo. Fix: fulfill the reminder route. Score model strings in Lesson 54.
    3. Asserting "Sent" on awaiting_approval. Symptom: the product copies the wrong toast and the test blesses it. Cause: the spec was written from a mockup that skipped approval. Fix: expect "Waiting for approval" and expect "Sent" to have count 0.
    4. Using a CSS selector for the button. Symptom: a div with a click handler passes, and keyboard users cannot run it. Cause: the locator was #remind. Fix: getByRole("button", ...), which matches getByRole.
    5. Sharing one storage state across roles. Symptom: the learner test is accidentally an instructor. Cause: use.storageState was global. Fix: set it on each project.
    6. Opening the host fence for a CDN. Symptom: a later widget calls a vendor from the page and the test stays green. Cause: the allow-list became "any https." Fix: serve assets from the e2e app.
    7. waitForTimeout after the click. Symptom: the spec is slow and still flakes. Cause: a sleep replaced an assertion. Fix: toHaveText on the status region, which auto-waits. See auto-waiting.
    8. Recording video of a transcript page. Symptom: learner text sits in CI artifacts. Cause: video: "on" was copied from a debug guide. Fix: video off, and do not navigate this suite to transcripts.
    9. Retrying five times. Symptom: a broken locator looks intermittent. Cause: retries were raised to force a green badge. Fix: 2 in CI, then a trace. Flaky tests explains the rest.
    10. Putting MODEL_API_KEY in webServer.env. Symptom: the suite spends money and fails closed only in theory. Cause: realism was confused with coverage. Fix: start:e2e exits when the variable is set.
    11. Hiding the expect inside the page object. Symptom: reviewers cannot see the waiting-copy rule. Cause: remind() asserted internally and returned void. Fix: the page object returns locators. The spec asserts.
    12. Treating a green browser suite as a grounding eval. Symptom: a release note says the tutor was evaluated. Cause: the panel loaded. Fix: Lesson 54 owns required checks. This lesson owns the screen and the host fence.

    Best Practices

    1. Treat Playwright as the tool course and this lesson as the product suite.
    2. Serve e2e on 127.0.0.1 only.
    3. Exit start:e2e when MODEL_API_KEY is set.
    4. Commit synthetic storage state, written by hand.
    5. Keep httpOnly on the fixture cookie.
    6. Use a different storage file per project.
    7. Map fixture cookie values only in the e2e server.
    8. Locate the button with getByRole and the accessible name.
    9. Locate status with getByRole("status").
    10. Fulfill the reminder API. Do not let it reach a real port.
    11. Fence every request to loopback.
    12. Assert waiting copy on awaiting_approval.
    13. Assert "Sent" is absent on both the pause and the 503.
    14. Assert lrn_contoso is absent on the Northwind panel.
    15. Assert the POST body has no email and no fixture token.
    16. Give the learner project a hidden-button test.
    17. Keep expects in the spec and locators in the page object.
    18. Tag the pause path @smoke for pull requests.
    19. Retry at most twice in CI, with trace on first retry.
    20. Leave video and full-page screenshots off for this suite.
    21. Open traces in Trace Viewer instead of re-running against production data.
    22. Leave prompt quality to Lesson 54 and deploy wiring to Lesson 56.
    23. Add a Contoso project later with its own cookie, not a second cookie in the same context.

    Interview Questions & Answers

    Beginner

    1. What is this Playwright suite actually proving?
      An instructor with the Northwind fixture cookie sees "Waiting for approval" and "2 learners" after the remind click, the page does not say "Sent," a Contoso id is not on screen, and the browser does not call another host. A learner cookie does not see the button.

    2. Why is the cookie value fixture_northwind_instructor?
      The e2e server maps that exact string to a session. Production does not. The file can live in git because it is not a credential that works anywhere else. A cookie captured from a real login is a secret.

    3. Why getByRole instead of a CSS id?
      The role and the name are what a keyboard and a screen reader use. getByRole is the locator that fails when the control is only a styled div. The test then pushes the UI toward the accessible button the product already promised in Lesson 8.

    Intermediate

    1. How do you stop the page from calling a model?
      page.route fulfills the reminder API, a second route would catch /api/model, and fenceToLoopback fails any host that is not 127.0.0.1:3000. Removing the fence to quiet a font error is a review failure. Vendor the font.

    2. What should the panel show on a 503?
      "Reminder unavailable." The exact word "Sent" has count 0. An outage that looks like success is the bug the second spec exists to catch.

    3. Why two Playwright projects?
      Each project has its own storage state and test directory, so the learner cookie cannot be reused by the instructor spec through a shared use block. Projects and browser context isolation are the mechanics.

    Senior

    1. How do you debug a CI-only failure?
      Download the trace zip from the retry and open it with npx playwright show-trace, as Trace Viewer describes. Look at the fulfilled response and the locator. Do not point the spec at production to reproduce. If the fence failed, the URL in the assertion message is the caller you need to remove.

    2. Where do login tests live?
      A separate tagged project can drive Lesson 48's form with a test-realm user whose password comes from the CI secret store, not from the repo. The smoke specs keep using storage state so they do not depend on the password form. Authentication strategies compares those options.

    Architect

    1. How do you scale this to more tenants and browsers?
      Add a project per role and tenant, each with a fixture cookie the e2e server understands. Add a browser by spreading a different devices entry once the smoke is stable. Keep the pull request on one Chromium smoke. Nightly runs the matrix. Cross browser testing and multi-tenant platform testing are the longer treatments.

    2. What do you refuse to mock?
      You refuse to mock away the host fence, the learner's missing button, and the waiting copy. You also refuse to mock the model by calling it. Route fulfill is a stand-in for the API your app owns. It is not a tunnel to a vendor. Grounding stays in Lesson 54's fixtures.

    3. How should artifacts be retained?
      Keep the trace zip for a failed retry, with a short retention window in CI. Do not keep video. Do not keep a trace of a page that shows a transcript. The cookie inside the zip is the fixture marker. If a spec ever gains a real test-realm login, scrub or avoid tracing the storage state. Token handling is the checklist.

    4. How does this hand off to CI?
      Lesson 56 runs npm run test:e2e:smoke on the pull request and the full Playwright command nightly. The job does not receive MODEL_API_KEY. A red smoke blocks merge the same way Lesson 54's block does. The feature flag is still an independent switch at runtime.

    Knowledge Check

    1. What problem does this capability solve?

    It proves the operations panel shows the pause, hides the action from a learner, and keeps the browser on loopback, using Playwright without a live model key.

    2. What alternatives exist, and when would you choose each?

    A unit test fits copy constants. An API test fits the 403. Playwright fits the button, the status region, and the request hosts. A full UI login fits the sign-in page on its own tag. A screenshot suite fits visual regressions after this smoke is stable, and it should avoid transcript pages.

    3. Which data, identity, and trust boundaries matter?

    The fixture cookie selects the role. The route fulfill is the reminder API. The host fence is the boundary against vendor calls. The page may show a count and a ticket id. It may not show an email or a Contoso learner on the Northwind spec.

    4. What can fail, and how should the system respond?

    A 503 renders "Reminder unavailable." A foreign id or the word "Sent" on the pause path fails the spec. A request to another host fails the spec. A learner who sees the button fails the spec. CI retries twice and keeps a trace.

    5. How would you test quality, security, performance, and cost?

    Quality is the accessible name and the status text. Security is the synthetic cookie, the hidden learner button, and the host fence. Performance is one smoke browser on the pull request. Cost is a suite that never holds MODEL_API_KEY and a server that exits if it does.

    Practical Exercise

    Add a Contoso instructor fixture cookie and a spec that opens the panel, fulfills a count of 1, and asserts lrn_priya is absent. Keep the host fence. Tag it @smoke only if it stays as fast as the Northwind spec. Otherwise leave it for nightly.

    Deliverable and Rubric

    Submit the config, the two storage files, the specs, a note that start:e2e refuses MODEL_API_KEY, and the Playwright lesson links you relied on.

    AreaWeight
    Conceptual accuracy and architecture20%
    Working implementation and code quality25%
    Security, privacy, and responsible AI20%
    Testing, reliability, and observability20%
    Documentation and decision rationale15%

    Production checklist:

    • baseURL is loopback.
    • Storage state values are fixture markers.
    • Projects split instructor and learner.
    • The remind control is a getByRole button.
    • Pause copy is "Waiting for approval."
    • Outage copy is "Reminder unavailable," and "Sent" is absent.
    • lrn_contoso is absent on the Northwind screen.
    • Every request host is 127.0.0.1:3000.
    • start:e2e exits when MODEL_API_KEY is set.
    • Traces are on first retry, video is off.
    • Smoke is tagged for the next lesson's pipeline.

    Key Takeaways

    1. Playwright is the browser runner. This lesson is the TechLearningPro smoke.
    2. The tool reference is Playwright, including locators, fixtures, storage state, and traces.
    3. The instructor cookie is fixture_northwind_instructor.
    4. The learner cookie cannot see the remind button.
    5. The reminder API is fulfilled in the spec.
    6. The status text for a pause is "Waiting for approval."
    7. A 503 does not render "Sent."
    8. Northwind's screen does not show lrn_contoso.
    9. Requests stay on 127.0.0.1.
    10. getByRole is the locator for the button and the status.
    11. Expects stay in the spec.
    12. MODEL_API_KEY aborts the e2e server.
    13. CI retries twice and records a trace on the first retry.
    14. Video stays off so transcripts are not captured later by accident.
    15. Lesson 54 scores strings. This lesson scores the panel. Lesson 56 runs both in CI.

    Summary

    Lesson 55 puts the reminder's pause on screen under Playwright without giving the browser a model or a real session secret. The instructor sees a wait state and a count. The learner does not see the button. An outage stays an outage. Any request that leaves loopback fails the run. The next lesson is what runs this smoke, the offline suites, and the privacy tests on every change.

    Next Lesson Preview

    CI/CD for AI-Powered Full-Stack Applications wires these checks into a pipeline: unit and contract tests, the offline LLM suite, and npm run test:e2e:smoke. The job still has no provider key. A red gate blocks the artifact. You will also see where a budgeted nightly job could live without becoming the pull-request signal.

    Further Reading

    Ready to mark this lesson complete?Track your journey across the entire course.