-
Notifications
You must be signed in to change notification settings - Fork 21
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
E2E tests: Dashboard - Edit Free Listings #2080
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #2080 +/- ##
=========================================
Coverage 58.3% 58.3%
Complexity 4118 4118
=========================================
Files 454 454
Lines 17683 17683
=========================================
Hits 10304 10304
Misses 7379 7379
Flags with carried forward coverage won't be shown. Click here to find out more. |
The JS linting is complaining about this:
However, when I run It seems related to this: https://stackoverflow.com/questions/67702186/prettier-ask-me-to-replace-with, I will have a look at it tomorrow. |
The prettier packages were updated in #2069. Rebasing onto the current |
I have a question about this approach. For the conversion ID it's possible to both set and unset the conversion ID, which in the case of the GTag tests it's set through |
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.
Thanks for adding the tests, especially the shared util classes so other tests can use them. I've tested it and the tests are working as expected. Just added a async
await
suggestion in the comment.
Since you are able to reproduce this at least some of the time could you try to see if some tweaks would work? One such suggestion would be to map the plugin to a separate folder instead of having it directly in
Another suggestion would be to clear cache. As |
@mikkamp, thanks for your comment:
That was my first idea. However, the issue I encountered was that Playwright uses multiple workers to execute tests. This means that, for instance, the I think that if you make another test that needs the ADS_CONVERSION_ACTION option to be blank, you may encounter the problem because
I agree that currently, this filter is only used for E2E tests. However, I don't see needing multiple filters since the extensions mainly use REST endpoints, which can be easily simulated with Playwright. For example, when dealing with MC accounts and other accounts, we're using this approach: https://github.com/woocommerce/google-listings-and-ads/pull/2080/files#diff-f64b9525d898297dabb242cc89a61158db06de7159c4ec987ca62f6bb790e143R56-R74.
Thanks for all your suggestions! The issue is intermittent but I will try with those suggestions to see if it fixes it. |
Thanks for the clarification, I forgot about that part and was originally contemplating turning that off like is done in Bookings when run for CI. Having a closer look now at the filter it seems you only do so when a query parameter is being set and not persistently, which seems like a workable solution and not too intrusive. I'm just wondering if that technique will eventually contribute to more code to handle certain states while supporting parallel tests, and whether just turning off parallel would simplify things. |
…te the onboarding status
Thanks @ianlin for your time reviewing this PR. I have updated the below points in this PR:
Would you mind to take a look? Thanks! |
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.
Thanks for the extra changes. I tested it again and everything passed as expected. Just left some non-blocking questions and suggestions in the comment below.
Note that during the review I also encountered this problem #2043 (review). I had to restart the container to make it work again. I tried to delete the plugins cache using wp cli in the container but still didn't work so I think those potential fixes @mikkamp suggested also require restarting the container so it makes it a bit tricky to verify if the fixes work. I'll keep trying it when developing other e2e tests.
} ); | ||
|
||
test( 'Check recommended shipping settings', async () => { | ||
editFreeListingsPage = new EditFreeListingsPage( page ); |
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.
While the test is configured to run serial, I think it'd still be better to move this line to beforeAll()
like dashboardPage
.
* @return {Promise<import('@playwright/test').Request[]>} The requests. | ||
*/ | ||
registerSavingRequests() { | ||
const targetAudienteRequest = this.page.waitForRequest( |
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.
Typo: should be "Audience".
|
||
const syncRequest = this.page.waitForRequest( | ||
( request ) => | ||
request.url().includes( '/gla/mc/settings/sync' ) && |
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.
❔We didn't mock this request /gla/mc/settings/sync
and by running npm run test:e2e-dev tests/e2e/specs/dashboard/edit-free-listings.test.js
I saw this request returned 500
server error with the message Please reconnect your Jetpack account.
. Although the test still passed since we only check the response from gla/mc/settings
API, do you think it'd be a good idea to mock /gla/mc/settings/sync
API so it wouldn't respond the error?
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.
At first, I didn't mock the response because I believed there wasn't much to test. But now I realize we can actually verify the message in the snackbar. See here: 5a9c0e2
Thanks @ianlin for your suggestions! I addressed all of them.
Since yesterday I have been working with this tweak:
It looks like it's solving the problem. Once I confirm this, I'll implement the tweak. |
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.
Thanks for the extra changes! I've tested again and it worked perfectly, LGTM.
Changes proposed in this Pull Request:
Closes part of #2070
This PR aims to create the base for testing the dashboard and editing the free listings. To access the dashboard page, merchants must log in with their Google account, merchant centre, and so on; otherwise, they'll be redirected to the Getting Started page. Since the redirection occurs on the server and can't be easily mocked through requests, so I opted to simulate the onboarded state by changing the values returned from the database. This was addressed by introducing a filter, as seen in this commit: 68d76b3. This enables us to attach an action that emulates the onboarding state. Initially, I attempted to store options in the database similarly to how it's done for the conversion id:
google-listings-and-ads/tests/e2e/bin/test-data.php
Lines 19 to 36 in 551b385
However, this approach would cause issues, as it would lead to all tests being in the onboarded state, preventing us from testing scenarios like the getting started page.
This PR covers the testing of the following aspects:
Screenshots:
Detailed test instructions:
npm run test:e2e ./tests/e2e/specs/dashboard/edit-free-listings.test.js
ornpm run test:e2e
to run all tests.Additional details:
While working on this, I experienced the problem described here: #2043 (review). Specifically, the test-data plugin failed to load correctly, leading to 404 errors in certain tests or preventing the successful simulation of the onboarded state:
As a temporary solution, I had to stop the containers and restart them. Additionally, on occasions, I had to manually activate the plugin by visiting http://localhost:8889/wp-admin/plugins.php?plugin_status=all. We will need to look deeper into this possible issue.
While there are numerous other scenarios that could be tested, the primary objective of this PR is to create the base for the tests for the dashboard page.
Changelog entry