Skip to content

Fix flaky Dev component polling tests#7289

Merged
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-dev-polling-tests
Apr 14, 2026
Merged

Fix flaky Dev component polling tests#7289
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-dev-polling-tests

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Flaky tests: https://github.com/Shopify/cli/actions/runs/24343909340

FAIL   @shopify/app  src/cli/services/dev/ui/components/Dev.test.tsx > Dev > polls for preview mode
AssertionError: expected 1 to be greater than or equal to 2
 ❯ src/cli/services/dev/ui/components/Dev.test.tsx:511:58
    509|     expect(developerPreview.enable).toHaveBeenCalledTimes(1)
    510|     // fetchMode should be called multiple times due to polling
    511|     expect(developerPreview.fetchMode.mock.calls.length).toBeGreaterTh…
       |                                                          ^
    512| 
    513|     // unmount so that polling is cleared after every test

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL   @shopify/app  src/cli/services/dev/ui/components/Dev.test.tsx > Dev > doesn't poll for preview mode when the app does not support it
AssertionError: expected "spy" to not be called at all, but actually been called 4 times

Received: 

  1st spy call:

    Array []

  2nd spy call:

    Array []

  3rd spy call:

    Array []

  4th spy call:

    Array []



Number of calls: 4

 ❯ src/cli/services/dev/ui/components/Dev.test.tsx:570:44
    568|     `)
    569|     expect(developerPreview.enable).not.toHaveBeenCalled()
    570|     expect(developerPreview.fetchMode).not.toHaveBeenCalled()
       |                                            ^
    571| 
    572|     // Verify 'd' input doesn't trigger update when app doesn't suppor…

WHAT is this pull request doing?

Two timing-dependent test failures are fixed:

  1. 'polls for preview mode': Replaced sleep-based timing with vi.waitFor() to reliably wait for the polling condition instead of hoping 50ms is enough.

  2. 'doesn't poll for preview mode when the app does not support it': Used a locally-scoped mock to isolate from leaked polling intervals from previous tests that call the shared module-level developerPreview mock.

How to test your changes?

CI

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing, so I've added a changelog entry with pnpm changeset add

@gonzaloriestra gonzaloriestra marked this pull request as ready for review April 14, 2026 10:21
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner April 14, 2026 10:21
Two timing-dependent test failures are fixed:

1. 'polls for preview mode': Replaced sleep-based timing with vi.waitFor()
   to reliably wait for the polling condition instead of hoping 50ms is enough.

2. 'doesn't poll for preview mode when the app does not support it': Used a
   locally-scoped mock to isolate from leaked polling intervals from previous
   tests that call the shared module-level developerPreview mock.
@gonzaloriestra gonzaloriestra force-pushed the river-fix-flaky-dev-polling-tests branch from 3f6466e to 25839b9 Compare April 14, 2026 11:55
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit d40f170 Apr 14, 2026
25 checks passed
@gonzaloriestra gonzaloriestra deleted the river-fix-flaky-dev-polling-tests branch April 14, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants