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: fetching and display of sync errors after saving #1670

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Oct 14, 2024

All Submissions:

Changes proposed in this Pull Request:

Fixes a race condition with concurrent fetch requests in the Redux store that can prevent sync errors from being displayed, and improves the sync error messaging, especially for Mailchimp, which often returns errors in an additional errors array instead of in a single error message.

How to test the changes in this Pull Request:

  1. On trunk, in a test site connected to Mailchimp, create a new newsletter.
  2. Set the "Sender Name" to something with invalid characters, such as $ Invalid @ Sender ! Name #
  3. Open the devtools console > Network tab and filter XHR requests by newsletters/v1. Save the newsletter as a draft and observe that after the save completes, a post-mjml POST request is fired, followed by a retrieve GET request, but possibly no sync-error request (because the fetchNewsletterData and fetchSyncErrors dispatchers are fired at the same time, the async response from fetchNewsletterData will overwrite the fetchSyncErrors request in the Redux store). Also observe that no error message is shown in the editor after this sequence of requests.
  4. Check out this branch, repeat steps 2-3 and this time confirm that the save request is followed by a post-mjml POST request, a retrieve request, AND a sync-error request, like so:
Screenshot 2024-10-14 at 3 44 59 PM
  1. Also confirm that a post-sync error message is shown in the editor with details of why the sync failed:
Screenshot 2024-10-14 at 3 40 54 PM

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo self-assigned this Oct 14, 2024
@dkoo dkoo requested a review from a team as a code owner October 14, 2024 21:46
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 20.86%. Comparing base (0ae5cc5) to head (bfc92d0).

Files with missing lines Patch % Lines
...mailchimp/class-newspack-newsletters-mailchimp.php 0.00% 3 Missing ⚠️
...ign/class-newspack-newsletters-active-campaign.php 0.00% 1 Missing ⚠️
...ct/class-newspack-newsletters-constant-contact.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk    #1670   +/-   ##
=========================================
  Coverage     20.85%   20.86%           
  Complexity     2658     2658           
=========================================
  Files            48       48           
  Lines          9776     9774    -2     
=========================================
  Hits           2039     2039           
+ Misses         7737     7735    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dkoo dkoo merged commit cdf2e24 into trunk Oct 18, 2024
7 checks passed
@dkoo dkoo deleted the fix/sync-error-handling branch October 18, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Approved Ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants