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 E2E locally #99
Fix E2E locally #99
Conversation
👋 @mokagio! Coincidentally, I am working on Playwright project right now 😄 Not an expert but have spent enough time on it to hopefully help if you have questions
I'm not sure if you have this set already, one way to debug in CI is to record the test execution in CI (or as Playwright calls it, a trace), return it as an artifact on the build and analyze it with trace viewer. It's very similar to the |
@jostnes legend! I configured traces in this PR and made CI store them as artifacts but I didn't know how to open them 🤦♂️ Update for future reference, as the logs show, you can also open Playwright traces locally with |
🤔 The trace doesn't show the application window... This is something I also noticed while using the UI mode ( |
Hmm I've not used it for testing an Electron app yet but there's this in the docs:
the blank screen looks like the launch might have failed? |
Ping @Automattic/yolo . From the lack of action in this PR I wonder how much E2E tests are currently used. I am a strong testing advocate and would usually argue for more testing rather than less. But... E2E, UI-driven tests are notoriously temperamental and often flaky. If the team is not ready so maintain them, then I would suggest switching them off. My preferred outcome would be for these to be looked at, for a way to fix them in CI to be identified, and for E2E to become a core part of the feedback loop. But if we're not at the stage in the project where we can focus on that, then I don't see the point in dragging this along. Counter argument: The longer you wait, the harder it gets to set them up because of app complexity and non-test-friendly design inevitably sneaking in. Counter-counter argument: If UI and UX are in flux, then one will spend a lot of time updating E2E page objects; sometimes is better to wait till UI/UX is established. |
I think having at least an E2E testing framework with basic tests that run and succeed is beneficial. Thus, let's maintain what we have and add more tests for critical paths when time allows. Regarding current diff, I ran tests on my local and the delete site failed:
It may be related to the recent change, #27, where we removed the custom dialog for deleting site confirmation and used the system dialog instead. |
Sounds good!
I was aware of #27 and even rebased on top of a version of I can reproduce the failure with This is a tangent, but I wonder if there's a way to check that the artifact on which we run the E2E tests is up to date? Running |
@mokagio I checked it more, and it seems that we can't currently use Playwright to test native dialogs opened by Electron (microsoft/playwright#21432). I disabled this test for now, and the remaining E2E tests are passing. However, as we don't know when we could make it work, does it make more sense to delete that test instead? |
Thanks @wojtekn !
Up to you. I like that Playwright (or the underlying test runner) has a I would keep it there. For reference, I had a go at implementing a check for --- a/src/components/delete-site.tsx
+++ b/src/components/delete-site.tsx
@@ -29,6 +29,14 @@ const DeleteSite = () => {
const trimmedSiteTitle = getTrimmedSiteTitle( selectedSite.name );
+ if ( process.env.E2E ) {
+ try {
+ await deleteSite(selectedSite.id, true);
+ } catch (error) {
+ await showErrorMessageBox(error, trimmedSiteTitle);
+ }
+ return;
+ }
+
const { response, checkboxChecked } = await getIpcApi().showMessageBox( {
type: 'warning',
message: sprintf( __( 'Delete %s' ), trimmedSiteTitle ), Unfortunately, I learned from it that Another idea I had, inspired by something I read in a comment in one Playwright-adjacent project which unfortunately I didn't track down at the time. would be to introduce a mock for the system dialog for the context of the E2E tests. What I'm thinking is something we could call in place of or internally to |
@mokagio thanks for trying that and for sharing some ideas. I will merge this one to let us proceed with other E2E fixes. I also added https://github.com/Automattic/dotcom-forge/issues/7236 to tackle delete site test issue. |
Related to #37. This is a cherry pick of the work from #76 but without the CI part.
I'm not sure how to debug the CI failures yet, so I thought I'd get these fixes reviewed and landed in the meantime.
cc @Automattic/apps-quality-team. Has any of you ever worked with Playwright? It's pretty cool and similar to the kind of syntax sugar we tried to add on top of XCTest with XCUITestHelpers. It was also good to see these tests used the page object pattern, like what we tried to encourage on the mobile apps and with ScreenObject
Proposed Changes
Updates the E2E tests to work locally.
Testing Instructions
Run
npm install && npm run e2e
, it should pass:Pre-merge Checklist