# 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 >> /places/megargel-cdp-al/: 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 "Megargel, Alabama" [level=1] [ref=e3]
    - paragraph [ref=e4]: CDP (Census Designated Place)
  - 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%2Fplaces%2Fmegargel-cdp-al%2F
        - link "Create an account" [ref=e11] [cursor=pointer]:
          - /url: /signin/register?rd=https%3A%2F%2Fus.elect.info%2Fplaces%2Fmegargel-cdp-al%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]: Place Name
      - definition [ref=e36]: Megargel
      - term [ref=e37]: Place Type
      - definition [ref=e38]: CDP (Census Designated Place)
      - term [ref=e39]: State
      - definition [ref=e40]:
        - link "Alabama" [ref=e41] [cursor=pointer]:
          - /url: https://us.elect.info/states/alabama/
      - term [ref=e42]: FIPS Code
      - definition [ref=e43]: "0147848"
      - term [ref=e44]: State FIPS
      - definition [ref=e45]: "01"
      - term [ref=e46]: Place FIPS
      - definition [ref=e47]: "47848"
  - generic [ref=e48]:
    - heading "Geography" [level=2] [ref=e49]
    - generic [ref=e50]:
      - term [ref=e51]: Land Area
      - definition [ref=e52]: 0.69 sq mi
      - term [ref=e53]: Water Area
      - definition [ref=e54]: 0.00 sq mi
      - term [ref=e55]: Total Area
      - definition [ref=e56]: 0.69 sq mi
      - term [ref=e57]: Latitude
      - definition [ref=e58]: "31.378141"
      - term [ref=e59]: Longitude
      - definition [ref=e60]: "-87.430649"
  - contentinfo [ref=e61]:
    - paragraph [ref=e62]:
      - link "elect.info" [ref=e63] [cursor=pointer]:
        - /url: https://us.elect.info/
      - text: "| Data from"
      - link "Federal Election Commission" [ref=e64] [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 | 
```