-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Failing regression E2E tests #2337
Conversation
Removed vultr server and associated DNS entries |
8ba6245
to
ad6c480
Compare
if ( | ||
!response.data["organisation-name"] || | ||
!response.data["organisation-id"] | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The missing !
here is my schoolboy error here that caused the latest Uniform submission to fail sorry!
If I can't progress this PR by later today I'll cherry-pick this commit into a new PR to get to prod for re-submission to take place.
@@ -46,7 +46,7 @@ const config: PlaywrightTestConfig = { | |||
webServer: { | |||
command: `pnpm ui`, | |||
port: 3000, | |||
reuseExistingServer: false, | |||
reuseExistingServer: !process.env.CI, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows us to run the React app at localhost:3000
when running Playwright tests and makes for a much better feedback loop than make change → build → re-run tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes in this file represent the fix to get the /pay
routes to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew, thanks for really thorough write up of this one - swr <> react-navi incompatibility was definitely a twist !
Payments and everything else working as expected for me on the pizza, so going to approve this one now and happy for you to merge whenever you decide ready! Please feel free to ping me for re-review if you end up pushing further fixes directly to this branch / or very understandable if you want to temporarily skip newly failing tests & separate changes here 👍
Thanks for the review! I've decided to go ahead and merge this and look into the outstanding issues on a new branch. |
What's the problem?
E2E "Invite to Pay" tests have been failing for a while (and flaky prior to that). Here's a description and video of the bug which was leading to these failures -
/:team/:flow/pay
or/:team/:flow/invite
)Sometime you can hit the error immediately without first encountering the successful page load.
This bug was getting hit in Invite to Pay E2E tests where multiple tabs were being opened and refreshed to check the status of payment requests.
Screen.Recording.2023-10-25.at.08.50.10.mov
What error is being thrown?
It's always some version of the above - please note that
ot
is a minified function name and can change from deploy to deploy. The stack trace however is consistent, and source maps show that it's an error being thrown by our routing libraryreact-navi
. The library is unfortunately deprecated and unmaintained, but having scoured their repo I'm pretty sure that the error matches this unresolved issue - frontarm/navi#174. The error call stack and actual location in the code suggests this.Try as I might, I can't trigger this bug when React is running locally - only once it's built.
I've also spent a lot of time trying to wrap various functions and components in try/catch blocks or
<ErrorBoundary>
s without success to programmatically narrow it down - there's something happening internally in react-navi that we're not being exposed to or isn't bubbling up correctly.No network requests are being made prior to the error being thrown.
What's the cause?
Something within the
route()
ormap()
functions for the/pay
routes is throwing an error - usually the second time the page is loaded. This suggests caching (could be happening at a number of levels) and I spent a good while pursuing this line of thought as well - making sure all calls were not cached via Apollo or any other mechanism.It eventually resorted to a tedious process of commenting out components and functions within the affected routes, rebuilding the React app, and running manual and E2E tests.
Narrowing down pointed to a pretty unlikely suspect -
useSWRMutation()
. If this was commented out, I couldn't replicate the issue - commented in it was consistently recreatable 🤯useSWRMutation()
also has cache options - changing these seemed to have no effect.I don't actually think that this is an issue with
useSWRMutation()
as such, but rather some sort of incompatibility issue withreact-navi
that we're not quite able to see and pick up on.What's the fix?
Replace
useSWRMutation()
withfetch()
and a fewsetState()
hooks and all seems to work as expected. In the medium term I would be very interested in prioritising replacing this library for something stable, maintained, and established.How as this bug introduced?
This is a great question which I wish I had a better answer for.
The first regression test failure related to this on
main
was on the 5th of October. Here's the list of commits from the 4th - nothing obvious here. I've also gone back through recent changes to permissions, routing,teamStore
etc without much avail in finding the cause. Similarlygit bisect
wasn't super helpful - the bug is sort of flaky and I could find it further back than expected.There was a successful regression test run on the 10th of October which demonstrates this "flakiness" - sometimes they pass, sometimes they don't.
So are regression tests passing now?
No 🥲
All E2E tests pass locally, and all previously failing "Invite to pay" test are now passing - see latest run here ✅
Now, two other tests are failing - I'm currently looking into this and hoping for a quick fix!