Skip to content

Free Listings + Paid Ads: Combine the audience and shipping steps #1616

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

Conversation

eason9487
Copy link
Member

@eason9487 eason9487 commented Aug 4, 2022

Changes proposed in this Pull Request:

It's a part of 📌 Adjust the setting sections in the onboarding steps in #1610. Mainly focus on combining the audience and shipping steps for the onboarding flow and the editing free listings page. Most visual and wording changes are not included.

  • Move the SetupFreeListings component of editing free listings to the shared directory.
  • Change the shared ChooseAudience to ChooseAudienceSection and merge it into SetupFreeListings with corresponding validations for the editing free listings.
  • Replace SetupFreeListings with the shared one for the onboarding flow.
  • Remove unused files and an npm package use-debounce.

It also handles some issues:

Screenshots:

📷 Onboarding flow

wp test_wp-admin_admin php_page=wc-admin path=%2Fgoogle%2Fsetup-mc google-mc=connected

📷 Edit free listings

wp test_wp-admin_admin php_page=wc-admin path=%2Fgoogle%2Fproduct-feed google-mc=connected guide=submission-success (2)

Detailed test instructions:

Onboarding flow

  1. Disconnect all accounts or run these SQLs to delete related GLA settings
    DELETE FROM wp_options WHERE option_name IN ('gla_mc_setup_completed_at', 'gla_target_audience', 'gla_merchant_center');
    DELETE FROM wp_gla_shipping_rates;
    DELETE FROM wp_gla_shipping_times;
  2. Start the onboarding setup and check if the combined step for audience and shipping works correctly.
    • Auto-saving mechanism for audience, MC settings, shipping rates, and shipping times
    • All possible ways to add/edit shipping times
    • Switch the location options of audience to see if all countries and selected countries options affect the corresponding shipping sections correctly.
  3. Change the audience countries to see if the removed countries are removed from shipping sections as well.
  4. Edit settings to check if the disabled status of the "Continue" button is correct.
  5. Continue or switch between steps to view whether it works as expected.
  6. Refer to the replicate steps in Shipping values flash during the onboarding setup #1078 to check if the value flash problem in shipping time fields is fixed.
    • 💡 The problem in shipping rate fields has been fixed in another PR before.

Edit free listings

  1. Go to the Edit Free Listings page.
  2. It should be changed to a one-pager without steps.
  3. Simiar to the tests in the onboarding flow except for the auto-saving mechanism, operate the combined audience and shipping to see if they work well.
  4. Edit some values to see if the unsaved data prompt pops up when navigating away.
  5. Edit the above values back to see if there is no prompt when navigating away.

Additional details:

  • The auto-fill feature of flat shipping rates in the onboarding flow is removed from the frontend side. Ref: p1659494048432789-slack-C01E9LB4X61
  • Not sure why but mc/target_audience will respond with an 400 error if saving with empty countries. From my memory, it should be ok before because the UI allows merchants to unselect all. 🤔

Changelog entry

Add - Combine the audience and shipping steps for the onboarding flow and the editing free listings page.
Fix - Shipping time values flash during the onboarding setup.

@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`checkErrors Audience When the audience countries array is empty and the value of audience location option is 'selected', should not pass 1`] = `"Please select at least one country."`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💅 Out of this PR and opinionated

Maybe to consider migration to unit testing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean replacing expect( errors.countries ).toBe( 'Please select at least one country.' ); with expect( errors.countries ).toMatchSnapshot(); ? If so, some related discussions can be found in #893 (comment) and #927 (comment).

Comment on lines +73 to +74
shipping_rate: 'automatic',
shipping_time: 'flat',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Not a suggestion, just curious. Why we are not adding the default values inside data store DEFAULT_STATE ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw we use null values as checkers for other stuff... probably because of that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent here is to trigger API to save the form's default values. It would be easier and more suitable to handle the intent here.

In addition, moving the default values of form layer to wp-data store layer will also bring different abstraction of data/states isolation. Since isResolving and hasFinishedResolution are not enough to cover all statuses of a state in wp-store (see issue #438.), and considering the "statuses" of states in wp-data haven't yet had a consistent definition/convention, for now, the default value in a wp-data state is more like the status that tells the state is not ready to be used. And after receiving the data from API, the state will be changed to that data, which will also change the status of that state to "the status of the state is ready, and the data is the state itself".

IMO, before a consistent definition/convention of the statuses, states, and data in wp-data is created, it's probably hard to say how to set a default value would be a good practice.

@@ -58,6 +100,15 @@ const SavedSetupStepper = ( { savedStep, onRefetchSavedStep = () => {} } ) => {
}
};

function handleFormChange( errorMessage, newValue ) {
this( newValue ).catch( () => createNotice( 'error', errorMessage ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💅 it was a bit confusing to understand what this was doing here. I saw after in the code that we bind the action to be called in SetupFreeListings.

However, would be nice to add a JSDOC in this function explaining whats going on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in d8ecc08.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now is perfect! thanks

Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I checked the behaviour. Tested locally and I didn't find any error. All the combos worked fine for me.
  • I checked also the code. Since there is a lot of files deleted and moved around mixed with changes in those files. It was a bit hard to differentiate what was added/changed and what was just a copy paste for the deleted files. However everything looks good for me... left a few comments and minor questions

@puntope
Copy link
Contributor

puntope commented Aug 11, 2022

Not sure why but mc/target_audience will respond with an 400 error if saving with empty countries. From my memory, it should be ok before because the UI allows merchants to unselect all. 🤔

I was unable to save with empty value in the audience selector. 🤔 I guess do you mean it shows an error when the autosave runs when the selector is empty?

@eason9487
Copy link
Member Author

Thanks for the review, @puntope

  • I checked also the code. Since there is a lot of files deleted and moved around mixed with changes in those files. It was a bit hard to differentiate what was added/changed and what was just a copy paste for the deleted files.

Sorry for the inconvenience, I was trying to separate this as smaller PRs but the second one would only be including file deletions. So I ended up choosing to use deal with it altogether.

There are no deleted file changes that were caused by copy-and-paste. All deleted files were actually deleted (20e758f). And two deleted-and-added files are completely different:

  • js/src/components/free-listings/choose-audience-section/index.js
  • js/src/components/free-listings/choose-audience-section/choose-audience-section.scss

I guess do you mean it shows an error when the autosave runs when the selector is empty?

Yes. UI allows the operation to clear the value in the audience selector but then it causes an error. It may confuse merchants. I will check it later while working on this project and open a follow-up issue if needed.

@eason9487 eason9487 requested a review from puntope August 12, 2022 06:00
@puntope
Copy link
Contributor

puntope commented Aug 12, 2022

Yes. UI allows the operation to clear the value in the audience selector but then it causes an error. It may confuse merchants. I will check it later while working on this project and open a follow-up issue if needed.

I agree

@eason9487 eason9487 merged commit 16244ee into feature/1610-streamlined-onboarding Aug 15, 2022
@eason9487 eason9487 deleted the update/1610-merge-audience-shipping-step-2-3 branch August 15, 2022 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: update Big changes to something that wasn't broken.
Projects
None yet
2 participants