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 lessons not being saved when creating a course on the latest Gutenberg version #7091

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

m1r0
Copy link
Member

@m1r0 m1r0 commented Aug 11, 2023

Resolves #7083

Proposed Changes

This bug was caused because of the logic detecting if a post is saved does not work on the latest Gutenberg version.

In our logic, we're tracking 3 different save requests - saving the post, saving the post meta, and saving the course structure. The problem was that in the latest Gutenberg version, the post meta saving request starts while the post saving request is still running. That caused a bug because the logic wasn't expecting the requests to happen in parallel. This PR changes the logic to track the requests independently.

I wasn't able to find a good way to add integration tests for this, but it should be covered by E2E tests already.

Testing Instructions

  1. Install the latest version of the Gutenberg plugin
  2. Go to Sensei LMS -> Courses -> New Course
  3. In the Course Outline block, select "Start with a blank canvas"
  4. Save the course as draft
  5. Make sure the lessons are saved
  6. Disable the Gutenberg plugin and make sure the same process works

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

The order of save post events is different on the latest Gutenberg version so our method needed some adjustments.
This aslo fixes the lessons not being saved when creating a course.
@m1r0 m1r0 added this to the 4.16.1 milestone Aug 11, 2023
@m1r0 m1r0 self-assigned this Aug 11, 2023
@github-actions
Copy link

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit 83f81de and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
blocks/single-course.js 27 kB -6 B ( -0.03% ⬇️ )
blocks/quiz/index.js 32.2 kB -3 B ( -0.01% ⬇️ )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #7091 (83f81de) into trunk (26ef3f4) will increase coverage by 0.01%.
Report is 11 commits behind head on trunk.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7091      +/-   ##
============================================
+ Coverage     49.32%   49.33%   +0.01%     
- Complexity    10538    10539       +1     
============================================
  Files           575      575              
  Lines         44501    44503       +2     
  Branches        402      402              
============================================
+ Hits          21950    21956       +6     
+ Misses        22224    22220       -4     
  Partials        327      327              
Files Changed Coverage Δ
assets/shared/structure/structure-store.js 80.76% <50.00%> (ø)
...ers/class-sensei-unsupported-theme-handler-cpt.php 85.71% <100.00%> (+7.02%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecf3cfc...83f81de. Read the comment docs.

@m1r0 m1r0 marked this pull request as ready for review August 11, 2023 18:27
@m1r0 m1r0 requested a review from a team August 11, 2023 18:27
Copy link
Contributor

@Imran92 Imran92 left a comment

Choose a reason for hiding this comment

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

Works as expected 👍

@m1r0 m1r0 merged commit ffe2abc into trunk Aug 14, 2023
21 checks passed
@m1r0 m1r0 deleted the fix/lessons-not-saved-when-creating-course branch August 14, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants