Skip to content

Fixes customer edit issue when there is a newsletter queue associated with it. #30727

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

Merged
merged 2 commits into from
Nov 14, 2020

Conversation

engcom-Golf
Copy link
Contributor

@engcom-Golf engcom-Golf commented Oct 30, 2020

Description (*)

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Customer Edit Issue when there is a newsletter queue associated with it. #30645 Customer Edit Issue when there is a newsletter queue associated with it.

Manual testing scenarios (*)

  1. Customer Edit Issue when there is a newsletter queue associated with it. #30645 Customer Edit Issue when there is a newsletter queue associated with it.
  2. Please check newsletter tab queue grid functionality on the customer edit page

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 Oct 30, 2020

Hi @engcom-Golf. 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

@engcom-Golf
Copy link
Contributor Author

@magento run all tests

@engcom-Golf engcom-Golf marked this pull request as ready for review November 2, 2020 09:10
@ghost ghost added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Nov 2, 2020
@aleron75
Copy link
Contributor

aleron75 commented Nov 3, 2020

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @aleron75. Thank you for your request. I'm working on Magento instance for you.

@aleron75
Copy link
Contributor

aleron75 commented Nov 3, 2020

@magento give me test instance

@magento-deployment-service
Copy link

Hi @aleron75. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@@ -74,6 +76,9 @@ public function testRenderingNewsletterBlock()
);
$this->assertStringNotContainsString('checked="checked"', $body);
$this->assertStringContainsString('\u003Cspan\u003ESubscribed to Newsletter\u003C\/span\u003E', $body);
$this->assertStringContainsString('\u003ENo Newsletter Found\u003C', $body);
$this->assertMatchesRegularExpression(
Copy link
Contributor

@aleron75 aleron75 Nov 3, 2020

Choose a reason for hiding this comment

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

Hello @engcom-Golf,
thanks for your PR.

Please help me understand something that is unclear to me.

According to the following assertion:

$this->assertStringNotContainsString('checked="checked"', $body);

we expect that the customer is not subscribed;

but according to the newly added assertion:

$this->assertMatchesRegularExpression('~.+\/newsletter\\\/template\\\/preview\\\/id\\\/\d+\\\/subscriber\\\/\d+\\\/.+~', $body);

it seems we expect that the customer was considered a subscriber because we expect to see the preview link in the grid of queued emails.

Furthermore, looking at the fixtures, I don't see any subscription created for the test customer so I don't get how the tests can pass.

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an example, the customer can unsubscribe from newsletters but have already received ones. They have to be shown in the grid with sent status. The logic of drawing the subscription checkbox is not connected with the newsletters queue.

Copy link
Contributor

@aleron75 aleron75 Nov 5, 2020

Choose a reason for hiding this comment

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

I get the point on the checkbox, but I don't understand where in the fixtures we set a received newsletter for the customer.

To clarify, I verified the PR and it seems ok, it solves the issue, I want just to check whether we have a false positive test or it's just me :)

@@ -59,6 +59,8 @@ protected function tearDown(): void

/**
* @magentoDataFixture Magento/Customer/_files/customer_sample.php
* @magentoDataFixture Magento/Newsletter/_files/newsletter_sample.php
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend make new test case for that and leave old as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -225,7 +225,10 @@ public function addCustomerFilter(int $customerId): Collection
)->join(
['subscriber' => $this->getTable('newsletter_subscriber')],
'link.subscriber_id=subscriber.subscriber_id',
['subscriber_store_id' => 'subscriber.store_id']
[
Copy link
Contributor

Choose a reason for hiding this comment

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

Please cover this code changes with integration test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

covered in dev/tests/integration/testsuite/Magento/Newsletter/Model/ResourceModel/Queue/CollectionTest.php

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Add a new customer which is also subscribed to newsletter.
    Sub news

  2. Create a newsletter in Marketing>Newsletter Templates
    New template

  3. Queue the newsletter
    queue news

  4. Go to the customer edit page and try to edit their information

Before applying changes provided in this PR

97159123-0e1f0280-1783-11eb-8f7d-74322d645e42

After switching to the PR
Customer

@engcom-Bravo
Copy link
Contributor

✔️
Correct template_id and subscriber_id is set in the View newsletter template link admin/newsletter/template/preview/id/3/subscriber/3/key/5e2ce99354cdf81dbd3a3e2989d4c0706b3f75d43f0a77cd0462e7f98345686a/
Correct subscriber_id and customer_id in newsletter_subscriber database table
db_template

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

Retested with the latest commit

@zakdma
Copy link
Contributor

zakdma commented Nov 13, 2020

@magento-engcom-team
Copy link
Contributor

@zakdma the pull request successfully imported.

@magento-engcom-team magento-engcom-team merged commit 084a8dd into magento:2.4-develop Nov 14, 2020
@m2-assistant
Copy link

m2-assistant bot commented Nov 14, 2020

Hi @engcom-Golf, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests bugfix Component: Customer Component: Newsletter Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customer Edit Issue when there is a newsletter queue associated with it.
6 participants