# 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/geo-map.spec.ts >> /postalcodes/73762/: boundary map, no missing scripts or shapes
- Location: tests/ui/geo-map.spec.ts:18:7

# Error details

```
Error: expect(locator).toHaveCount(expected) failed

Locator:  locator('script[src="/js/geo-map.js"][data-geo-shape]')
Expected: 1
Received: 0
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" locator('script[src="/js/geo-map.js"][data-geo-shape]') with timeout 5000ms
  - waiting for locator('script[src="/js/geo-map.js"][data-geo-shape]')
    14 × locator resolved to 0 elements
       - unexpected value "0"

```

# Page snapshot

```yaml
- generic [active] [ref=e1]:
  - banner [ref=e2]:
    - heading "ZIP Code 73762" [level=1] [ref=e3]
    - paragraph [ref=e4]: ZIP Code Tabulation Area
  - generic [ref=e5]:
    - generic [ref=e6]:
      - generic [ref=e7]: Not signed in
      - generic [ref=e9]:
        - link "Log in" [ref=e10] [cursor=pointer]:
          - /url: /outpost.goauthentik.io/start?rd=https%3A%2F%2Fus.elect.info%2Fpostalcodes%2F73762%2F
        - link "Create an account" [ref=e11] [cursor=pointer]:
          - /url: /signin/register?rd=https%3A%2F%2Fus.elect.info%2Fpostalcodes%2F73762%2F
    - toolbar "Member tools" [ref=e12]:
      - button "All cycles (Sign in to use the cycle facet)" [disabled] [ref=e13] [cursor=pointer]:
        - generic [ref=e17]: All cycles
      - button "Graph (Sign in to use Graph)" [disabled] [ref=e20] [cursor=pointer]:
        - generic [ref=e29]: Graph
  - generic [ref=e32]:
    - heading "Overview" [level=2] [ref=e33]
    - generic [ref=e34]:
      - term [ref=e35]: ZIP Code
      - definition [ref=e36]: "73762"
      - term [ref=e37]: Land Area
      - definition [ref=e38]: 2.50 sq mi
      - term [ref=e39]: Water Area
      - definition [ref=e40]: 0.04 sq mi
      - term [ref=e41]: Total Area
      - definition [ref=e42]: 2.54 sq mi
      - term [ref=e43]: Overlapping Districts
      - definition [ref=e44]: "2"
  - generic [ref=e45]:
    - heading "Congressional Districts" [level=2] [ref=e46]
    - paragraph [ref=e47]: "This ZIP code overlaps with the following congressional districts:"
    - list [ref=e48]:
      - listitem [ref=e49]:
        - link "Oklahoma District 03" [ref=e50] [cursor=pointer]:
          - /url: https://us.elect.info/districts/ok-03/
        - text: (175.95 sq mi overlap)
      - listitem [ref=e51]:
        - link "Oklahoma District 05" [ref=e52] [cursor=pointer]:
          - /url: https://us.elect.info/districts/ok-05/
        - text: (2.54 sq mi overlap)
    - paragraph [ref=e53]: Showing 2 of 2 overlapping districts
  - generic [ref=e54]:
    - heading "Counties" [level=2] [ref=e55]
    - paragraph [ref=e56]: "This ZIP code overlaps with the following counties:"
    - list [ref=e57]:
      - listitem [ref=e58]:
        - link "Canadian County" [ref=e59] [cursor=pointer]:
          - /url: https://us.elect.info/counties/canadian-county-ok/
        - text: (99.33 sq mi overlap)
      - listitem [ref=e60]:
        - link "Kingfisher County" [ref=e61] [cursor=pointer]:
          - /url: https://us.elect.info/counties/kingfisher-county-ok/
        - text: (79.15 sq mi overlap)
    - paragraph [ref=e62]: Showing 2 of 2 overlapping counties
  - contentinfo [ref=e63]:
    - paragraph [ref=e64]:
      - link "elect.info" [ref=e65] [cursor=pointer]:
        - /url: https://us.elect.info/
      - text: "| Data from"
      - link "Federal Election Commission" [ref=e66] [cursor=pointer]:
        - /url: https://us.elect.info/datasources/fec.gov/
      - text: "| Generated 2026-10-23"
```

# Test source

```ts
  1  | import { test, expect } from '@playwright/test';
  2  | 
  3  | /*
  4  |  * /js/geo-map.js boundary maps (sites#470). Congressional District, County, Place and ZIP Code pages loaded a script
  5  |  * that never existed (a console 404 on every page). The renderer's tag now names the entity's GeoJSON; the script
  6  |  * adds a Boundary section with a Leaflet map. Missing shapes (territory delegate districts) add nothing.
  7  |  */
  8  | 
  9  | const PAGES: Array<[string, string]> = [
  10 |   ['/districts/ny-16/', 'overview'],
  11 |   ['/districts/ak-00/', 'overview'],
  12 |   ['/counties/kerr-county-tx/', 'geography'],
  13 |   ['/places/megargel-cdp-al/', 'geography'],
  14 |   ['/postalcodes/73762/', 'overview'],
  15 | ];
  16 | 
  17 | for (const [path, after] of PAGES) {
  18 |   test(`${path}: boundary map, no missing scripts or shapes`, async ({ page }) => {
  19 |     test.setTimeout(60000);
  20 |     const failures: string[] = [];
  21 |     page.on('response', r => {
  22 |       const url = r.url();
  23 |       if (r.status() >= 400 && /\/(js|geo)\//.test(url)) failures.push(`${r.status()} ${url}`);
  24 |     });
  25 |     page.on('pageerror', e => failures.push(e.message));
  26 |     const res = await page.goto(path);
  27 |     expect(res?.status(), `${path} should answer 200`).toBe(200);
  28 |     const tag = page.locator('script[src="/js/geo-map.js"][data-geo-shape]');
> 29 |     await expect(tag).toHaveCount(1);
     |                       ^ Error: expect(locator).toHaveCount(expected) failed
  30 |     expect(await tag.getAttribute('data-geo-shape')).toMatch(/^\/geo\/(districts|counties|places|zcta)\/.+\.geojson$/);
  31 |     await expect(page.locator('section#boundary[data-loaded="true"] .leaflet-container')).toBeVisible({ timeout: 30000 });
  32 |     expect(await page.locator('section#boundary').evaluate(s => s.previousElementSibling?.id)).toBe(after);
  33 |     await expect(page.locator('section#boundary a', { hasText: 'Boundary as GeoJSON' })).toHaveAttribute('href', /\.geojson$/);
  34 |     expect(failures).toEqual([]);
  35 |   });
  36 | }
  37 | 
```