From 7ccf37f4eea163181b0d2c6883eb8668ad8a9a9e Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Mon, 19 Aug 2024 13:20:14 +0530 Subject: [PATCH 01/13] Hide Tax UI during onboarding & keep in edit campaign --- .../free-listings/setup-free-listings/form-content.js | 3 ++- js/src/components/free-listings/setup-free-listings/index.js | 3 ++- js/src/edit-free-campaign/index.js | 1 + js/src/setup-mc/setup-stepper/saved-setup-stepper.js | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/components/free-listings/setup-free-listings/form-content.js b/js/src/components/free-listings/setup-free-listings/form-content.js index dceec6c361..dcbb5616c4 100644 --- a/js/src/components/free-listings/setup-free-listings/form-content.js +++ b/js/src/components/free-listings/setup-free-listings/form-content.js @@ -25,10 +25,11 @@ import ConditionalSection from '.~/components/conditional-section'; */ const FormContent = ( { submitLabel = __( 'Complete setup', 'google-listings-and-ads' ), + hideTaxRates = false, } ) => { const { values, isValidForm, handleSubmit, adapter } = useAdaptiveFormContext(); - const shouldDisplayTaxRate = useDisplayTaxRate( adapter.audienceCountries ); + const shouldDisplayTaxRate = !hideTaxRates && useDisplayTaxRate( adapter.audienceCountries ); const shouldDisplayShippingTime = values.shipping_time === 'flat'; const handleSubmitClick = ( event ) => { diff --git a/js/src/components/free-listings/setup-free-listings/index.js b/js/src/components/free-listings/setup-free-listings/index.js index 3f26ae7b9c..eb27495fd1 100644 --- a/js/src/components/free-listings/setup-free-listings/index.js +++ b/js/src/components/free-listings/setup-free-listings/index.js @@ -91,6 +91,7 @@ const SetupFreeListings = ( { onContinue = noop, submitLabel, headerTitle, + hideTaxRates = false, } ) => { const formRef = useRef(); const { code: storeCountryCode } = useStoreCountry(); @@ -231,7 +232,7 @@ const SetupFreeListings = ( { validate={ handleValidate } onSubmit={ onContinue } > - + ); diff --git a/js/src/edit-free-campaign/index.js b/js/src/edit-free-campaign/index.js index c5f21c7811..b4b9be7f65 100644 --- a/js/src/edit-free-campaign/index.js +++ b/js/src/edit-free-campaign/index.js @@ -208,6 +208,7 @@ const EditFreeCampaign = () => { settings={ settings } onSettingsChange={ updateSettings } shippingRates={ loadedShippingRates } + hideTaxRates={false} onShippingRatesChange={ updateShippingRates } shippingTimes={ loadedShippingTimes } onShippingTimesChange={ updateShippingTimes } diff --git a/js/src/setup-mc/setup-stepper/saved-setup-stepper.js b/js/src/setup-mc/setup-stepper/saved-setup-stepper.js index 000b0a9336..eb13d3a815 100644 --- a/js/src/setup-mc/setup-stepper/saved-setup-stepper.js +++ b/js/src/setup-mc/setup-stepper/saved-setup-stepper.js @@ -170,6 +170,7 @@ const SavedSetupStepper = ( { savedStep } ) => { targetAudience={ initTargetAudience } settings={ initSettings } shippingRates={ initShippingRates } + hideTaxRates={ true } shippingTimes={ initShippingTimes } resolveFinalCountries={ getFinalCountries } onTargetAudienceChange={ handleFormChange.bind( From f3d08473fdea60ee08d2b03ef437d12282248833 Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Tue, 20 Aug 2024 10:42:13 +0530 Subject: [PATCH 02/13] Removes tax rate related e2e tests since no onboarding UI --- .../setup-mc/step-2-product-listings.test.js | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js index 25cd591a51..f6b37ec9b9 100644 --- a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js +++ b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js @@ -160,31 +160,6 @@ test.describe( 'Configure product listings', () => { await productListingsPage.checkSelectedCountriesOnlyRadioButton(); } ); - test( 'should still see "Tax rate (required for U.S. only)" even if deselect US when the default country is US', async () => { - const taxRateSection = productListingsPage.getTaxRateSection(); - await expect( taxRateSection ).toBeVisible(); - await removeCountryFromSearchBox( page, 'United States (US)' ); - await expect( taxRateSection ).toBeVisible(); - } ); - - test( 'should hide "Tax rate (required for U.S. only)" if deselect US when the default country is not US', async () => { - // Mock WC default country as TW, because Tax rate will always be shown if the default country is US. - await productListingsPage.fulfillWCDefaultCountry( { - woocommerce_default_country: 'TW', - } ); - await page.reload(); - - // Check the radio button of "Selected countries only" first in order to ensure the country search box is visible. - await productListingsPage.checkSelectedCountriesOnlyRadioButton(); - - const taxRateSection = productListingsPage.getTaxRateSection(); - await expect( taxRateSection ).toBeVisible(); - - await removeCountryFromSearchBox( page, 'United States (US)' ); - - await expect( taxRateSection ).not.toBeVisible(); - } ); - test.describe( 'Shipping rate is simple', () => { test.beforeAll( async () => { await page.reload(); @@ -358,11 +333,6 @@ test.describe( 'Configure product listings', () => { ); } ); - test( 'should show error message if clicking "Continue" button when tax rate is not chosen', async () => { - await productListingsPage.clickContinueButton(); - const taxRateError = productListingsPage.getTaxRateError(); - await expect( taxRateError ).toBeVisible(); - } ); } ); test.describe( 'Links', () => { From 87d46c23b4ae148fe55c8949931a0001d8b4b28c Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Tue, 20 Aug 2024 10:44:15 +0530 Subject: [PATCH 03/13] Fixes linter warnings --- .../free-listings/setup-free-listings/form-content.js | 3 ++- tests/e2e/specs/setup-mc/step-2-product-listings.test.js | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/components/free-listings/setup-free-listings/form-content.js b/js/src/components/free-listings/setup-free-listings/form-content.js index dcbb5616c4..b8123c58eb 100644 --- a/js/src/components/free-listings/setup-free-listings/form-content.js +++ b/js/src/components/free-listings/setup-free-listings/form-content.js @@ -29,7 +29,8 @@ const FormContent = ( { } ) => { const { values, isValidForm, handleSubmit, adapter } = useAdaptiveFormContext(); - const shouldDisplayTaxRate = !hideTaxRates && useDisplayTaxRate( adapter.audienceCountries ); + const shouldDisplayTaxRate = + ! hideTaxRates && useDisplayTaxRate( adapter.audienceCountries ); const shouldDisplayShippingTime = values.shipping_time === 'flat'; const handleSubmitClick = ( event ) => { diff --git a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js index f6b37ec9b9..95233a4de8 100644 --- a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js +++ b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js @@ -332,7 +332,6 @@ test.describe( 'Configure product listings', () => { 'Successfully added time for country: "US".' ); } ); - } ); test.describe( 'Links', () => { From 98aa6f0491b12430739a0a9888887760b446f0b5 Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Tue, 20 Aug 2024 10:56:09 +0530 Subject: [PATCH 04/13] Fixes linter warnings --- .../free-listings/setup-free-listings/form-content.js | 5 +++-- .../components/free-listings/setup-free-listings/index.js | 6 +++++- js/src/edit-free-campaign/index.js | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/src/components/free-listings/setup-free-listings/form-content.js b/js/src/components/free-listings/setup-free-listings/form-content.js index b8123c58eb..d4f2295830 100644 --- a/js/src/components/free-listings/setup-free-listings/form-content.js +++ b/js/src/components/free-listings/setup-free-listings/form-content.js @@ -22,6 +22,7 @@ import ConditionalSection from '.~/components/conditional-section'; * * @param {Object} props React props. * @param {string} [props.submitLabel="Complete setup"] Submit button label. + * @param {boolean} [props.hideTaxRates=false] Whether to hide tax rate section. */ const FormContent = ( { submitLabel = __( 'Complete setup', 'google-listings-and-ads' ), @@ -29,8 +30,8 @@ const FormContent = ( { } ) => { const { values, isValidForm, handleSubmit, adapter } = useAdaptiveFormContext(); - const shouldDisplayTaxRate = - ! hideTaxRates && useDisplayTaxRate( adapter.audienceCountries ); + const displayTaxRate = useDisplayTaxRate( adapter.audienceCountries ); + const shouldDisplayTaxRate = ! hideTaxRates && displayTaxRate; const shouldDisplayShippingTime = values.shipping_time === 'flat'; const handleSubmitClick = ( event ) => { diff --git a/js/src/components/free-listings/setup-free-listings/index.js b/js/src/components/free-listings/setup-free-listings/index.js index eb27495fd1..503812d766 100644 --- a/js/src/components/free-listings/setup-free-listings/index.js +++ b/js/src/components/free-listings/setup-free-listings/index.js @@ -77,6 +77,7 @@ const getSettings = ( values ) => { * @param {() => void} [props.onContinue] Callback called once continue button is clicked. Could be async. While it's being resolved the form would turn into a saving state. * @param {string} [props.submitLabel] Submit button label, to be forwarded to `FormContent`. * @param {JSX.Element} props.headerTitle Title in the header block of this setup. + * @param {boolean} [props.hideTaxRates] Whether to hide tax rate section, to be forwarded to `FormContent`. */ const SetupFreeListings = ( { targetAudience, @@ -232,7 +233,10 @@ const SetupFreeListings = ( { validate={ handleValidate } onSubmit={ onContinue } > - + ); diff --git a/js/src/edit-free-campaign/index.js b/js/src/edit-free-campaign/index.js index b4b9be7f65..1f890845cc 100644 --- a/js/src/edit-free-campaign/index.js +++ b/js/src/edit-free-campaign/index.js @@ -208,7 +208,7 @@ const EditFreeCampaign = () => { settings={ settings } onSettingsChange={ updateSettings } shippingRates={ loadedShippingRates } - hideTaxRates={false} + hideTaxRates={ false } onShippingRatesChange={ updateShippingRates } shippingTimes={ loadedShippingTimes } onShippingTimesChange={ updateShippingTimes } From d8d0ba9f6d754875fab70f6e3ded8ded70d224f5 Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Tue, 20 Aug 2024 10:58:32 +0530 Subject: [PATCH 05/13] Removes unused code in e2e tests --- .../e2e/specs/setup-mc/step-2-product-listings.test.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js index 95233a4de8..92d618c146 100644 --- a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js +++ b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js @@ -5,7 +5,6 @@ import ProductListingsPage from '../../utils/pages/setup-mc/step-2-product-listi import { getCountryInputSearchBoxContainer, getCountryInputSearchBox, - removeCountryFromSearchBox, selectCountryFromSearchBox, } from '../../utils/page'; @@ -367,14 +366,6 @@ test.describe( 'Configure product listings', () => { ); } ); - test( 'should contain the correct URL for "Read more for Tax Rate" link', async () => { - const link = productListingsPage.getReadMoreTaxRateLink(); - await expect( link ).toBeVisible(); - await expect( link ).toHaveAttribute( - 'href', - 'https://support.google.com/merchants/answer/160162' - ); - } ); } ); test.describe( 'Click "Continue" button', () => { @@ -383,7 +374,6 @@ test.describe( 'Configure product listings', () => { productListingsPage.mockContactInformation(); productListingsPage.checkRecommendedShippingRateRadioButton(); await productListingsPage.fillEstimatedShippingTimes( '14' ); - await productListingsPage.checkNonDestinationBasedTaxRateRadioButton(); } ); test( 'should see the heading of next step and send two requests after clicking "Continue"', async () => { From 7acafdf4dbe3c6fa0edd778a483d5a68ac32464d Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Tue, 20 Aug 2024 11:01:19 +0530 Subject: [PATCH 06/13] Removes extra line break --- tests/e2e/specs/setup-mc/step-2-product-listings.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js index 92d618c146..dc76211a57 100644 --- a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js +++ b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js @@ -365,7 +365,6 @@ test.describe( 'Configure product listings', () => { 'https://support.google.com/merchants/answer/7050921' ); } ); - } ); test.describe( 'Click "Continue" button', () => { From 9cd398f3baeeba5b1351b764c382d1df359567b7 Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Fri, 23 Aug 2024 11:19:29 +0530 Subject: [PATCH 07/13] Hide default prop per CR feedback --- js/src/edit-free-campaign/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/src/edit-free-campaign/index.js b/js/src/edit-free-campaign/index.js index 1f890845cc..c5f21c7811 100644 --- a/js/src/edit-free-campaign/index.js +++ b/js/src/edit-free-campaign/index.js @@ -208,7 +208,6 @@ const EditFreeCampaign = () => { settings={ settings } onSettingsChange={ updateSettings } shippingRates={ loadedShippingRates } - hideTaxRates={ false } onShippingRatesChange={ updateShippingRates } shippingTimes={ loadedShippingTimes } onShippingTimesChange={ updateShippingTimes } From a4abb2905dbe9b5c81f9af824b730cfbbbf910eb Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Fri, 23 Aug 2024 11:39:30 +0530 Subject: [PATCH 08/13] Update error checking to ignore if hideTaxRates is true --- .../free-listings/configure-product-listings/checkErrors.js | 4 +++- js/src/components/free-listings/setup-free-listings/index.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/src/components/free-listings/configure-product-listings/checkErrors.js b/js/src/components/free-listings/configure-product-listings/checkErrors.js index fea4c66c4c..ee3d17abb7 100644 --- a/js/src/components/free-listings/configure-product-listings/checkErrors.js +++ b/js/src/components/free-listings/configure-product-listings/checkErrors.js @@ -17,7 +17,8 @@ const checkErrors = ( values, shippingTimes, finalCountryCodes, - storeCountryCode + storeCountryCode, + hideTaxRates = false ) => { const errors = {}; @@ -110,6 +111,7 @@ const checkErrors = ( * Check tax rate (required for U.S. only). */ if ( + ! hideTaxRates && ( storeCountryCode === 'US' || finalCountryCodes.includes( 'US' ) ) && ! validTaxRateSet.has( values.tax_rate ) ) { diff --git a/js/src/components/free-listings/setup-free-listings/index.js b/js/src/components/free-listings/setup-free-listings/index.js index 503812d766..02886c51e4 100644 --- a/js/src/components/free-listings/setup-free-listings/index.js +++ b/js/src/components/free-listings/setup-free-listings/index.js @@ -109,7 +109,8 @@ const SetupFreeListings = ( { values, shippingTimesData, countries, - storeCountryCode + storeCountryCode, + hideTaxRates ); }; From c2c324212806bdd0d35003c37a2fd651c57efa46 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Mon, 26 Aug 2024 15:24:33 -0500 Subject: [PATCH 09/13] Mock default MC settings with tax_rate set --- tests/e2e/specs/setup-mc/step-2-product-listings.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js index dc76211a57..2172deb28c 100644 --- a/tests/e2e/specs/setup-mc/step-2-product-listings.test.js +++ b/tests/e2e/specs/setup-mc/step-2-product-listings.test.js @@ -69,6 +69,7 @@ test.describe( 'Configure product listings', () => { payment_methods_visible: false, refund_tos_visible: false, contact_info_visible: false, + tax_rate: 'destination', }, 200, [ 'GET' ] From 4870093d73814c38c835c9498017dda2f2494849 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Mon, 26 Aug 2024 15:27:31 -0500 Subject: [PATCH 10/13] Remove unused e2e test helpers --- .../pages/setup-mc/step-2-product-listings.js | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js b/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js index ecd2d84116..dc93884fd1 100644 --- a/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js +++ b/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js @@ -169,17 +169,6 @@ export default class ProductListingsPage extends MockRequests { .filter( { hasText: 'Shipping times' } ); } - /** - * Get tax rate section. - * - * @return {import('@playwright/test').Locator} Get tax rate section. - */ - getTaxRateSection() { - return this.page - .locator( 'section' ) - .filter( { hasText: 'Tax rate (required for U.S. only)' } ); - } - /** * Get audience card. * @@ -246,17 +235,6 @@ export default class ProductListingsPage extends MockRequests { ); } - /** - * Get tax rate error. - * - * @return {import('@playwright/test').Locator} Get tax rate error. - */ - getTaxRateError() { - return this.getTaxRateSection().getByText( - 'Please specify tax rate option.' - ); - } - /** * Get "Free shipping for all orders" tag. * @@ -338,18 +316,6 @@ export default class ProductListingsPage extends MockRequests { } ); } - /** - * Get "Read more" for Tax rate link. - * - * @return {import('@playwright/test').Locator} Get "Read more" for Tax rate link. - */ - getReadMoreTaxRateLink() { - return this.getTaxRateSection().getByRole( 'link', { - name: 'Read more', - exact: true, - } ); - } - /** * Register the requests when the continue button is clicked. * @@ -483,17 +449,6 @@ export default class ProductListingsPage extends MockRequests { await this.page.waitForLoadState( LOAD_STATE.DOM_CONTENT_LOADED ); } - /** - * Check non-destination-based tax rate radio button. - * - * @return {Promise} - */ - async checkNonDestinationBasedTaxRateRadioButton() { - const radio = this.getNonDestinationBasedTaxRateRadioRow(); - await radio.check(); - await this.page.waitForLoadState( LOAD_STATE.DOM_CONTENT_LOADED ); - } - /** * Fill estimated shipping rates. * From 630c73d52cdd717ae484027e5ae1f32c121de0b5 Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Thu, 5 Sep 2024 13:28:03 +0530 Subject: [PATCH 11/13] Removes unused function --- .../utils/pages/setup-mc/step-2-product-listings.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js b/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js index dc93884fd1..c9e1a62d99 100644 --- a/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js +++ b/tests/e2e/utils/pages/setup-mc/step-2-product-listings.js @@ -135,18 +135,6 @@ export default class ProductListingsPage extends MockRequests { } ); } - /** - * Get non-destination-based tax rate radio row. - * - * @return {import('@playwright/test').Locator} Get non-destination-based tax rate radio row. - */ - getNonDestinationBasedTaxRateRadioRow() { - return this.page.getByRole( 'radio', { - name: 'My store does not use destination-based tax rates.', - exact: true, - } ); - } - /** * Get shipping rates section. * From 3e4910ffa37c31258f8f73749de598d7f62ee5eb Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Thu, 5 Sep 2024 13:30:26 +0530 Subject: [PATCH 12/13] Updates props per CR feedback --- .../free-listings/setup-free-listings/form-content.js | 2 +- js/src/components/free-listings/setup-free-listings/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/components/free-listings/setup-free-listings/form-content.js b/js/src/components/free-listings/setup-free-listings/form-content.js index d4f2295830..c1913d857f 100644 --- a/js/src/components/free-listings/setup-free-listings/form-content.js +++ b/js/src/components/free-listings/setup-free-listings/form-content.js @@ -26,7 +26,7 @@ import ConditionalSection from '.~/components/conditional-section'; */ const FormContent = ( { submitLabel = __( 'Complete setup', 'google-listings-and-ads' ), - hideTaxRates = false, + hideTaxRates, } ) => { const { values, isValidForm, handleSubmit, adapter } = useAdaptiveFormContext(); diff --git a/js/src/components/free-listings/setup-free-listings/index.js b/js/src/components/free-listings/setup-free-listings/index.js index 02886c51e4..867ff8b012 100644 --- a/js/src/components/free-listings/setup-free-listings/index.js +++ b/js/src/components/free-listings/setup-free-listings/index.js @@ -77,7 +77,7 @@ const getSettings = ( values ) => { * @param {() => void} [props.onContinue] Callback called once continue button is clicked. Could be async. While it's being resolved the form would turn into a saving state. * @param {string} [props.submitLabel] Submit button label, to be forwarded to `FormContent`. * @param {JSX.Element} props.headerTitle Title in the header block of this setup. - * @param {boolean} [props.hideTaxRates] Whether to hide tax rate section, to be forwarded to `FormContent`. + * @param {boolean} [props.hideTaxRates=false] Whether to hide tax rate section, to be forwarded to `FormContent`. */ const SetupFreeListings = ( { targetAudience, From 5db0bad2c5a613c146121b10417f169b80c3deff Mon Sep 17 00:00:00 2001 From: Darshan Sawardekar Date: Wed, 11 Sep 2024 10:48:46 +0530 Subject: [PATCH 13/13] Updates jsdoc --- .../free-listings/setup-free-listings/form-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/components/free-listings/setup-free-listings/form-content.js b/js/src/components/free-listings/setup-free-listings/form-content.js index c1913d857f..c195e3cb4e 100644 --- a/js/src/components/free-listings/setup-free-listings/form-content.js +++ b/js/src/components/free-listings/setup-free-listings/form-content.js @@ -22,7 +22,7 @@ import ConditionalSection from '.~/components/conditional-section'; * * @param {Object} props React props. * @param {string} [props.submitLabel="Complete setup"] Submit button label. - * @param {boolean} [props.hideTaxRates=false] Whether to hide tax rate section. + * @param {boolean} [props.hideTaxRates] Whether to hide tax rate section. */ const FormContent = ( { submitLabel = __( 'Complete setup', 'google-listings-and-ads' ),