From 68d76b3a8b41f08e9f5c396143893b098419bc73 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:02:58 +0200 Subject: [PATCH 01/24] Add filter to override DB options --- src/Options/Options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Options/Options.php b/src/Options/Options.php index 2164e9c7ab..b51b7fe28e 100644 --- a/src/Options/Options.php +++ b/src/Options/Options.php @@ -41,7 +41,7 @@ public function get( string $name, $default = null ) { if ( ! array_key_exists( $name, $this->options ) ) { $value = get_option( $this->prefix_name( $name ), $default ); - $this->options[ $name ] = $this->maybe_cast_value( $name, $value ); + $this->options[ $name ] = apply_filters("woocommerce_gla_options_get_{$name}", $this->maybe_cast_value( $name, $value )) ; } return $this->raw_value( $this->options[ $name ] ); From edbd0cdd9b1c6e744531661dc11f7b2e27ee6aab Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:03:33 +0200 Subject: [PATCH 02/24] Add action to simulate GLA onboarded --- tests/e2e/bin/test-data.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/e2e/bin/test-data.php b/tests/e2e/bin/test-data.php index 02fc9edaad..9a1865e62b 100644 --- a/tests/e2e/bin/test-data.php +++ b/tests/e2e/bin/test-data.php @@ -25,16 +25,33 @@ function register_routes() { 'methods' => 'POST', 'callback' => __NAMESPACE__ . '\set_conversion_id', 'permission_callback' => __NAMESPACE__ . '\permissions', - ], + ], [ 'methods' => 'DELETE', 'callback' => __NAMESPACE__ . '\clear_conversion_id', 'permission_callback' => __NAMESPACE__ . '\permissions', ], - ], + ], ); } +add_action( 'plugins_loaded', function () { + + if(isset($_GET['gla-e2e-onboarded'])){ + add_filter("woocommerce_gla_options_get_".OptionsInterface::REDIRECT_TO_ONBOARDING, function ($value){ + return 'no'; + }); + + add_filter("woocommerce_gla_options_get_".OptionsInterface::MC_SETUP_COMPLETED_AT, function ($value){ + return 1693215209; + }); + + add_filter("woocommerce_gla_options_get_".OptionsInterface::GOOGLE_CONNECTED, function ($value){ + return true; + }); + } +} ); + /** * Set the Ads Conversion Action to test values. */ @@ -56,12 +73,13 @@ function set_conversion_id() { function clear_conversion_id() { /** @var OptionsInterface $options */ $options = woogle_get_container()->get( OptionsInterface::class ); - $options->delete( OptionsInterface::ADS_CONVERSION_ACTION ); + $options->delete( OptionsInterface::ADS_CONVERSION_ACTION ); } /** * Check permissions for API requests. */ function permissions() { + return true; return current_user_can( 'manage_woocommerce' ); } From 251de35b29b4478f0b5a05afb15312ee10e3025a Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:04:46 +0200 Subject: [PATCH 03/24] Add Mock Requests Utility class --- tests/e2e/utils/mock-requests.js | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/e2e/utils/mock-requests.js diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js new file mode 100644 index 0000000000..19c48b8be8 --- /dev/null +++ b/tests/e2e/utils/mock-requests.js @@ -0,0 +1,80 @@ +/** + * Mock Requests + * + * This class is used to mock requests to the server. + */ +export default class MockRequests { + /** + * @param {import('@playwright/test').Page} page + */ + constructor( page ) { + this.page = page; + } + + /** + * Fulfill a request with a payload. + * @param {RegExp|String} url The url to fulfill. + * @param {Object} payload The payload to send. + * @returns {Promise} + */ + async fulfillRequest( url, payload ) { + await this.page.route( url, ( route ) => + route.fulfill( { + content: 'application/json', + headers: { 'Access-Control-Allow-Origin': '*' }, + body: JSON.stringify( payload ), + } ) + ); + } + + /** + * Fulfill the MC Report Program request. + * @param {Object} payload + * @returns {Promise} + */ + async fulfillMCReportProgram( payload ) { + await this.fulfillRequest( + /\/wc\/gla\/mc\/reports\/programs\b/, + payload + ); + } + + /** + * Fulfill the Target Audience request. + * @param {Object} payload + * @returns {Promise} + */ + async fulfillTargetAudience( payload ) { + await this.fulfillRequest( + /\/wc\/gla\/mc\/target_audience\b/, + payload + ); + } + + /** + * Fulfill the JetPack Connection request. + * @param {Object} payload + * @returns {Promise} + */ + async fulfillJetPackConnection( payload ) { + await this.fulfillRequest( /\/wc\/gla\/jetpack\/connected\b/, payload ); + } + + /** + * Fulfill the Google Connection request. + * @param {Object} payload + * @returns {Promise} + */ + async fulfillGoogleConnection( payload ) { + await this.fulfillRequest( /\/wc\/gla\/google\/connected\b/, payload ); + } + + /** + * Fulfill the Ads Connection request. + * @param {Object} payload + * @returns {Promise} + */ + async fulfillAdsConnection( payload ) { + await this.fulfillRequest( /\/wc\/gla\/ads\/connection\b/, payload ); + } +} From acd00aada7744afa602ea4e8fbc9b5e8442c0541 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:05:17 +0200 Subject: [PATCH 04/24] Create Dashboard Page --- tests/e2e/utils/pages/dashboard.js | 131 +++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 tests/e2e/utils/pages/dashboard.js diff --git a/tests/e2e/utils/pages/dashboard.js b/tests/e2e/utils/pages/dashboard.js new file mode 100644 index 0000000000..4be12e5911 --- /dev/null +++ b/tests/e2e/utils/pages/dashboard.js @@ -0,0 +1,131 @@ +import MockRequests from '../mock-requests'; + +/** + * Dashboard page object class. + */ +export default class DashboardPage extends MockRequests { + /** + * @param {import('@playwright/test').Page} page + */ + constructor( page ) { + super( page ); + this.page = page; + this.freeListingRow = this.page.locator( + '.gla-all-programs-table-card table tr:nth-child(2)' + ); + this.editFreeListingButton = this.freeListingRow.getByRole( 'button', { + name: 'Edit', + } ); + } + + /** + * Close the current page. + */ + async closePage() { + await this.page.close(); + } + + /** + * Mock all requests related to external accounts such as Merchant Center, Google, etc. + */ + async mockRequests() { + // Mock Reports Programs + this.fulfillMCReportProgram( { + free_listings: null, + products: null, + intervals: null, + totals: { + clicks: 0, + impressions: 0, + }, + next_page: null, + } ); + + this.fulfillTargetAudience( { + location: 'selected', + countries: [ 'US' ], + locale: 'en_US', + language: 'English', + } ); + + this.fulfillJetPackConnection( { + active: 'yes', + owner: 'yes', + displayName: 'John', + email: 'john@email.com', + } ); + + this.fulfillGoogleConnection( { + active: 'yes', + email: 'john@email.com', + scope: [], + } ); + + this.fulfillAdsConnection( { + id: 0, + currency: null, + symbol: '$', + status: 'disconnected', + } ); + } + + /** + * Mock the onboarded state. Otherwise it will be redirected to the onboarding page. + */ + async onboarded() { + this.page.route( /\/admin.php\b/, ( route ) => { + const url = `${ route.request().url() }&gla-e2e-onboarded=true`; + route.continue( { url } ); + } ); + } + + /** + * Go to the dashboard page. + */ + async goto() { + await this.page.goto( + '/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard', + { waitUntil: 'domcontentloaded' } + ); + } + + /** + * Click the edit free listings button. + */ + async clickEditFreeListings() { + await this.editFreeListingButton.click(); + } + + /** + * Get the continue to edit button from the modal. + * + * @returns {Promise} + */ + async getContinueToEditButton() { + return this.page.getByRole( 'button', { + name: 'Continue to edit', + exact: true, + } ); + } + + /** + * Get the don't edit button from the modal. + * + * @returns {Promise} + */ + async getDontEditButton() { + return this.page.getByRole( 'button', { + name: "Don't edit", + exact: true, + } ); + } + + /** + * Click the continue to edit button from the modal. + * @returns {Promise} + */ + async clickContinueToEditButton() { + const continueToEditButton = await this.getContinueToEditButton(); + await continueToEditButton.click(); + } +} From 280b8f8e47cfad83c4edb455b134ef2b2d2fbc54 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:05:57 +0200 Subject: [PATCH 05/24] Add edit free-listings page --- tests/e2e/utils/pages/edit-free-listings.js | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/e2e/utils/pages/edit-free-listings.js diff --git a/tests/e2e/utils/pages/edit-free-listings.js b/tests/e2e/utils/pages/edit-free-listings.js new file mode 100644 index 0000000000..0d516378b3 --- /dev/null +++ b/tests/e2e/utils/pages/edit-free-listings.js @@ -0,0 +1,90 @@ +export default class EditFreeListingsPage { + /** + * @param {import('@playwright/test').Page} page + */ + constructor( page ) { + this.page = page; + } + + /** + * Get Save Changes button. * + * @returns {Promise} + */ + async getSaveChangesButton() { + return this.page.getByRole( 'button', { + name: 'Save changes', + exact: true, + } ); + } + + /** + * Click the Save Changes button. + * @returns {Promise} + */ + async clickSaveChanges() { + const saveChangesButton = await this.getSaveChangesButton(); + saveChangesButton.click(); + } + + /** + * Check the recommended shipping settings. + * @returns {Promise} + */ + async checkRecommendShippingSettings() { + return this.page + .locator( + 'text=Recommended: Automatically sync my store’s shipping settings to Google.' + ) + .check(); + } + /** + * Fill the countries shipping time input. + * @param {String} input The shipping time + * @returns {Promise} + */ + async fillCountriesShippingTimeInput( input ) { + await this.page.locator( '.countries-time input' ).fill( input ); + } + + /** + * Check the destination based tax rates. + * @returns {Promise} + */ + async checkDestinationBasedTaxRates() { + await this.page + .locator( 'text=My store uses destination-based tax rates.' ) + .check(); + } + + /** + * Register the requests when the save button is clicked. + * @returns {Promise} + */ + registerSavingRequests() { + const targetAudienteRequest = this.page.waitForRequest( + ( request ) => + request.url().includes( '/gla/mc/target_audience' ) && + request.method() === 'POST' && + request.postDataJSON().countries[ 0 ] === 'US' + ); + const settingsRequest = this.page.waitForRequest( + ( request ) => + request.url().includes( '/gla/mc/settings' ) && + request.method() === 'POST' && + request.postDataJSON().shipping_rate === 'automatic' && + request.postDataJSON().shipping_time === 'flat' + ); + + const syncRequest = this.page.waitForRequest( + ( request ) => + request.url().includes( '/gla/mc/settings/sync' ) && + request.method() === 'POST' + ); + + return Promise.all( [ + settingsRequest, + targetAudienteRequest, + syncRequest, + ] ); + } +} From f76fb1db3a6ab7c2efa3e8ff3f7696f43acc3426 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:06:19 +0200 Subject: [PATCH 06/24] Add edit free listings test --- .../dashboard/edit-free-listings.test.js | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/e2e/specs/dashboard/edit-free-listings.test.js diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js new file mode 100644 index 0000000000..7025d053bf --- /dev/null +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -0,0 +1,85 @@ +import { test, expect } from '@playwright/test'; +import DashboardPage from '../../utils/pages/dashboard.js'; +import EditFreeListingsPage from '../../utils/pages/edit-free-listings.js'; + +test.use( { storageState: process.env.ADMINSTATE } ); + +test.describe.configure( { mode: 'serial' } ); + +/** + * @type {import('../../utils/pages/dashboard.js').default} dashboardPage + */ +let dashboardPage = null; + +/** + * @type {import('../../utils/pages/edit-free-listings.js').default} editFreeListingsPage + */ +let editFreeListingsPage = null; + +/** + * @type {import('@playwright/test').Page} page + */ +let page = null; + +test.describe( 'Edit Free Listings', () => { + test.beforeAll( async ( { browser } ) => { + page = await browser.newPage(); + dashboardPage = new DashboardPage( page ); + await dashboardPage.onboarded(); + await dashboardPage.mockRequests(); + await dashboardPage.goto(); + } ); + + test.afterAll( async () => { + await page.close(); + } ); + + test( 'Dashboard page contains Free Listings', async () => { + await expect( dashboardPage.freeListingRow ).toContainText( + 'Free listings' + ); + + await expect( dashboardPage.editFreeListingButton ).toBeEnabled(); + } ); + + test( 'Edit Free Listings should show modal', async () => { + await dashboardPage.clickEditFreeListings(); + + await page.waitForLoadState( 'domcontentloaded' ); + + const continueToEditButton = await dashboardPage.getContinueToEditButton(); + const dontEditButton = await dashboardPage.getDontEditButton(); + await expect( continueToEditButton ).toBeEnabled(); + await expect( dontEditButton ).toBeEnabled(); + } ); + + test( 'Continue to edit Free listings', async () => { + await dashboardPage.clickContinueToEditButton(); + await page.waitForLoadState( 'domcontentloaded' ); + } ); + + test( 'Check recommended shipping settings', async () => { + editFreeListingsPage = new EditFreeListingsPage( page ); + await editFreeListingsPage.checkRecommendShippingSettings(); + await editFreeListingsPage.fillCountriesShippingTimeInput( '5' ); + await editFreeListingsPage.checkDestinationBasedTaxRates(); + const saveChangesButton = await editFreeListingsPage.getSaveChangesButton(); + await expect( saveChangesButton ).toBeEnabled(); + } ); + + test( 'Save changes', async () => { + const awaitForRequests = editFreeListingsPage.registerSavingRequests(); + await editFreeListingsPage.clickSaveChanges(); + const requests = await awaitForRequests; + const settingsResponse = await ( + await requests[ 0 ].response() + ).json(); + + expect( settingsResponse.status ).toBe( 'success' ); + expect( settingsResponse.message ).toBe( + 'Merchant Center Settings successfully updated.' + ); + expect( settingsResponse.data.shipping_time ).toBe( 'flat' ); + expect( settingsResponse.data.tax_rate ).toBe( 'destination' ); + } ); +} ); From 551b3851a7426922173b36c0da1e63e19706619b Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:13:46 +0200 Subject: [PATCH 07/24] Rename onboarded function and move the method to mock requests class --- tests/e2e/specs/dashboard/edit-free-listings.test.js | 2 +- tests/e2e/utils/mock-requests.js | 11 +++++++++++ tests/e2e/utils/pages/dashboard.js | 10 ---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index 7025d053bf..a6a02d369b 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -25,7 +25,7 @@ test.describe( 'Edit Free Listings', () => { test.beforeAll( async ( { browser } ) => { page = await browser.newPage(); dashboardPage = new DashboardPage( page ); - await dashboardPage.onboarded(); + await dashboardPage.mockOnboarded(); await dashboardPage.mockRequests(); await dashboardPage.goto(); } ); diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js index 19c48b8be8..2f7aebdbd1 100644 --- a/tests/e2e/utils/mock-requests.js +++ b/tests/e2e/utils/mock-requests.js @@ -11,6 +11,17 @@ export default class MockRequests { this.page = page; } + /** + * Add the parameter gla-e2e-onboarded to the request to simulate the onboarded state; otherwise, it will redirect to the onboarding page. + * @returns {Promise} + */ + async mockOnboarded() { + await this.page.route( /\/admin.php\b/, ( route ) => { + const url = `${ route.request().url() }&gla-e2e-onboarded=true`; + route.continue( { url } ); + } ); + } + /** * Fulfill a request with a payload. * @param {RegExp|String} url The url to fulfill. diff --git a/tests/e2e/utils/pages/dashboard.js b/tests/e2e/utils/pages/dashboard.js index 4be12e5911..0cb5e2ef8f 100644 --- a/tests/e2e/utils/pages/dashboard.js +++ b/tests/e2e/utils/pages/dashboard.js @@ -69,16 +69,6 @@ export default class DashboardPage extends MockRequests { } ); } - /** - * Mock the onboarded state. Otherwise it will be redirected to the onboarding page. - */ - async onboarded() { - this.page.route( /\/admin.php\b/, ( route ) => { - const url = `${ route.request().url() }&gla-e2e-onboarded=true`; - route.continue( { url } ); - } ); - } - /** * Go to the dashboard page. */ From d722ba48999c6656b24743367fca98027fe24c94 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:27:38 +0200 Subject: [PATCH 08/24] Remove unnecessary spaces --- tests/e2e/bin/test-data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/bin/test-data.php b/tests/e2e/bin/test-data.php index 9a1865e62b..c19b3f9f92 100644 --- a/tests/e2e/bin/test-data.php +++ b/tests/e2e/bin/test-data.php @@ -25,13 +25,13 @@ function register_routes() { 'methods' => 'POST', 'callback' => __NAMESPACE__ . '\set_conversion_id', 'permission_callback' => __NAMESPACE__ . '\permissions', - ], + ], [ 'methods' => 'DELETE', 'callback' => __NAMESPACE__ . '\clear_conversion_id', 'permission_callback' => __NAMESPACE__ . '\permissions', ], - ], + ], ); } From 0a84f51af9075d1952d9ec31680e472865aebd3e Mon Sep 17 00:00:00 2001 From: Jorge M Date: Tue, 29 Aug 2023 23:55:02 +0200 Subject: [PATCH 09/24] Fix phpcs --- src/Options/Options.php | 2 +- tests/e2e/bin/test-data.php | 43 +++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Options/Options.php b/src/Options/Options.php index b51b7fe28e..8b02575ee9 100644 --- a/src/Options/Options.php +++ b/src/Options/Options.php @@ -41,7 +41,7 @@ public function get( string $name, $default = null ) { if ( ! array_key_exists( $name, $this->options ) ) { $value = get_option( $this->prefix_name( $name ), $default ); - $this->options[ $name ] = apply_filters("woocommerce_gla_options_get_{$name}", $this->maybe_cast_value( $name, $value )) ; + $this->options[ $name ] = apply_filters( "woocommerce_gla_options_get_{$name}", $this->maybe_cast_value( $name, $value ) ); } return $this->raw_value( $this->options[ $name ] ); diff --git a/tests/e2e/bin/test-data.php b/tests/e2e/bin/test-data.php index c19b3f9f92..cc3132a8fd 100644 --- a/tests/e2e/bin/test-data.php +++ b/tests/e2e/bin/test-data.php @@ -35,22 +35,34 @@ function register_routes() { ); } -add_action( 'plugins_loaded', function () { +add_action( + 'plugins_loaded', + function () { + if ( isset( $_GET['gla-e2e-onboarded'] ) ) { + add_filter( + 'woocommerce_gla_options_get_' . OptionsInterface::REDIRECT_TO_ONBOARDING, + function ( $value ) { + return 'no'; + } + ); - if(isset($_GET['gla-e2e-onboarded'])){ - add_filter("woocommerce_gla_options_get_".OptionsInterface::REDIRECT_TO_ONBOARDING, function ($value){ - return 'no'; - }); - - add_filter("woocommerce_gla_options_get_".OptionsInterface::MC_SETUP_COMPLETED_AT, function ($value){ - return 1693215209; - }); - - add_filter("woocommerce_gla_options_get_".OptionsInterface::GOOGLE_CONNECTED, function ($value){ - return true; - }); + add_filter( + 'woocommerce_gla_options_get_' . OptionsInterface::MC_SETUP_COMPLETED_AT, + function ( $value ) { + return 1693215209; + } + ); + + add_filter( + 'woocommerce_gla_options_get_' . OptionsInterface::GOOGLE_CONNECTED, + function ( $value ) { + return true; + } + ); + } } -} ); +); + /** * Set the Ads Conversion Action to test values. @@ -73,13 +85,12 @@ function set_conversion_id() { function clear_conversion_id() { /** @var OptionsInterface $options */ $options = woogle_get_container()->get( OptionsInterface::class ); - $options->delete( OptionsInterface::ADS_CONVERSION_ACTION ); + $options->delete( OptionsInterface::ADS_CONVERSION_ACTION ); } /** * Check permissions for API requests. */ function permissions() { - return true; return current_user_can( 'manage_woocommerce' ); } From 9c5010d8f931eb61ef78209f7b7686e6335620fd Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 00:06:03 +0200 Subject: [PATCH 10/24] Fix js linting --- .../dashboard/edit-free-listings.test.js | 6 +++++ tests/e2e/utils/mock-requests.js | 23 ++++++++++++------- tests/e2e/utils/pages/dashboard.js | 16 ++++++++++--- tests/e2e/utils/pages/edit-free-listings.js | 22 +++++++++++------- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index a6a02d369b..554c69d334 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -1,4 +1,10 @@ +/** + * External dependencies + */ import { test, expect } from '@playwright/test'; +/** + * Internal dependencies + */ import DashboardPage from '../../utils/pages/dashboard.js'; import EditFreeListingsPage from '../../utils/pages/edit-free-listings.js'; diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js index 2f7aebdbd1..2950ea4871 100644 --- a/tests/e2e/utils/mock-requests.js +++ b/tests/e2e/utils/mock-requests.js @@ -13,7 +13,8 @@ export default class MockRequests { /** * Add the parameter gla-e2e-onboarded to the request to simulate the onboarded state; otherwise, it will redirect to the onboarding page. - * @returns {Promise} + * + * @return {Promise} */ async mockOnboarded() { await this.page.route( /\/admin.php\b/, ( route ) => { @@ -24,9 +25,10 @@ export default class MockRequests { /** * Fulfill a request with a payload. - * @param {RegExp|String} url The url to fulfill. + * + * @param {RegExp|string} url The url to fulfill. * @param {Object} payload The payload to send. - * @returns {Promise} + * @return {Promise} */ async fulfillRequest( url, payload ) { await this.page.route( url, ( route ) => @@ -40,8 +42,9 @@ export default class MockRequests { /** * Fulfill the MC Report Program request. + * * @param {Object} payload - * @returns {Promise} + * @return {Promise} */ async fulfillMCReportProgram( payload ) { await this.fulfillRequest( @@ -52,8 +55,9 @@ export default class MockRequests { /** * Fulfill the Target Audience request. + * * @param {Object} payload - * @returns {Promise} + * @return {Promise} */ async fulfillTargetAudience( payload ) { await this.fulfillRequest( @@ -64,8 +68,9 @@ export default class MockRequests { /** * Fulfill the JetPack Connection request. + * * @param {Object} payload - * @returns {Promise} + * @return {Promise} */ async fulfillJetPackConnection( payload ) { await this.fulfillRequest( /\/wc\/gla\/jetpack\/connected\b/, payload ); @@ -73,8 +78,9 @@ export default class MockRequests { /** * Fulfill the Google Connection request. + * * @param {Object} payload - * @returns {Promise} + * @return {Promise} */ async fulfillGoogleConnection( payload ) { await this.fulfillRequest( /\/wc\/gla\/google\/connected\b/, payload ); @@ -82,8 +88,9 @@ export default class MockRequests { /** * Fulfill the Ads Connection request. + * * @param {Object} payload - * @returns {Promise} + * @return {Promise} */ async fulfillAdsConnection( payload ) { await this.fulfillRequest( /\/wc\/gla\/ads\/connection\b/, payload ); diff --git a/tests/e2e/utils/pages/dashboard.js b/tests/e2e/utils/pages/dashboard.js index 0cb5e2ef8f..7949134682 100644 --- a/tests/e2e/utils/pages/dashboard.js +++ b/tests/e2e/utils/pages/dashboard.js @@ -1,3 +1,6 @@ +/** + * Internal dependencies + */ import MockRequests from '../mock-requests'; /** @@ -20,6 +23,8 @@ export default class DashboardPage extends MockRequests { /** * Close the current page. + * + * @return {Promise} */ async closePage() { await this.page.close(); @@ -71,6 +76,8 @@ export default class DashboardPage extends MockRequests { /** * Go to the dashboard page. + * + * @return {Promise} */ async goto() { await this.page.goto( @@ -81,6 +88,8 @@ export default class DashboardPage extends MockRequests { /** * Click the edit free listings button. + * + * @return {Promise} */ async clickEditFreeListings() { await this.editFreeListingButton.click(); @@ -89,7 +98,7 @@ export default class DashboardPage extends MockRequests { /** * Get the continue to edit button from the modal. * - * @returns {Promise} + * @return {Promise} Get the continue to edit button from the modal. */ async getContinueToEditButton() { return this.page.getByRole( 'button', { @@ -101,7 +110,7 @@ export default class DashboardPage extends MockRequests { /** * Get the don't edit button from the modal. * - * @returns {Promise} + * @return {Promise} Get the don't edit button from the modal. */ async getDontEditButton() { return this.page.getByRole( 'button', { @@ -112,7 +121,8 @@ export default class DashboardPage extends MockRequests { /** * Click the continue to edit button from the modal. - * @returns {Promise} + * + * @return {Promise} */ async clickContinueToEditButton() { const continueToEditButton = await this.getContinueToEditButton(); diff --git a/tests/e2e/utils/pages/edit-free-listings.js b/tests/e2e/utils/pages/edit-free-listings.js index 0d516378b3..5f7e4c63a4 100644 --- a/tests/e2e/utils/pages/edit-free-listings.js +++ b/tests/e2e/utils/pages/edit-free-listings.js @@ -7,8 +7,9 @@ export default class EditFreeListingsPage { } /** - * Get Save Changes button. * - * @returns {Promise} + * Get Save Changes button. + * + * @return {Promise} Get Save Changes button. */ async getSaveChangesButton() { return this.page.getByRole( 'button', { @@ -19,7 +20,8 @@ export default class EditFreeListingsPage { /** * Click the Save Changes button. - * @returns {Promise} + * + * @return {Promise} */ async clickSaveChanges() { const saveChangesButton = await this.getSaveChangesButton(); @@ -28,7 +30,8 @@ export default class EditFreeListingsPage { /** * Check the recommended shipping settings. - * @returns {Promise} + * + * @return {Promise} */ async checkRecommendShippingSettings() { return this.page @@ -39,8 +42,9 @@ export default class EditFreeListingsPage { } /** * Fill the countries shipping time input. - * @param {String} input The shipping time - * @returns {Promise} + * + * @param {string} input The shipping time + * @return {Promise} */ async fillCountriesShippingTimeInput( input ) { await this.page.locator( '.countries-time input' ).fill( input ); @@ -48,7 +52,8 @@ export default class EditFreeListingsPage { /** * Check the destination based tax rates. - * @returns {Promise} + * + * @return {Promise} */ async checkDestinationBasedTaxRates() { await this.page @@ -58,7 +63,8 @@ export default class EditFreeListingsPage { /** * Register the requests when the save button is clicked. - * @returns {Promise} + * + * @return {Promise} The requests. */ registerSavingRequests() { const targetAudienteRequest = this.page.waitForRequest( From d3b3448f9b05ee3777cec7bde29d8353b2966402 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:47:25 +0200 Subject: [PATCH 11/24] Add endpoints to simulate onboarded merchant --- tests/e2e/bin/test-data.php | 71 +++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/tests/e2e/bin/test-data.php b/tests/e2e/bin/test-data.php index cc3132a8fd..55de84dcaa 100644 --- a/tests/e2e/bin/test-data.php +++ b/tests/e2e/bin/test-data.php @@ -33,35 +33,54 @@ function register_routes() { ], ], ); + register_rest_route( + 'wc/v3', + 'gla-test/onboarded-merchant', + [ + [ + 'methods' => 'POST', + 'callback' => __NAMESPACE__ . '\set_onboarded_merchant', + 'permission_callback' => __NAMESPACE__ . '\permissions', + ], + [ + 'methods' => 'DELETE', + 'callback' => __NAMESPACE__ . '\clear_onboarded_merchant', + 'permission_callback' => __NAMESPACE__ . '\permissions', + ], + ], + ); } -add_action( - 'plugins_loaded', - function () { - if ( isset( $_GET['gla-e2e-onboarded'] ) ) { - add_filter( - 'woocommerce_gla_options_get_' . OptionsInterface::REDIRECT_TO_ONBOARDING, - function ( $value ) { - return 'no'; - } - ); - - add_filter( - 'woocommerce_gla_options_get_' . OptionsInterface::MC_SETUP_COMPLETED_AT, - function ( $value ) { - return 1693215209; - } - ); +/** + * Set the onboarded merchant options. + */ +function set_onboarded_merchant() { + /** @var OptionsInterface $options */ + $options = woogle_get_container()->get( OptionsInterface::class ); + $options->update( + OptionsInterface::REDIRECT_TO_ONBOARDING, + 'no' + ); + $options->update( + OptionsInterface::MC_SETUP_COMPLETED_AT, + 1693215209 + ); + $options->update( + OptionsInterface::GOOGLE_CONNECTED, + true + ); +} - add_filter( - 'woocommerce_gla_options_get_' . OptionsInterface::GOOGLE_CONNECTED, - function ( $value ) { - return true; - } - ); - } - } -); +/** + * Clear a previously set onboarded merchant. + */ +function clear_onboarded_merchant() { + /** @var OptionsInterface $options */ + $options = woogle_get_container()->get( OptionsInterface::class ); + $options->delete( OptionsInterface::REDIRECT_TO_ONBOARDING ); + $options->delete( OptionsInterface::MC_SETUP_COMPLETED_AT ); + $options->delete( OptionsInterface::GOOGLE_CONNECTED ); +} /** From 0664818c35c60bd2de6f3f0e36fddb11abf0ff36 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:49:05 +0200 Subject: [PATCH 12/24] Remove filter to simulate options values --- src/Options/Options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Options/Options.php b/src/Options/Options.php index 8b02575ee9..2164e9c7ab 100644 --- a/src/Options/Options.php +++ b/src/Options/Options.php @@ -41,7 +41,7 @@ public function get( string $name, $default = null ) { if ( ! array_key_exists( $name, $this->options ) ) { $value = get_option( $this->prefix_name( $name ), $default ); - $this->options[ $name ] = apply_filters( "woocommerce_gla_options_get_{$name}", $this->maybe_cast_value( $name, $value ) ); + $this->options[ $name ] = $this->maybe_cast_value( $name, $value ); } return $this->raw_value( $this->options[ $name ] ); From d520d8bafd1af0bea0274f9c07f3917ea12eb2fd Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:49:51 +0200 Subject: [PATCH 13/24] Use the test API to simulate onboarded merchant --- tests/e2e/specs/dashboard/edit-free-listings.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index 554c69d334..eb11f504a4 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -7,6 +7,7 @@ import { test, expect } from '@playwright/test'; */ import DashboardPage from '../../utils/pages/dashboard.js'; import EditFreeListingsPage from '../../utils/pages/edit-free-listings.js'; +import { setOnboardedMerchant, clearOnboardedMerchant } from '../../utils/api'; test.use( { storageState: process.env.ADMINSTATE } ); @@ -31,12 +32,13 @@ test.describe( 'Edit Free Listings', () => { test.beforeAll( async ( { browser } ) => { page = await browser.newPage(); dashboardPage = new DashboardPage( page ); - await dashboardPage.mockOnboarded(); + await setOnboardedMerchant(); await dashboardPage.mockRequests(); await dashboardPage.goto(); } ); test.afterAll( async () => { + await clearOnboardedMerchant(); await page.close(); } ); From c5942d632e6bc42cbe768d95b59364290a390ed2 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:50:31 +0200 Subject: [PATCH 14/24] Add onBoarded functions --- tests/e2e/utils/api.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/e2e/utils/api.js b/tests/e2e/utils/api.js index f009e491cb..4c1c2bca7c 100644 --- a/tests/e2e/utils/api.js +++ b/tests/e2e/utils/api.js @@ -61,3 +61,17 @@ export async function setConversionID() { export async function clearConversionID() { await api().delete( 'gla-test/conversion-id' ); } + +/** + * Set Onboarded Merchant. + */ +export async function setOnboardedMerchant() { + await api().post( 'gla-test/onboarded-merchant' ); +} + +/** + * Clear Onboarded Merchant. + */ +export async function clearOnboardedMerchant() { + await api().delete( 'gla-test/onboarded-merchant' ); +} From a19a8a8718bd05d100be553871414aac23ae225d Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:51:24 +0200 Subject: [PATCH 15/24] Remove old mockOnboarded method as we will use the test API to simulate the onboarding status --- tests/e2e/utils/mock-requests.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js index 2950ea4871..06f67c3bbf 100644 --- a/tests/e2e/utils/mock-requests.js +++ b/tests/e2e/utils/mock-requests.js @@ -11,18 +11,6 @@ export default class MockRequests { this.page = page; } - /** - * Add the parameter gla-e2e-onboarded to the request to simulate the onboarded state; otherwise, it will redirect to the onboarding page. - * - * @return {Promise} - */ - async mockOnboarded() { - await this.page.route( /\/admin.php\b/, ( route ) => { - const url = `${ route.request().url() }&gla-e2e-onboarded=true`; - route.continue( { url } ); - } ); - } - /** * Fulfill a request with a payload. * From d68f4d7a8e0f33cac9ac1f58e9fd98b1d624a42c Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:51:52 +0200 Subject: [PATCH 16/24] Set the number of workers to 1 --- tests/e2e/config/playwright.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/config/playwright.config.js b/tests/e2e/config/playwright.config.js index ae3720a15d..b3d99e4407 100644 --- a/tests/e2e/config/playwright.config.js +++ b/tests/e2e/config/playwright.config.js @@ -15,6 +15,9 @@ module.exports = defineConfig( { timeout: 20 * 1000, }, + /* Number of workers, See discusion: https://github.com/woocommerce/google-listings-and-ads/pull/2080#issuecomment-1698810270 */ + workers: 1, + /* Retry on CI only */ retries: process.env.CI ? 2 : 0, From 4b4f063f282e941e25e1158d53c3d3f652e5923d Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 12:58:26 +0200 Subject: [PATCH 17/24] Adding missing awaits --- tests/e2e/utils/pages/dashboard.js | 10 +++++----- tests/e2e/utils/pages/edit-free-listings.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/e2e/utils/pages/dashboard.js b/tests/e2e/utils/pages/dashboard.js index 7949134682..86f788489a 100644 --- a/tests/e2e/utils/pages/dashboard.js +++ b/tests/e2e/utils/pages/dashboard.js @@ -35,7 +35,7 @@ export default class DashboardPage extends MockRequests { */ async mockRequests() { // Mock Reports Programs - this.fulfillMCReportProgram( { + await this.fulfillMCReportProgram( { free_listings: null, products: null, intervals: null, @@ -46,27 +46,27 @@ export default class DashboardPage extends MockRequests { next_page: null, } ); - this.fulfillTargetAudience( { + await this.fulfillTargetAudience( { location: 'selected', countries: [ 'US' ], locale: 'en_US', language: 'English', } ); - this.fulfillJetPackConnection( { + await this.fulfillJetPackConnection( { active: 'yes', owner: 'yes', displayName: 'John', email: 'john@email.com', } ); - this.fulfillGoogleConnection( { + await this.fulfillGoogleConnection( { active: 'yes', email: 'john@email.com', scope: [], } ); - this.fulfillAdsConnection( { + await this.fulfillAdsConnection( { id: 0, currency: null, symbol: '$', diff --git a/tests/e2e/utils/pages/edit-free-listings.js b/tests/e2e/utils/pages/edit-free-listings.js index 5f7e4c63a4..b561ad92dd 100644 --- a/tests/e2e/utils/pages/edit-free-listings.js +++ b/tests/e2e/utils/pages/edit-free-listings.js @@ -25,7 +25,7 @@ export default class EditFreeListingsPage { */ async clickSaveChanges() { const saveChangesButton = await this.getSaveChangesButton(); - saveChangesButton.click(); + await saveChangesButton.click(); } /** From 62f62705d8805e9eff5b7df22271f583a3308485 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Wed, 30 Aug 2023 13:30:58 +0200 Subject: [PATCH 18/24] Fix js lint --- tests/e2e/specs/dashboard/edit-free-listings.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index eb11f504a4..02d754bfd5 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -55,7 +55,8 @@ test.describe( 'Edit Free Listings', () => { await page.waitForLoadState( 'domcontentloaded' ); - const continueToEditButton = await dashboardPage.getContinueToEditButton(); + const continueToEditButton = + await dashboardPage.getContinueToEditButton(); const dontEditButton = await dashboardPage.getDontEditButton(); await expect( continueToEditButton ).toBeEnabled(); await expect( dontEditButton ).toBeEnabled(); @@ -71,7 +72,8 @@ test.describe( 'Edit Free Listings', () => { await editFreeListingsPage.checkRecommendShippingSettings(); await editFreeListingsPage.fillCountriesShippingTimeInput( '5' ); await editFreeListingsPage.checkDestinationBasedTaxRates(); - const saveChangesButton = await editFreeListingsPage.getSaveChangesButton(); + const saveChangesButton = + await editFreeListingsPage.getSaveChangesButton(); await expect( saveChangesButton ).toBeEnabled(); } ); From 097f2fb98b27e70173d74fe72ba3f7e7d372170c Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 10:52:47 +0200 Subject: [PATCH 19/24] Fix misspelling targetAudienceRequest --- tests/e2e/utils/pages/edit-free-listings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/utils/pages/edit-free-listings.js b/tests/e2e/utils/pages/edit-free-listings.js index b561ad92dd..f581875640 100644 --- a/tests/e2e/utils/pages/edit-free-listings.js +++ b/tests/e2e/utils/pages/edit-free-listings.js @@ -67,7 +67,7 @@ export default class EditFreeListingsPage { * @return {Promise} The requests. */ registerSavingRequests() { - const targetAudienteRequest = this.page.waitForRequest( + const targetAudienceRequest = this.page.waitForRequest( ( request ) => request.url().includes( '/gla/mc/target_audience' ) && request.method() === 'POST' && @@ -89,7 +89,7 @@ export default class EditFreeListingsPage { return Promise.all( [ settingsRequest, - targetAudienteRequest, + targetAudienceRequest, syncRequest, ] ); } From e68a11e5cee336f97d3df35523ec689724068c24 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 10:54:04 +0200 Subject: [PATCH 20/24] Mock saving settings sync request --- tests/e2e/utils/mock-requests.js | 10 ++++++++++ tests/e2e/utils/pages/edit-free-listings.js | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js index 06f67c3bbf..406ccf1caa 100644 --- a/tests/e2e/utils/mock-requests.js +++ b/tests/e2e/utils/mock-requests.js @@ -83,4 +83,14 @@ export default class MockRequests { async fulfillAdsConnection( payload ) { await this.fulfillRequest( /\/wc\/gla\/ads\/connection\b/, payload ); } + + /** + * Fulfill the Sync Settings Connection request. + * + * @param {Object} payload + * @return {Promise} + */ + async fulfillSettingsSync( payload ) { + await this.fulfillRequest( /\/wc\/gla\/mc\/settings\/sync\b/, payload ); + } } diff --git a/tests/e2e/utils/pages/edit-free-listings.js b/tests/e2e/utils/pages/edit-free-listings.js index f581875640..aea8797814 100644 --- a/tests/e2e/utils/pages/edit-free-listings.js +++ b/tests/e2e/utils/pages/edit-free-listings.js @@ -1,8 +1,14 @@ -export default class EditFreeListingsPage { +/** + * Internal dependencies + */ +import MockRequests from '../mock-requests'; + +export default class EditFreeListingsPage extends MockRequests { /** * @param {import('@playwright/test').Page} page */ constructor( page ) { + super( page ); this.page = page; } @@ -61,6 +67,18 @@ export default class EditFreeListingsPage { .check(); } + /** + * Mock the successful saving settings response. + * + * @return {Promise} + */ + async mockSuccessfulSavingSettingsResponse() { + await this.fulfillSettingsSync( { + status: 'success', + message: 'Successfully synchronized settings with Google.', + } ); + } + /** * Register the requests when the save button is clicked. * From 819250b94e845ce551f88237d2ddb7478b1bdc93 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 10:54:46 +0200 Subject: [PATCH 21/24] Move EditFreeListings page in beforeAll --- tests/e2e/specs/dashboard/edit-free-listings.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index 02d754bfd5..d9d8f41dc3 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -32,6 +32,7 @@ test.describe( 'Edit Free Listings', () => { test.beforeAll( async ( { browser } ) => { page = await browser.newPage(); dashboardPage = new DashboardPage( page ); + editFreeListingsPage = new EditFreeListingsPage( page ); await setOnboardedMerchant(); await dashboardPage.mockRequests(); await dashboardPage.goto(); From 5a9c0e2d1c3e4fd4a7036a79a514a5b2bed12b7d Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 10:58:36 +0200 Subject: [PATCH 22/24] Test the snackbar message after the settings have been saved --- .../specs/dashboard/edit-free-listings.test.js | 7 +++++++ tests/e2e/utils/page.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/e2e/utils/page.js diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index d9d8f41dc3..1b4dec3318 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -8,6 +8,7 @@ import { test, expect } from '@playwright/test'; import DashboardPage from '../../utils/pages/dashboard.js'; import EditFreeListingsPage from '../../utils/pages/edit-free-listings.js'; import { setOnboardedMerchant, clearOnboardedMerchant } from '../../utils/api'; +import { checkSnackBarMessage } from '../../utils/page'; test.use( { storageState: process.env.ADMINSTATE } ); @@ -80,6 +81,7 @@ test.describe( 'Edit Free Listings', () => { test( 'Save changes', async () => { const awaitForRequests = editFreeListingsPage.registerSavingRequests(); + await editFreeListingsPage.mockSuccessfulSavingSettingsResponse(); await editFreeListingsPage.clickSaveChanges(); const requests = await awaitForRequests; const settingsResponse = await ( @@ -92,5 +94,10 @@ test.describe( 'Edit Free Listings', () => { ); expect( settingsResponse.data.shipping_time ).toBe( 'flat' ); expect( settingsResponse.data.tax_rate ).toBe( 'destination' ); + + await checkSnackBarMessage( + page, + 'Your changes to your Free Listings have been saved and will be synced to your Google Merchant Center account.' + ); } ); } ); diff --git a/tests/e2e/utils/page.js b/tests/e2e/utils/page.js new file mode 100644 index 0000000000..9ae0013ad4 --- /dev/null +++ b/tests/e2e/utils/page.js @@ -0,0 +1,18 @@ +/** + * External dependencies + */ +const { expect } = require( '@playwright/test' ); + +/** + * Check the snackbar message. + * + * @param {import('@playwright/test').Page} page The current page. + * @param {string} text The text to check. + * + * @return {Promise} + */ +export async function checkSnackBarMessage( page, text ) { + const snackbarMessage = page.locator( '.components-snackbar__content' ); + await snackbarMessage.waitFor(); + expect( snackbarMessage ).toHaveText( text ); +} From 3e7fbdb4dcd2d55d9d9a288c0e9b24e62d10be05 Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 11:22:19 +0200 Subject: [PATCH 23/24] Reorder imports --- tests/e2e/specs/dashboard/edit-free-listings.test.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/e2e/specs/dashboard/edit-free-listings.test.js b/tests/e2e/specs/dashboard/edit-free-listings.test.js index 1b4dec3318..87a8e60858 100644 --- a/tests/e2e/specs/dashboard/edit-free-listings.test.js +++ b/tests/e2e/specs/dashboard/edit-free-listings.test.js @@ -1,14 +1,14 @@ /** * External dependencies */ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; /** * Internal dependencies */ +import { clearOnboardedMerchant, setOnboardedMerchant } from '../../utils/api'; +import { checkSnackBarMessage } from '../../utils/page'; import DashboardPage from '../../utils/pages/dashboard.js'; import EditFreeListingsPage from '../../utils/pages/edit-free-listings.js'; -import { setOnboardedMerchant, clearOnboardedMerchant } from '../../utils/api'; -import { checkSnackBarMessage } from '../../utils/page'; test.use( { storageState: process.env.ADMINSTATE } ); @@ -70,7 +70,6 @@ test.describe( 'Edit Free Listings', () => { } ); test( 'Check recommended shipping settings', async () => { - editFreeListingsPage = new EditFreeListingsPage( page ); await editFreeListingsPage.checkRecommendShippingSettings(); await editFreeListingsPage.fillCountriesShippingTimeInput( '5' ); await editFreeListingsPage.checkDestinationBasedTaxRates(); From d0c9172973c5247dd6cb9d27948c76e91a54c3ce Mon Sep 17 00:00:00 2001 From: Jorge M Date: Thu, 31 Aug 2023 12:08:17 +0200 Subject: [PATCH 24/24] Add missing return JSDOC --- tests/e2e/utils/pages/dashboard.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/utils/pages/dashboard.js b/tests/e2e/utils/pages/dashboard.js index 86f788489a..925426330a 100644 --- a/tests/e2e/utils/pages/dashboard.js +++ b/tests/e2e/utils/pages/dashboard.js @@ -32,6 +32,8 @@ export default class DashboardPage extends MockRequests { /** * Mock all requests related to external accounts such as Merchant Center, Google, etc. + * + * @return {Promise} */ async mockRequests() { // Mock Reports Programs