Update tests for Nuxt 3 migration #3667
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Split from #3646 by @obulat
This PR can be merged to
main
because it works with both Nuxt 2 and Nuxt 3Description
This PR moves all analytics tests from the unit to Playwright E2E tests. It makes the tests more reliable and also avoid the need to mock the analytics requests in the unit tests (which was causing problems in
@nuxt/test-utils
).The Playwright test setup was refactored to ensure all tests were well set up. Often, Playwright test flakiness is caused by the fact that we are trying to interact with the page before it's been hydrated (hydration means adding the JavaScript event handlers to the server-rendered HTML). So, Playwright was clicking on buttons, but nothing would happen since they didn't yet have event handlers. I've set the button state to
disabled
before they are hydrated (as suggested by Playwright docs) in the Nuxt 3 migration PR. Here, I just added the proper setup for all tests and waited for the "enabled" state.To make the cookies for the UI state easier to handle with the new
useCookie
composable in Nuxt 3, I combined all of them in a singleui
cookie object. This change is added here to the UI store, tests, and theinitFromCookies
calls.For global audio tests, I used HAR recordings to save the audio file, and stop requesting it from the provider on every test run (and prevent flakiness).
The bulk of changed files are the response tapes: I added the CORS header as there were too many CORS-related errors in the tests locally, and sometimes in CI.
Some other changes were related to code cleanup, refactoring to extract common functionality, and removing warnings.
I also normalized the
peaks
in the audio tapes, reducing the number of peaks for each audio to a maximum of 200 (from ~1000), which helped create this image:Testing Instructions
CI should pass, and the test changes should make sense.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin