-
Notifications
You must be signed in to change notification settings - Fork 218
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
Update Playwright to use a custom test fixture with global mocks #2196
Conversation
Size Change: 0 B Total Size: 846 kB ℹ️ View Unchanged
|
Full-stack documentation: https://docs.openverse.org/_preview/2196 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
@obulat indeed, there is! I had already written it and forgot to push 🤦 |
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.
Hmm, the eslint
rule doesn't appear to be working for me 😮 I made the following change:
diff --git a/frontend/test/storybook/visual-regression/v-select-field.spec.ts b/frontend/test/storybook/visual-regression/v-select-field.spec.ts
index c759c64af..b0265a671 100644
--- a/frontend/test/storybook/visual-regression/v-select-field.spec.ts
+++ b/frontend/test/storybook/visual-regression/v-select-field.spec.ts
@@ -1,6 +1,4 @@
-import { Page, expect } from "@playwright/test"
-
-import { test } from "~~/test/playwright/utils/test-fixture"
+import { Page, expect, test } from "@playwright/test"
import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
But just lint eslint
is still passing. Is that expected?
@AetherUnbound I will look into the eslint rule! It might be that you need to |
FWIW I ran |
@zackkrida The ESLint rule you added is in the overrides block scoped exclusively to the unit tests (see the |
@sarayourfriend, ah, thanks so much! That's definitely it |
@AetherUnbound thanks to Sara's excellent suggestion this is ready for review 👍 the rule should definitely work now. Edit: And as a perfect test, there was one replacement of the import I missed, that CI caught with the now-working rule 😄 https://github.com/WordPress/openverse/actions/runs/5194737466/jobs/9366737945?pr=2196 |
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.
LGTM! Decided to review to cover Madison while she's at WCEU. Just one small thing and then will be good to go from me.
Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
LGTM once the tests pass 👍 |
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.
Confirmed the lint rule now works (read: breaks correctly) for me! 😄
Looks like there might be some test flake here 😢 I'll confirm on the next run and create the necessary critical issues. |
Creates a
test
fixture which overrides the base Playwright test fixture. This allows for easily setting global route mocks and other settings. Most crucially it removes the thousands of logs cluttering the output about the failed proxying of the analytics server.This PR also makes our provider mocks global and adds a global mock for the analytics event endpoint, to prevent that from outputting hundreds of proxy-related error logs during the run of the test suite.
frontend/test/playwright/utils/test-fixture.ts
is the main thing to review here. The rest is just implementations of the new fixture (switching the import from playwright to our custom test fixture).This will be cleaned up and undrafted once #2194 is merged.Testing instructions
import { test } from "@playwright/test"
and you should be able to observe a lint error.