# 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/money-flow.spec.ts >> money-flow card toggle >> candidate: #ie-oppose card follows the independent-expenditure data
- Location: tests/ui/money-flow.spec.ts:78:9

# Error details

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

Locator:  locator('#funding .mf-toggle')
Expected: 1
Received: 0
Timeout:  15000ms

Call log:
  - Expect "toHaveCount" locator('#funding .mf-toggle') with timeout 15000ms
  - waiting for locator('#funding .mf-toggle')
    34 × locator resolved to 0 elements
       - unexpected value "0"

```

# Page snapshot

```yaml
- generic [active] [ref=e1]:
  - banner [ref=e2]:
    - heading "HARRIS, KAMALA" [level=1] [ref=e3]
    - paragraph [ref=e4]: Democratic Party candidate for President of the United States
    - paragraph [ref=e5]: "FEC ID: P00009423"
    - button "Graph" [ref=e6] [cursor=pointer]
  - link "Log In" [ref=e16] [cursor=pointer]:
    - /url: /outpost.goauthentik.io/start?rd=http%3A%2F%2Fpreview-us-elect-info.electinfo.svc.cluster.local%2Fcandidates%2Fa8897257-430c-2bf3-4498-349021b09ca3%2F
  - generic [ref=e17]:
    - heading "Profile" [level=2] [ref=e18]
    - generic [ref=e19]:
      - term [ref=e20]: Party
      - definition [ref=e21]:
        - link "Democratic Party" [ref=e22] [cursor=pointer]:
          - /url: https://preview.elect.info/parties/democratic/
      - term [ref=e23]: Office
      - definition [ref=e24]:
        - link "President of the United States" [ref=e25] [cursor=pointer]:
          - /url: https://preview.elect.info/offices/president/
      - term [ref=e26]: Status
      - definition [ref=e27]: Prior Candidate (Not Current) (Challenger)
      - term [ref=e28]: Home Location
      - definition [ref=e29]: PHILADELPHIA, Pennsylvania 19102
  - generic [ref=e30]:
    - heading "Campaign Timeline" [level=2] [ref=e31]
    - generic [ref=e32]:
      - term [ref=e33]: Election Years
      - definition [ref=e34]:
        - generic [ref=e35]:
          - link "2026" [ref=e36] [cursor=pointer]:
            - /url: https://preview.elect.info/elections/2026/
          - text: ","
          - link "2024" [ref=e37] [cursor=pointer]:
            - /url: https://preview.elect.info/elections/2024/
          - text: ","
          - link "2022" [ref=e38] [cursor=pointer]:
            - /url: https://preview.elect.info/elections/2022/
          - text: ","
          - link "2020" [ref=e39] [cursor=pointer]:
            - /url: https://preview.elect.info/elections/2020/
      - term [ref=e40]: First Campaign
      - definition [ref=e41]: "2020"
      - term [ref=e42]: Most Recent
      - definition [ref=e43]: "2024"
  - generic [ref=e44]:
    - heading "Campaign Funding" [level=2] [ref=e45]
    - generic [ref=e46]:
      - term [ref=e47]: Total Received
      - definition [ref=e48]:
        - strong [ref=e49]: $4.6M
      - term [ref=e50]: Contributing Committees
      - definition [ref=e51]: "6715"
    - heading "Top Contributors" [level=3] [ref=e52]
    - table [ref=e53]:
      - rowgroup [ref=e54]:
        - row [ref=e55]:
          - columnheader "Committee" [ref=e56]
          - columnheader "Amount" [ref=e57]
          - columnheader "Contributions" [ref=e58]
          - columnheader "Cycles" [ref=e59]
      - rowgroup [ref=e60]:
        - row [ref=e61]:
          - cell [ref=e62]:
            - link "DNC SERVICES CORP / DEMOCRATIC NATIONAL COMMITTEE" [ref=e63] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/dnc-services-corp-democratic-national-committee-c00010603/
          - cell "$3.8M" [ref=e64]
          - cell "39" [ref=e65]
          - cell [ref=e66]:
            - generic [ref=e67]:
              - link "2024" [ref=e68] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2024/
              - text: ","
              - link "2026" [ref=e69] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2026/
        - row [ref=e70]:
          - cell [ref=e71]:
            - link "ALPHA KAPPA ALPHA SORORITY PAC, INC. (AKA AKA 1908 PAC)" [ref=e72] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/alpha-kappa-alpha-sorority-pac-inc-aka-aka-1908-pac-c00886036/
          - cell "$457K" [ref=e73]
          - cell "6,403" [ref=e74]
          - cell [ref=e75]:
            - link "2024" [ref=e77] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e78]:
          - cell [ref=e79]:
            - link "PROGRESSIVE VICTORY PAC" [ref=e80] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/progressive-victory-pac-c00821348/
          - cell "$49K" [ref=e81]
          - cell "3" [ref=e82]
          - cell [ref=e83]:
            - link "2024" [ref=e85] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e86]:
          - cell [ref=e87]:
            - link "DEMOCRATIC WOMEN OF SANTA BARBARA COUNTY" [ref=e88] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/democratic-women-of-santa-barbara-county-c00399444/
          - cell "$20K" [ref=e89]
          - cell "1" [ref=e90]
          - cell [ref=e91]:
            - link "2024" [ref=e93] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e94]:
          - cell [ref=e95]:
            - link "JSTREETPAC" [ref=e96] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/jstreetpac-c00441949/
          - cell "$17K" [ref=e97]
          - cell "88" [ref=e98]
          - cell [ref=e99]:
            - link "2024" [ref=e101] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e102]:
          - cell [ref=e103]:
            - link "MI FAMILIA DECIDE PAC" [ref=e104] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/mi-familia-decide-pac-c00882019/
          - cell "$10K" [ref=e105]
          - cell "1" [ref=e106]
          - cell [ref=e107]:
            - link "2024" [ref=e109] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e110]:
          - cell [ref=e111]:
            - link "PLANNED PARENTHOOD ACTION FUND INC PAC, DBA PLANNED PARENTHOOD FEDERAL PAC" [ref=e112] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/planned-parenthood-action-fund-inc-pac-dba-planned-parenthood-federal-pac-c00314617/
          - cell "$8K" [ref=e113]
          - cell "25" [ref=e114]
          - cell [ref=e115]:
            - link "2024" [ref=e117] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e118]:
          - cell [ref=e119]:
            - link "TOM STEYER 2020" [ref=e120] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/tom-steyer-2020-c00711614/
          - cell "$8K" [ref=e121]
          - cell "2" [ref=e122]
          - cell [ref=e123]:
            - link "2020" [ref=e125] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2020/
        - row [ref=e126]:
          - cell [ref=e127]:
            - link "PROFESSIONAL ENGINEERS IN CALIFORNIA GOVERNMENT FEDERAL PAC (PECG FED-PAC)" [ref=e128] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/professional-engineers-in-california-government-federal-pac-pecg-fed-pac-c00459800/
          - cell "$8K" [ref=e129]
          - cell "4" [ref=e130]
          - cell [ref=e131]:
            - generic [ref=e132]:
              - link "2024" [ref=e133] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2024/
              - text: ","
              - link "2020" [ref=e134] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2020/
        - row [ref=e135]:
          - cell [ref=e136]:
            - link "END CITIZENS UNITED" [ref=e137] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/end-citizens-united-c00573261/
          - cell "$6K" [ref=e138]
          - cell "5" [ref=e139]
          - cell [ref=e140]:
            - generic [ref=e141]:
              - link "2024" [ref=e142] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2024/
              - text: ","
              - link "2020" [ref=e143] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2020/
    - paragraph [ref=e144]: Showing top 10 of 78
  - generic [ref=e145]:
    - heading "Independent Expenditures Supporting" [level=2] [ref=e146]
    - paragraph [ref=e147]: Spending by outside groups for this candidate, made independently of the campaign. Not a contribution to the campaign.
    - table [ref=e148]:
      - rowgroup [ref=e149]:
        - row [ref=e150]:
          - columnheader "Committee" [ref=e151]
          - columnheader "Amount" [ref=e152]
          - columnheader "Contributions" [ref=e153]
          - columnheader "Cycles" [ref=e154]
      - rowgroup [ref=e155]:
        - row [ref=e156]:
          - cell [ref=e157]:
            - link "FF PAC" [ref=e158] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/ff-pac-c00669259/
          - cell "$443.5M" [ref=e159]
          - cell "362" [ref=e160]
          - cell [ref=e161]:
            - link "2024" [ref=e163] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e164]:
          - cell [ref=e165]:
            - link "BLACKPAC" [ref=e166] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/blackpac-c00609388/
          - cell "$19.1M" [ref=e167]
          - cell "89" [ref=e168]
          - cell [ref=e169]:
            - link "2024" [ref=e171] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e172]:
          - cell [ref=e173]:
            - link "LF PAC" [ref=e174] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/lf-pac-c00804856/
          - cell "$14.4M" [ref=e175]
          - cell "349" [ref=e176]
          - cell [ref=e177]:
            - link "2024" [ref=e179] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e180]:
          - cell [ref=e181]:
            - link "YOUR COMMUNITY PAC" [ref=e182] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/your-community-pac-c00886614/
          - cell "$12.7M" [ref=e183]
          - cell "17" [ref=e184]
          - cell [ref=e185]:
            - link "2024" [ref=e187] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e188]:
          - cell [ref=e189]:
            - link "SOMOS PAC" [ref=e190] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/somos-pac-c00724203/
          - cell "$12.3M" [ref=e191]
          - cell "113" [ref=e192]
          - cell [ref=e193]:
            - link "2024" [ref=e195] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e196]:
          - cell [ref=e197]:
            - link "ONE FOR ALL COMMITTEE" [ref=e198] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/one-for-all-committee-c00752691/
          - cell "$10.3M" [ref=e199]
          - cell "24" [ref=e200]
          - cell [ref=e201]:
            - link "2024" [ref=e203] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e204]:
          - cell [ref=e205]:
            - link "CFFE PAC" [ref=e206] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/cffe-pac-c00744920/
          - cell "$7.3M" [ref=e207]
          - cell "79" [ref=e208]
          - cell [ref=e209]:
            - link "2024" [ref=e211] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e212]:
          - cell [ref=e213]:
            - link "LCV VICTORY FUND" [ref=e214] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/lcv-victory-fund-c00486845/
          - cell "$6.5M" [ref=e215]
          - cell "117" [ref=e216]
          - cell [ref=e217]:
            - link "2024" [ref=e219] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e220]:
          - cell [ref=e221]:
            - link "NATIONAL NURSES UNITED FOR PATIENT PROTECTION" [ref=e222] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/national-nurses-united-for-patient-protection-c00490375/
          - cell "$4.8M" [ref=e223]
          - cell "50" [ref=e224]
          - cell [ref=e225]:
            - generic [ref=e226]:
              - link "2024" [ref=e227] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2024/
              - text: ","
              - link "2026" [ref=e228] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2026/
        - row [ref=e229]:
          - cell [ref=e230]:
            - link "SEIU COPE (SERVICE EMPLOYEES INTERNATIONAL UNION COMMITTEE ON POLITICAL EDUCATION)" [ref=e231] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/seiu-cope-service-employees-international-union-committee-on-political-education-c00004036/
          - cell "$4.1M" [ref=e232]
          - cell "90" [ref=e233]
          - cell [ref=e234]:
            - generic [ref=e235]:
              - link "2024" [ref=e236] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2024/
              - text: ","
              - link "2026" [ref=e237] [cursor=pointer]:
                - /url: https://preview.elect.info/elections/2026/
    - paragraph [ref=e238]: Showing top 10 of 292
  - generic [ref=e239]:
    - heading "Independent Expenditures Opposing" [level=2] [ref=e240]
    - paragraph [ref=e241]: Spending by outside groups against this candidate, made independently of any campaign.
    - table [ref=e242]:
      - rowgroup [ref=e243]:
        - row [ref=e244]:
          - columnheader "Committee" [ref=e245]
          - columnheader "Amount" [ref=e246]
          - columnheader "Contributions" [ref=e247]
          - columnheader "Cycles" [ref=e248]
      - rowgroup [ref=e249]:
        - row [ref=e250]:
          - cell [ref=e251]:
            - link "MAKE AMERICA GREAT AGAIN INC." [ref=e252] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/make-america-great-again-inc-c00825851/
          - cell "$251.8M" [ref=e253]
          - cell "119" [ref=e254]
          - cell [ref=e255]:
            - link "2024" [ref=e257] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e258]:
          - cell [ref=e259]:
            - link "PRESERVE AMERICA PAC" [ref=e260] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/preserve-america-pac-c00878801/
          - cell "$112.3M" [ref=e261]
          - cell "29" [ref=e262]
          - cell [ref=e263]:
            - link "2024" [ref=e265] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e266]:
          - cell [ref=e267]:
            - link "AMERICA PAC" [ref=e268] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/america-pac-c00879510/
          - cell "$54.2M" [ref=e269]
          - cell "212" [ref=e270]
          - cell [ref=e271]:
            - link "2024" [ref=e273] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e274]:
          - cell [ref=e275]:
            - link "RIGHT FOR AMERICA" [ref=e276] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/right-for-america-c00867036/
          - cell "$51.1M" [ref=e277]
          - cell "34" [ref=e278]
          - cell [ref=e279]:
            - link "2024" [ref=e281] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e282]:
          - cell [ref=e283]:
            - link "RESTORATION OF AMERICA PAC" [ref=e284] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/restoration-of-america-pac-c00571588/
          - cell "$27.0M" [ref=e285]
          - cell "23" [ref=e286]
          - cell [ref=e287]:
            - link "2024" [ref=e289] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e290]:
          - cell [ref=e291]:
            - link "DUTY TO AMERICA PAC" [ref=e292] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/duty-to-america-pac-c00881987/
          - cell "$23.2M" [ref=e293]
          - cell "36" [ref=e294]
          - cell [ref=e295]:
            - link "2024" [ref=e297] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e298]:
          - cell [ref=e299]:
            - link "RJC VICTORY FUND" [ref=e300] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/rjc-victory-fund-c00528554/
          - cell "$10.0M" [ref=e301]
          - cell "18" [ref=e302]
          - cell [ref=e303]:
            - link "2024" [ref=e305] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e306]:
          - cell [ref=e307]:
            - link "BUCKEYE VALUES PAC" [ref=e308] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/buckeye-values-pac-c00834630/
          - cell "$5.6M" [ref=e309]
          - cell "5" [ref=e310]
          - cell [ref=e311]:
            - link "2024" [ref=e313] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e314]:
          - cell [ref=e315]:
            - link "WOMEN SPEAK OUT PAC" [ref=e316] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/women-speak-out-pac-c00530766/
          - cell "$2.6M" [ref=e317]
          - cell "69" [ref=e318]
          - cell [ref=e319]:
            - link "2024" [ref=e321] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
        - row [ref=e322]:
          - cell [ref=e323]:
            - link "MAHA ALLIANCE" [ref=e324] [cursor=pointer]:
              - /url: https://preview.elect.info/committees/maha-alliance-c00888172/
          - cell "$2.0M" [ref=e325]
          - cell "15" [ref=e326]
          - cell [ref=e327]:
            - link "2024" [ref=e329] [cursor=pointer]:
              - /url: https://preview.elect.info/elections/2024/
    - paragraph [ref=e330]: Showing top 10 of 79
  - contentinfo [ref=e331]:
    - paragraph [ref=e332]:
      - link "elect.info" [ref=e333] [cursor=pointer]:
        - /url: https://preview.elect.info/
      - text: "| Data from"
      - link "Federal Election Commission" [ref=e334] [cursor=pointer]:
        - /url: https://preview.elect.info/datasources/fec_bulk/
      - text: "| Generated 2026-10-13"
```

# Test source

```ts
  1   | import { test, expect } from '@playwright/test';
  2   | 
  3   | // Money-flow Sankey (electinfo/sites#178). nginx injects /js/money-flow.js
  4   | // into Candidate and Committee detail pages served from the static-pages
  5   | // mount; the us-pages renderer (sites#210, on preview) writes the same tag
  6   | // into the pages it renders. The script fetches moneyFlow from /api/graphql and gives each money
  7   | // card a Sankey | Table toggle, Sankey by default.
  8   | //
  9   | // Every us target has these pages and a moneyFlow API: the CI test pod mounts
  10  | // the production static pages and proxies to api-graphql, and preview serves
  11  | // beta-pages through api-graphql-preview. So the specs run everywhere, on the
  12  | // DNC and Harris pages, and check that no other kind of page gets the script.
  13  | 
  14  | const SCRIPT = '<script src="/js/money-flow.js" defer></script>';
  15  | const DNC = '/committees/a75a9110-f1db-a945-39a8-7503ed3c04da/'; // C00010603
  16  | const HARRIS = '/candidates/a8897257-430c-2bf3-4498-349021b09ca3/'; // P00009423
  17  | const OTHER_PAGES = [
  18  |   '/states/032f8d61-f554-f435-2a6d-50b3c8cc01d7/', // AK
  19  |   '/elections/2024/',
  20  |   '/offices/president/',
  21  |   '/districts/ak/00/',
  22  | ];
  23  | 
  24  | test.describe('money-flow script injection', () => {
  25  |   for (const path of [DNC, HARRIS]) {
  26  |     test(`injected once on ${path}`, async ({ request }) => {
  27  |       const res = await request.get(path);
  28  |       expect(res.status()).toBe(200);
  29  |       const html = await res.text();
  30  |       expect(html.split(SCRIPT).length - 1).toBe(1);
  31  |     });
  32  |   }
  33  | 
  34  |   for (const path of OTHER_PAGES) {
  35  |     test(`not injected on ${path}`, async ({ request }) => {
  36  |       const res = await request.get(path);
  37  |       expect(res.status()).toBe(200);
  38  |       expect(await res.text()).not.toContain('money-flow.js');
  39  |     });
  40  |   }
  41  | });
  42  | 
  43  | test.describe('money-flow card toggle', () => {
  44  |   test('committee: each money card defaults to the Sankey', async ({ page }) => {
  45  |     const errors: string[] = [];
  46  |     page.on('pageerror', (e) => errors.push(String(e)));
  47  |     await page.goto(DNC);
  48  |     for (const id of ['incoming', 'outgoing', 'funded']) {
  49  |       const card = page.locator(`#${id}`);
  50  |       await expect(card.locator('.money-flow-chart canvas')).toHaveCount(1, { timeout: 15000 });
  51  |       await expect(card.locator('.mf-view-btn[data-view="sankey"]')).toHaveAttribute('aria-pressed', 'true');
  52  |       await expect(card.locator('ul.candidate-list')).toBeHidden();
  53  |     }
  54  |     await expect(page.locator('#supported .mf-toggle')).toHaveCount(0);
  55  |     expect(errors).toEqual([]);
  56  |   });
  57  | 
  58  |   test('candidate: Top Contributors toggles between Sankey and table', async ({ page }) => {
  59  |     await page.goto(HARRIS);
  60  |     const card = page.locator('#funding');
  61  |     await expect(card.locator('.money-flow-chart canvas')).toHaveCount(1, { timeout: 15000 });
  62  |     await expect(card.locator('table')).toBeHidden();
  63  |     await card.locator('.mf-view-btn[data-view="table"]').click();
  64  |     await expect(card.locator('table')).toBeVisible();
  65  |     await expect(card.locator('.money-flow-chart')).toBeHidden();
  66  |     await expect(card.locator('.mf-view-btn[data-view="table"]')).toHaveAttribute('aria-pressed', 'true');
  67  |   });
  68  | 
  69  |   // Independent expenditures (rundeck#757): each card is a Sankey once the graph
  70  |   // has IE_SUPPORTS / IE_OPPOSES edges, and keeps its static list until then.
  71  |   // Pages generated before the sections existed have none to mount.
  72  |   for (const [label, path, fecId, sectionId, side] of [
  73  |     ['candidate', HARRIS, 'P00009423', 'ie-support', 'ie-in'],
  74  |     ['committee', DNC, 'C00010603', 'ie-support', 'ie-out'],
  75  |     ['candidate', HARRIS, 'P00009423', 'ie-oppose', 'ie-opp-in'],
  76  |     ['committee', DNC, 'C00010603', 'ie-oppose', 'ie-opp-out'],
  77  |   ] as const) {
  78  |     test(`${label}: #${sectionId} card follows the independent-expenditure data`, async ({ page, request }) => {
  79  |       const errors: string[] = [];
  80  |       page.on('pageerror', (e) => errors.push(String(e)));
  81  |       const res = await request.post('/api/graphql', {
  82  |         data: { query: 'query($f: String!) { moneyFlow(fecId: $f) { nodes { side } } }', variables: { f: fecId } },
  83  |       });
  84  |       const nodes: { side: string }[] = (await res.json())?.data?.moneyFlow?.nodes ?? [];
  85  |       const ieNodes = nodes.filter((n) => n.side === side).length;
  86  | 
  87  |       await page.goto(path);
  88  |       const card = page.locator(`#${sectionId}`);
  89  |       // the contribution cards are mounted first, so wait for them before judging the IE card
> 90  |       await expect(page.locator(label === 'candidate' ? '#funding .mf-toggle' : '#incoming .mf-toggle')).toHaveCount(1, { timeout: 15000 });
      |                                                                                                          ^ Error: expect(locator).toHaveCount(expected) failed
  91  |       if ((await card.count()) === 0) {
  92  |         expect(errors).toEqual([]);
  93  |         return;
  94  |       }
  95  |       const list = card.locator(label === 'candidate' ? 'table' : 'ul.candidate-list');
  96  |       if (ieNodes > 0) {
  97  |         await expect(card.locator('.money-flow-chart canvas')).toHaveCount(1, { timeout: 15000 });
  98  |         await expect(list).toBeHidden();
  99  |       } else {
  100 |         await expect(card.locator('.mf-toggle')).toHaveCount(0);
  101 |         await expect(list).toBeVisible();
  102 |       }
  103 |       expect(errors).toEqual([]);
  104 |     });
  105 |   }
  106 | });
  107 | 
```