# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: tests/ui/district-delegates.spec.ts >> VI delegate district has a current00 canonical and historical98 redirect
- Location: tests/ui/district-delegates.spec.ts:11:7

# Error details

```
Error: expect(received).toBe(expected) // Object.is equality

Expected: "00"
Received: "98"
```

# Page snapshot

```yaml
- generic [active] [ref=e1]:
  - link "← Back to Home" [ref=e2] [cursor=pointer]:
    - /url: /
  - banner [ref=e3]:
    - heading "Districts" [level=1] [ref=e4]
    - paragraph [ref=e5]: Congressional, State Senate and State House districts
  - generic [ref=e6]:
    - generic [ref=e7]:
      - generic [ref=e8]: Not signed in
      - generic [ref=e10]:
        - link "Log in" [ref=e11] [cursor=pointer]:
          - /url: /outpost.goauthentik.io/start?rd=http%3A%2F%2Fpreview-us-elect-info.electinfo.svc.cluster.local%2Fdistricts%2F%3Fstate%3DVI%26tab%3Dcongressional
        - link "Create an account" [ref=e12] [cursor=pointer]:
          - /url: /signin/register?rd=http%3A%2F%2Fpreview-us-elect-info.electinfo.svc.cluster.local%2Fdistricts%2F%3Fstate%3DVI%26tab%3Dcongressional
    - toolbar "Member tools" [ref=e13]:
      - button "All cycles (Sign in to use the cycle facet)" [disabled] [ref=e14] [cursor=pointer]:
        - generic [ref=e18]: All cycles
      - button "Graph (Sign in to use Graph)" [disabled] [ref=e21] [cursor=pointer]:
        - generic [ref=e30]: Graph
  - generic [ref=e33]:
    - button "Congressional map" [ref=e34] [cursor=pointer]
    - button "List" [ref=e35] [cursor=pointer]
  - main [ref=e36]:
    - generic [ref=e38]:
      - generic [ref=e39]:
        - textbox "Search districts by name..." [ref=e40]
        - button "Search" [ref=e41] [cursor=pointer]
      - generic [ref=e42]:
        - button "All" [ref=e43] [cursor=pointer]
        - button "Congressional" [pressed] [ref=e44] [cursor=pointer]
        - button "State Senate" [ref=e45] [cursor=pointer]
        - button "State House" [ref=e46] [cursor=pointer]
      - generic [ref=e47]:
        - generic [ref=e48]: "State:"
        - combobox "State:" [ref=e49] [cursor=pointer]:
          - option "All states"
          - option "Alabama"
          - option "Alaska"
          - option "American Samoa"
          - option "Arizona"
          - option "Arkansas"
          - option "California"
          - option "Colorado"
          - option "Connecticut"
          - option "Delaware"
          - option "District of Columbia"
          - option "Florida"
          - option "Georgia"
          - option "Guam"
          - option "Hawaii"
          - option "Idaho"
          - option "Illinois"
          - option "Indiana"
          - option "Iowa"
          - option "Kansas"
          - option "Kentucky"
          - option "Louisiana"
          - option "Maine"
          - option "Maryland"
          - option "Massachusetts"
          - option "Michigan"
          - option "Minnesota"
          - option "Mississippi"
          - option "Missouri"
          - option "Montana"
          - option "Nebraska"
          - option "Nevada"
          - option "New Hampshire"
          - option "New Jersey"
          - option "New Mexico"
          - option "New York"
          - option "North Carolina"
          - option "North Dakota"
          - option "Northern Mariana Islands"
          - option "Ohio"
          - option "Oklahoma"
          - option "Oregon"
          - option "Pennsylvania"
          - option "Puerto Rico"
          - option "Rhode Island"
          - option "South Carolina"
          - option "South Dakota"
          - option "Tennessee"
          - option "Texas"
          - option "U.S. Virgin Islands" [selected]
          - option "Utah"
          - option "Vermont"
          - option "Virginia"
          - option "Washington"
          - option "West Virginia"
          - option "Wisconsin"
          - option "Wyoming"
      - generic [ref=e50]:
        - heading "All Districts" [level=3] [ref=e52]
        - link "U.S. Virgin Islands At-Large Delegate District Congressional · Delegate" [ref=e54] [cursor=pointer]:
          - /url: /districts/7eb04ba2-bee7-9d61-d62d-e85f9e14c53b/
          - generic [ref=e55]: U.S. Virgin Islands At-Large Delegate District
          - generic [ref=e56]: Congressional · Delegate
        - generic [ref=e57]: Showing all 1 results
```

# Test source

```ts
  1  | import { test, expect } from '@playwright/test';
  2  | import { canonicalPath, toRelativePath } from './helpers';
  3  | 
  4  | // Release contract after the coordinated graph + PagePaths cutover (#462): all six
  5  | // delegates exist as current00 entities; the index and00 alias serve them, their
  6  | // live UUID pages canonicalize to00, and historical98 aliases redirect to00.
  7  | // This is intentionally red on the old98 graph / stale alias snapshot. The local
  8  | // district-categories fixture still proves98 rows keep safe current-UUID links;
  9  | // neither that fixture nor these inventory assertions may be skipped for missing rows.
  10 | for (const state of ['AS', 'GU', 'MP', 'VI', 'DC', 'PR']) {
  11 |   test(`${state} delegate district has a current00 canonical and historical98 redirect`, async ({ page, request }) => {
  12 |     const dataResponse = page.waitForResponse(response => {
  13 |       if (!response.url().includes('/api/graphql') || response.request().method() !== 'POST') return false;
  14 |       try {
  15 |         const body = response.request().postDataJSON();
  16 |         const variables = body?.variables;
  17 |         const filters = String(variables?.filter).split(',');
  18 |         return /\bbrowseEntities\s*\(/.test(body?.query || '') && variables?.entityType === 'District' &&
  19 |           filters.includes('district_type:cd') && filters.includes(`state:${state}`);
  20 |       } catch { return false; }
  21 |     });
  22 |     await page.goto(`/districts/?state=${state}&tab=congressional`);
  23 |     const payload = await (await dataResponse).json();
  24 |     expect(payload.errors, `${state}: current inventory query must succeed`).toBeUndefined();
  25 |     const inventory = payload.data?.browseEntities;
  26 |     expect(inventory?.total, `${state}: full congressional inventory must contain exactly one delegate`).toBe(1);
  27 |     expect(inventory?.hasMore, `${state}: delegate inventory must not be truncated`).toBe(false);
  28 |     const rows = inventory?.results;
  29 |     expect(rows, `${state}: exactly one delegate must remain in the graph`).toHaveLength(1);
  30 |     const row = rows[0];
  31 |     expect(row.state).toBe(state);
> 32 |     expect(row.district).toBe('00');
     |                          ^ Error: expect(received).toBe(expected) // Object.is equality
  33 |     const metadata = JSON.parse(row.metadata || '{}');
  34 |     expect(metadata.district_type).toBe('cd');
  35 |     expect(metadata.district_slug.toLowerCase()).toBe(`${state.toLowerCase()}-00`);
  36 |     expect(row.id).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
  37 | 
  38 |     await expect(page.locator('#district-state-select')).toHaveValue(state);
  39 |     const result = page.locator('.entity-search-result');
  40 |     await expect(result).toHaveCount(1, { timeout: 15000 });
  41 |     await expect(result).toContainText(`${state}-00`);
  42 |     const canonical = `/districts/${state.toLowerCase()}-00/`;
  43 |     await expect(result).toHaveAttribute('href', canonical);
  44 |     const response = await page.goto(canonical);
  45 |     expect(response?.status(), `${state}:00 must serve, not redirect or miss`).toBe(200);
  46 |     await expect(page.locator('h1')).toBeVisible();
  47 |     expect(canonicalPath(await page.content())).toBe(canonical);
  48 | 
  49 |     const storage = await request.get(`/districts/${row.id}/`, { maxRedirects: 0 });
  50 |     expect(storage.status(), `${state}: graph-current UUID page must serve`).toBe(200);
  51 |     expect(canonicalPath(await storage.text()), `${state}: current UUID must share00 canonical`).toBe(canonical);
  52 |     const historical = await request.get(`/districts/${state.toLowerCase()}-98/`, { maxRedirects: 0 });
  53 |     expect(historical.status(), `${state}:98 must redirect rather than retire or retain an old owner`).toBe(301);
  54 |     expect(toRelativePath(historical.headers()['location'] || '')).toBe(canonical);
  55 |   });
  56 | }
  57 | 
```