# 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/entities.spec.ts >> us.elect.info entity sections - additional index + detail >> counties section - index and random detail pages
- Location: tests/ui/entities.spec.ts:467:7

# Error details

```
Error: page.goto: net::ERR_CONNECTION_REFUSED at http://10.1.85.212/counties/
Call log:
  - navigating to "http://10.1.85.212/counties/", waiting until "load"

```

# Test source

```ts
  368 |     if (resp.request().method() !== 'POST') return false;
  369 |     const body = resp.request().postData() || '';
  370 |     return body.includes('browseEntities');
  371 |   }, { timeout: DATA_LOAD_TIMEOUT });
  372 |   await page.goto(url);
  373 |   const response = await responsePromise;
  374 |   const json = await response.json();
  375 |   const results = json.data?.browseEntities?.results || [];
  376 |   return results.map((r: { score?: number }) => r.score || 0);
  377 | }
  378 | 
  379 | test.describe('entity browse sort order - quantitative fields', () => {
  380 | 
  381 |   test('candidates sorted by total contributions descending', async ({ page }) => {
  382 |     const scores = await getBrowseScores(page, '/candidates/');
  383 |     expect(scores.length).toBeGreaterThan(1);
  384 |     for (let i = 1; i < scores.length; i++) {
  385 |       expect(scores[i - 1]).toBeGreaterThanOrEqual(scores[i]);
  386 |     }
  387 |   });
  388 | 
  389 |   test('committees sorted by total receipts descending', async ({ page }) => {
  390 |     const scores = await getBrowseScores(page, '/committees/');
  391 |     expect(scores.length).toBeGreaterThan(1);
  392 |     for (let i = 1; i < scores.length; i++) {
  393 |       expect(scores[i - 1]).toBeGreaterThanOrEqual(scores[i]);
  394 |     }
  395 |   });
  396 | 
  397 |   test('vendors sorted by total received descending', async ({ page }) => {
  398 |     const scores = await getBrowseScores(page, '/vendors/');
  399 |     expect(scores.length).toBeGreaterThan(1);
  400 |     for (let i = 1; i < scores.length; i++) {
  401 |       expect(scores[i - 1]).toBeGreaterThanOrEqual(scores[i]);
  402 |     }
  403 |   });
  404 | 
  405 |   test('individuals sorted by total contributions descending', async ({ page, baseURL }) => {
  406 |     await premiumVisitor(page.context(), baseURL); // donor records are premium (sites#277)
  407 |     const scores = await getBrowseScores(page, '/individuals/');
  408 |     expect(scores.length).toBeGreaterThan(1);
  409 |     // A stale search index scores every donor 0 and the order means nothing.
  410 |     expect(scores[0], 'top individual donor should have contributions').toBeGreaterThan(0);
  411 |     for (let i = 1; i < scores.length; i++) {
  412 |       expect(scores[i - 1]).toBeGreaterThanOrEqual(scores[i]);
  413 |     }
  414 |   });
  415 | 
  416 |   test('employers sorted by total employee contributions descending', async ({ page }) => {
  417 |     const scores = await getBrowseScores(page, '/employers/');
  418 |     expect(scores.length).toBeGreaterThan(1);
  419 |     for (let i = 1; i < scores.length; i++) {
  420 |       expect(scores[i - 1]).toBeGreaterThanOrEqual(scores[i]);
  421 |     }
  422 |   });
  423 | });
  424 | 
  425 | test.describe('us.elect.info entity sections - additional index + detail', () => {
  426 | 
  427 |   test('employers section - index and random pages', async ({ page }) => {
  428 |     const indexResponse = await page.goto('/employers/');
  429 |     expect(indexResponse?.status(), '/employers/ should answer 200').toBe(200);
  430 |     await expect(page.locator('h1')).toContainText(/Employers/i);
  431 | 
  432 |     await expect(page.locator('.entity-search-result').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  433 | 
  434 |     const links = await page.locator('.entity-search-result').all();
  435 |     expect(links.length).toBeGreaterThan(0);
  436 | 
  437 |     const hrefs = await Promise.all(links.slice(0, 20).map(l => l.getAttribute('href')));
  438 |     const randomLinks = getRandomItems(hrefs.filter(Boolean) as string[], 3);
  439 | 
  440 |     for (const href of randomLinks) {
  441 |       const entityResponse = await page.goto(toRelativePath(href));
  442 |       expect(entityResponse?.status(), `${toRelativePath(href)} should answer 200`).toBe(200);
  443 |       await expect(page.locator('h1')).toBeVisible();
  444 |     }
  445 |   });
  446 | 
  447 |   test('vendors section - index and random pages', async ({ page }) => {
  448 |     const indexResponse = await page.goto('/vendors/');
  449 |     expect(indexResponse?.status(), '/vendors/ should answer 200').toBe(200);
  450 |     await expect(page.locator('h1')).toContainText(/Vendors/i);
  451 | 
  452 |     await expect(page.locator('.entity-search-result').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  453 | 
  454 |     const links = await page.locator('.entity-search-result').all();
  455 |     expect(links.length).toBeGreaterThan(0);
  456 | 
  457 |     const hrefs = await Promise.all(links.slice(0, 20).map(l => l.getAttribute('href')));
  458 |     const randomLinks = getRandomItems(hrefs.filter(Boolean) as string[], 3);
  459 | 
  460 |     for (const href of randomLinks) {
  461 |       const entityResponse = await page.goto(toRelativePath(href));
  462 |       expect(entityResponse?.status(), `${toRelativePath(href)} should answer 200`).toBe(200);
  463 |       await expect(page.locator('h1')).toBeVisible();
  464 |     }
  465 |   });
  466 | 
  467 |   test('counties section - index and random detail pages', async ({ page }) => {
> 468 |     await page.goto('/counties/');
      |                ^ Error: page.goto: net::ERR_CONNECTION_REFUSED at http://10.1.85.212/counties/
  469 | 
  470 |     // Map view is default — verify Leaflet map renders with GeoJSON state shapes
  471 |     await expect(page.locator('#map.leaflet-container')).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  472 |     await expect(page.locator('#map .leaflet-interactive').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  473 |     const shapes = await page.locator('#map .leaflet-interactive').all();
  474 |     expect(shapes.length).toBeGreaterThan(0);
  475 | 
  476 |     // Switch to List view to test county results and detail navigation
  477 |     await page.locator('.toggle-btn[data-view="list"]').click();
  478 | 
  479 |     // Wait for results to load
  480 |     await page.waitForSelector('.county-result, .county-error', { timeout: DATA_LOAD_TIMEOUT });
  481 |     const results = await page.locator('.county-result').all();
  482 |     expect(results.length).toBeGreaterThan(0);
  483 | 
  484 |     // County results are <a> tags - pick random ones and visit detail pages
  485 |     const hrefs = await Promise.all(results.slice(0, 20).map(r => r.getAttribute('href')));
  486 |     const randomLinks = getRandomItems(hrefs.filter(Boolean) as string[], 3);
  487 | 
  488 |     for (const href of randomLinks) {
  489 |       const entityResponse = await page.goto(toRelativePath(href));
  490 |       expect(entityResponse?.status(), `${toRelativePath(href)} should answer 200`).toBe(200);
  491 |       await expect(page.locator('h1')).toBeVisible();
  492 |     }
  493 |   });
  494 | 
  495 |   test('places section - index and random detail pages', async ({ page }) => {
  496 |     await page.goto('/places/');
  497 | 
  498 |     // Map view is default — verify Leaflet map renders with GeoJSON state shapes
  499 |     await expect(page.locator('#map.leaflet-container')).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  500 |     await expect(page.locator('#map .leaflet-interactive').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  501 |     const shapes = await page.locator('#map .leaflet-interactive').all();
  502 |     expect(shapes.length).toBeGreaterThan(0);
  503 | 
  504 |     // Switch to List view to test place results and detail navigation
  505 |     await page.locator('.toggle-btn[data-view="list"]').click();
  506 | 
  507 |     // Wait for results to load
  508 |     await page.waitForSelector('.place-result, .place-error', { timeout: DATA_LOAD_TIMEOUT });
  509 |     const results = await page.locator('.place-result').all();
  510 |     expect(results.length).toBeGreaterThan(0);
  511 | 
  512 |     // Pick random results and visit detail pages
  513 |     const hrefs = await Promise.all(results.slice(0, 20).map(r => r.getAttribute('href')));
  514 |     const randomLinks = getRandomItems(hrefs.filter(Boolean) as string[], 3);
  515 | 
  516 |     for (const href of randomLinks) {
  517 |       const entityResponse = await page.goto(toRelativePath(href));
  518 |       expect(entityResponse?.status(), `${toRelativePath(href)} should answer 200`).toBe(200);
  519 |       await expect(page.locator('h1')).toBeVisible();
  520 |     }
  521 |   });
  522 | 
  523 |   test('postalcodes section - index and random detail pages', async ({ page }) => {
  524 |     await page.goto('/postalcodes/');
  525 | 
  526 |     // Map view is default — verify Leaflet map renders with GeoJSON state shapes
  527 |     await expect(page.locator('#map.leaflet-container')).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  528 |     await expect(page.locator('#map .leaflet-interactive').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  529 |     const shapes = await page.locator('#map .leaflet-interactive').all();
  530 |     expect(shapes.length).toBeGreaterThan(0);
  531 | 
  532 |     // Switch to List view to test postal code results and detail navigation
  533 |     await page.locator('.toggle-btn[data-view="list"]').click();
  534 | 
  535 |     // Wait for results to load
  536 |     await page.waitForSelector('.postal-result, .postal-error', { timeout: DATA_LOAD_TIMEOUT });
  537 |     const results = await page.locator('.postal-result').all();
  538 |     expect(results.length).toBeGreaterThan(0);
  539 | 
  540 |     // Pick random results and visit detail pages
  541 |     const hrefs = await Promise.all(results.slice(0, 20).map(r => r.getAttribute('href')));
  542 |     const randomLinks = getRandomItems(hrefs.filter(Boolean) as string[], 3);
  543 | 
  544 |     for (const href of randomLinks) {
  545 |       const entityResponse = await page.goto(toRelativePath(href));
  546 |       expect(entityResponse?.status(), `${toRelativePath(href)} should answer 200`).toBe(200);
  547 |       await expect(page.locator('h1')).toBeVisible();
  548 |     }
  549 |   });
  550 | 
  551 |   test('precincts section - map view and state filter', async ({ page }) => {
  552 |     await page.goto('/precincts/');
  553 | 
  554 |     // Map view is default — verify Leaflet map renders with GeoJSON state shapes
  555 |     await expect(page.locator('#map.leaflet-container')).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  556 |     await expect(page.locator('#map .leaflet-interactive').first()).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  557 |     const shapes = await page.locator('#map .leaflet-interactive').all();
  558 |     expect(shapes.length).toBeGreaterThan(0);
  559 | 
  560 |     // Switch to List view to test state filter and precinct results
  561 |     await page.locator('.toggle-btn[data-view="list"]').click();
  562 | 
  563 |     // Select a state first (precincts require state selection)
  564 |     const stateSelect = page.locator('#precinct-state-select');
  565 |     await expect(stateSelect).toBeVisible({ timeout: DATA_LOAD_TIMEOUT });
  566 |     await stateSelect.selectOption('TX');
  567 | 
  568 |     // Wait for precinct results to load
```