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

Fix for wildcard section reload being broken by section-config refacor #29081

Conversation

complexthings
Copy link

@complexthings complexthings commented Jul 12, 2020

Description (*)

Since the refactor of section-config.js in Magento_Customer (976302d) reloading of all customer-data sections via wildcard * has caused requests to customer/section/load to respond 400.

image

This causes issues when you call reload directly from customer-data or you request wildcard section reloading via an action in sections.xml

You can validate this yourself by executing the following code from your devtools console:

require('Magento_Customer/js/customer-data').reload('*');

I've added an additional condition to the getFromServer method's parameters variable that checks to see if the wildcard section request is present, if it is, it makes sure parameters gets set to [] instead of ['*'] which fails.

image

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Customer data not retrieved after executing a custom login controller #28428
  2. Fixes [Backward compatibility] Customer section load with one section causes an error #28154

Manual testing scenarios (*)

  1. In your Browser's devtools, execute the following code:
require('Magento_Customer/js/customer-data').reload('*');

This should return all customer-data sections.
2. Hitting any route with a request where the action expects to reload '*'.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jul 12, 2020

Hi @complexthings. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@complexthings
Copy link
Author

@magento run all tests

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jul 13, 2020

@complexthings interesting... I see case with * (all) is covered with auto test, so it suppose to work...

it('Adds sections for all URLs "*" to found ones.', function () {
obj['Magento_Customer/js/section-config']({
sections: {
'path': [
'section'
],
'*': [
'all'
]
},
baseUrls: [
'http://localhost.com/'
]
});
expect(obj.getAffectedSections('http://localhost.com/path')).toEqual(['section', 'all']);
});
it('Returns "*" sections for all URLs.', function () {
obj['Magento_Customer/js/section-config']({
sections: {
'*': [
'all'
]
},
baseUrls: [
'http://localhost.com/'
]
});
expect(obj.getAffectedSections('http://localhost.com/path')).toEqual(['all']);
});

Related to #25764

@krzksz could you review this PR?

@ihor-sviziev ihor-sviziev requested a review from krzksz July 13, 2020 11:14
@complexthings
Copy link
Author

@ihor-sviziev section-config does what it's supposed to, the refactor works, it just happened to break customer-data.js

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

@ghost ghost assigned ihor-sviziev Jul 14, 2020
@ihor-sviziev ihor-sviziev added Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests Award: bug fix Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Jul 14, 2020
Copy link
Contributor

@krzksz krzksz left a comment

Choose a reason for hiding this comment

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

@ihor-sviziev suggestions look good to me. It would be great to have this module covered with unit tests.

@ghost ghost assigned krzksz Jul 14, 2020
@complexthings complexthings force-pushed the bugfix/wildcard-section-reload-broken branch from 5da0a04 to 4f10b5d Compare July 14, 2020 11:17
@complexthings
Copy link
Author

@ihor-sviziev @krzksz I am working on jasmine tests for customer-data.js but it will take some time.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jul 15, 2020 via email

@complexthings
Copy link
Author

@ihor-sviziev @krzksz I added js unit test for customer-data.js

@complexthings complexthings force-pushed the bugfix/wildcard-section-reload-broken branch from 71c6d14 to 1505a36 Compare July 20, 2020 20:08
@complexthings
Copy link
Author

@magento run all tests

@complexthings
Copy link
Author

@magento run Static Tests, Unit Tests

@complexthings
Copy link
Author

@magento run Static Tests, Unit Tests

@complexthings
Copy link
Author

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-8093 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. In Browser's devtools, execute the following code:
require('Magento_Customer/js/customer-data').reload('*');

Before: ✖️ Js error:

Screenshot from 2020-09-16 14-42-31

After: ✔️ It returns all customer-data sections.

Screenshot from 2020-09-16 15-20-39

@engcom-Alfa engcom-Alfa added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Sep 22, 2020
@magento-engcom-team magento-engcom-team added Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner labels Sep 22, 2020
@magento-engcom-team magento-engcom-team merged commit f0d0840 into magento:2.4-develop Sep 23, 2020
@m2-assistant
Copy link

m2-assistant bot commented Sep 23, 2020

Hi @complexthings, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@pitbulk
Copy link

pitbulk commented Oct 15, 2020

After apply the changes, one of my customer reported me 2 different related issues:

  • If in the Magento instance exists customers with similar fullname (same lastname for example), the message that appears on the welcome message mismatch the fullname (wrong is loaded). It was verified that the data of the logged user that appears on the profile view is different than the one loaded on the customer data object loaded by js for printing the welcome message
  • After login, if the user proceeds to checkout, the login popup appear even if the user was previously logged.
    Similar than the issue described here: https://github.com/mageplaza/magento-2-social-login/issues/197

I created a new ticket:
#30498

Hopefully @complexthings can fix this one as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Area: Lib/Frontend Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: test coverage Component: Customer Component: Multishipping help wanted Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Risk: low Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Archived in project