# 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/map-insets.spec.ts >> /counties/ map draws AK, HI and DC insets and drills in from a label
- Location: tests/ui/map-insets.spec.ts:20:7

# Error details

```
Error: apiRequestContext.get: connect ECONNREFUSED 10.1.105.22:80
Call log:
  - → GET http://10.1.105.22/geo/states/us-states.geojson
    - user-agent: Playwright/1.64.1 (x64; ubuntu 22.04) node/20.9 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br

```

# Test source

```ts
  1  | import { test, expect } from '@playwright/test';
  2  | import { skipIfPremiumGated } from './helpers';
  3  | 
  4  | /*
  5  |  * Relocated states on the Leaflet map pages (electinfo/rundeck#852).
  6  |  *
  7  |  * The states view opens on the contiguous 48. Alaska, Hawaii and Puerto Rico
  8  |  * are drawn again, scaled and moved into open water in roughly their true
  9  |  * direction, dashed and labelled; DC gets a labelled marker. Clicking a label
  10 |  * fires the click of the state's real outline, so the drill-in uses the real
  11 |  * bounds and each page's own rules apply (precincts: HI has no VTD data, so
  12 |  * its click is a no-op there). The insets show at the national zoom only.
  13 |  * A jurisdiction with no boundary file yet (PR until GeoShapeImageSync has
  14 |  * run) simply has no inset.
  15 |  */
  16 | 
  17 | const PAGES = ['/districts/', '/counties/', '/places/', '/postalcodes/', '/tracts/', '/precincts/', '/blocks/'];
  18 | 
  19 | for (const path of PAGES) {
  20 |   test(`${path} map draws AK, HI and DC insets and drills in from a label`, async ({ page, request }) => {
  21 |     test.setTimeout(90000);
  22 |     if (path === '/blocks/') await skipIfPremiumGated(request, path);
> 23 |     const geo = await request.get('/geo/states/us-states.geojson');
     |                               ^ Error: apiRequestContext.get: connect ECONNREFUSED 10.1.105.22:80
  24 |     test.skip(geo.status() !== 200, 'state boundaries are not served in this environment');
  25 | 
  26 |     const res = await page.goto(path);
  27 |     expect(res?.status(), `${path} should answer 200`).toBe(200);
  28 |     await page.locator('.toggle-btn[data-view="map"]').click();
  29 | 
  30 |     const labels = page.locator('.map-inset-label');
  31 |     await expect(labels.first()).toBeVisible({ timeout: 30000 });
  32 |     for (const code of ['ak', 'hi', 'dc']) {
  33 |       await expect(page.locator(`.map-inset-label[data-state="${code}"]`)).toBeVisible();
  34 |     }
  35 | 
  36 |     // Alaska has shapes and precinct data on every page, so its label drills in.
  37 |     await page.locator('.map-inset-label[data-state="ak"]').click();
  38 |     await expect(labels).toHaveCount(0);
  39 |     await expect(page.locator('.map-back-btn').first()).toBeVisible({ timeout: 15000 });
  40 |   });
  41 | }
  42 | 
  43 | // /states/ has no drill-in: a state click opens its page, so the AK label
  44 | // lands on /states/ak/, which may redirect to the canonical /states/alaska/.
  45 | // The opening view frames the 48 and every inset.
  46 | test('/states/ map frames AK, HI and DC insets and a label opens the state page', async ({ page, request }) => {
  47 |   test.setTimeout(90000);
  48 |   const geo = await request.get('/geo/states/us-states.geojson');
  49 |   test.skip(geo.status() !== 200, 'state boundaries are not served in this environment');
  50 | 
  51 |   const res = await page.goto('/states/');
  52 |   expect(res?.status(), '/states/ should answer 200').toBe(200);
  53 |   await page.locator('.toggle-btn[data-view="map"]').click();
  54 | 
  55 |   await expect(page.locator('.map-inset-label').first()).toBeVisible({ timeout: 30000 });
  56 |   const map = await page.locator('#map').boundingBox();
  57 |   const codes = (await geo.json()).features.map((f: any) => f.properties.code);
  58 |   for (const code of ['ak', 'hi', 'dc', 'pr'].filter(c => codes.includes(c))) {
  59 |     const label = page.locator(`.map-inset-label[data-state="${code}"]`);
  60 |     await expect(label).toBeVisible();
  61 |     const box = await label.boundingBox();
  62 |     expect(box && map && box.x >= map.x && box.x + box.width <= map.x + map.width
  63 |       && box.y >= map.y && box.y + box.height <= map.y + map.height, `${code} label inside the map frame`).toBeTruthy();
  64 |   }
  65 | 
  66 |   await page.locator('.map-inset-label[data-state="ak"]').click();
  67 |   await expect(page).toHaveURL(/\/states\/(ak|alaska)\/$/);
  68 | });
  69 | 
```