ONEARMY / community-platform

A platform to build useful communities that aim to tackle global problems
https://platform.onearmy.earth
MIT License
1.14k stars 386 forks source link

fix: flaky routes unit tests #3721

Closed pizzaisdavid closed 2 months ago

pizzaisdavid commented 3 months ago

I only changed the readme, open pull request, and unit test fails:

https://github.com/ONEARMY/community-platform/pull/3720

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/pages/Research/research.routes.test.tsx > research.routes > /research/:slug/edit-update/:id > accept logged in author present
TestingLibraryElementError: Unable to find an element by: [data-testid="/EditResearchUpdate/i"]

Ignored nodes: comments, script, style
<body>
  <div />
</body>

Ignored nodes: comments, script, style
<html>
  <head>
    <title>
      Community Platform
    </title>
  </head>
  <body>
    <div />
  </body>
</html>...
 ❯ Proxy.waitForWrapper node_modules/@testing-library/dom/dist/wait-for.js:166:27
 ❯ src/pages/Research/research.routes.test.tsx:436:13
    434|       })
    435| 
    436|       await waitFor(() => {
       |             ^
    437|         expect(wrapper.getByTestId(/EditResearchUpdate/i)).toBeInTheDo…
    438|       })

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

 Test Files  1 failed | 71 passed (72)
      Tests  1 failed | 389 passed | 1 todo (391)
   Start at  15:49:39
   Duration  50.44s (transform 33.39s, setup 124.36s, collect 444.79s, tests 106.67s, environment 316.69s, prepare 113.16s)
benfurber commented 3 months ago

I think the responsibilities of the router tests are too broad, tidying that up might help (i.e. reducing the scope of the router tests and increasing coverage in the children of the router components).

tuliobluz commented 2 months ago

This issue is happening often in several scenarios of research. Another example

benfurber commented 2 months ago

I think this has been resolved now.