Skip to content
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

Move the pre-launch checklist from step 3 to 4 for the MC setup #927

Merged
merged 5 commits into from
Aug 4, 2021

Conversation

eason9487
Copy link
Member

Changes proposed in this Pull Request:

Partial of #863 and based on #926

  • Move js/src/setup-mc/setup-stepper/setup-free-listings/pre-launch-checklist in the folder of js/src/setup-mc/setup-stepper/store-requirements/
  • Separate the pre-launch checks into another validation function
  • Move the pre-launch checklist from step 3 to 4 for the MC setup and relevant checking and data updating

Screenshots:

Kapture.2021-08-02.at.20.56.40.mp4

Detailed test instructions:

  1. Go to the MC setup and proceed to step 3
  2. The pre-launch checklist should no longer be in step 3
  3. Change some product listings settings to see if the disable state of "Continue" button works correctly
  4. Proceed to step 4 and the pre-launch checklist should be at the bottom
  5. Fill in the contact information
  6. Tick or untick each pre-launch checklist to see if the disable state of "Complete setup" button works correctly

Changelog entry

@eason9487 eason9487 requested a review from a team August 2, 2021 13:01
@eason9487 eason9487 self-assigned this Aug 2, 2021
Copy link
Member

@ecgan ecgan left a comment

Choose a reason for hiding this comment

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

Code looks good. Just left a few ❔ 💅 on one test file.

I was testing the PR halfway and facing a blocker in Setup MC Step 4, where the contact-information API returns null for wc_address, causing useStoreAddress to throw error "TypeError: Cannot read property 'country' of null". I have already posted this in our project slack channel (p1627923876015900-slack-C01E9LB4X61) for advice. Since the issue is not related to this PR, and this PR looks simple, I'd say feel free to merge and get ourselves unblocked.

Comment on lines 83 to 99
it( 'When all requirements are true, should pass', () => {
const values = {
website_live: true,
checkout_process_secure: true,
payment_methods_visible: true,
refund_tos_visible: true,
contact_info_visible: true,
};

const errors = checkErrors( values, [], [], [] );

expect( errors ).not.toHaveProperty( 'website_live' );
expect( errors ).not.toHaveProperty( 'checkout_process_secure' );
expect( errors ).not.toHaveProperty( 'payment_methods_visible' );
expect( errors ).not.toHaveProperty( 'refund_tos_visible' );
expect( errors ).not.toHaveProperty( 'contact_info_visible' );
} );
Copy link
Member

Choose a reason for hiding this comment

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

❔ I think this is similar to the other test it( 'When all checks are passed, should return an empty object',, no? I would just retain either one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding the test case of 'When all checks are passed, should return an empty object' was mentioned at #871 (comment). I think they look similar but have different purposes though. But I don't have a concrete opinion here. Probably we could have @tomalec 's thought on this?

Copy link
Member

@tomalec tomalec Aug 3, 2021

Choose a reason for hiding this comment

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

I agree the test is a bit redundant. What I mean in the linked comment, was mostly about the non-precise/accurate term "should pass" in the test description (which was explained in the code comment), and non 1:1 matching assertions with descriptions.

Here is an alternative suggestion, which also removes unused parameters, and snapshots:
feature/863-pre-launch-checklist...feature/863-pre-launch-checklist-tests (feel free to merge it if you like it)

 PASS  js/src/setup-mc/setup-stepper/store-requirements/pre-launch-checklist/checkErrors.test.js
  checkErrors
    Should check the presence of required properties in the given object. Returned object should have error messages for respective properties.
      ✓ website_live === true (5ms)
      ✓ checkout_process_secure === true (1ms)
      ✓ payment_methods_visible === true (1ms)
      ✓ refund_tos_visible === true
      ✓ contact_info_visible === true
      ✓ When there are many missing/invalid properties, should report them all. (1ms)
      ✓ When all properties are valid, should return an empty object. (1ms)

Copy link
Member Author

Choose a reason for hiding this comment

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

@tomalec, thanks for the suggestion. I merged the feature/863-pre-launch-checklist-tests branch.

Comment on lines 29 to 34
it( 'should indicate multiple unpassed checks by setting properties in the returned object', () => {
const errors = checkErrors( {} );

expect( errors ).toHaveProperty( 'website_live' );
expect( errors ).toHaveProperty( 'checkout_process_secure' );
} );
Copy link
Member

Choose a reason for hiding this comment

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

❔ I think this test is not needed because it is covered by it( 'When there are any requirements are not true, should not pass'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above #927 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced along with #927 (comment).

Comment on lines 56 to 63
// Invalid value
const values = {
website_live: false,
checkout_process_secure: 1,
payment_methods_visible: 'true',
refund_tos_visible: [],
contact_info_visible: {},
};
Copy link
Member

Choose a reason for hiding this comment

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

💅 I would split the // Not set yet and // Invalid value into two different tests, instead of within one it() block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed by 0c9bd95.

expect( errors.refund_tos_visible ).toMatchSnapshot();

expect( errors ).toHaveProperty( 'contact_info_visible' );
expect( errors.contact_info_visible ).toMatchSnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

❔ 💅 Personally I wouldn't use toMatchSnapshot here. Let's say we change the checkErrors function, the error message is changed to a new string (e.g. 'Please check the requirements.' with an 's'), causing the snapshots to change. We would need to update the snapshots. I feel those are like frictions and the tests are not specific enough to convey those intention.

I'd say having toHaveProperty is enough, or maybe even check that the property is of string type. Whether to test for the exact string 'Please check the requirement.' is another question because currently we don't use that in the UI really, so I would leave it out for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

We had discussed a similar context at #893 (comment). Even though the error messages are not used on UI currently, but the context of this question is the same to me. The message texts are not the main focus here, but we still have snapshots to alert if they're changed on purpose or unintended. And it only takes an action to press a u key to update the snapshot if it's a correct change. I don't see obvious cons here.

Considering these test cases were moved out from the original checkErrors.test.js, and we had already over the deadline of this feature. I'd like to open a follow-up 📜 issue for this if this concept doesn't work for you.

Base automatically changed from feature/863-integrate-api to feature/contact-info August 4, 2021 07:29
@eason9487 eason9487 merged commit d1d1b51 into feature/contact-info Aug 4, 2021
@eason9487 eason9487 deleted the feature/863-pre-launch-checklist branch August 4, 2021 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants