Skip to content

test: replacing snapshot tests with rtl tests part 12 #2222

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 25, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @jacobo-dominguez-wgu!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Jun 25, 2025
@jacobo-dominguez-wgu jacobo-dominguez-wgu added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Jun 25, 2025
@jacobo-dominguez-wgu jacobo-dominguez-wgu moved this from Needs Triage to Ready for Review in Contributions Jun 25, 2025
@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the depr-shallow-spanshot-test-12 branch from 96cc163 to e111ebc Compare June 25, 2025 15:53
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.18%. Comparing base (75ea750) to head (b958d75).
Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2222      +/-   ##
==========================================
+ Coverage   94.09%   94.18%   +0.08%     
==========================================
  Files        1164     1167       +3     
  Lines       24507    24678     +171     
  Branches     5315     5270      -45     
==========================================
+ Hits        23061    23243     +182     
+ Misses       1369     1367       -2     
+ Partials       77       68       -9     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tonybusa tonybusa self-requested a review June 26, 2025 22:07
@tonybusa
Copy link
Contributor

Adding my review:

  • Checked out branch, ran all relevant tests - passed
  • Video Editor Component:
    • License Widget:
    • Options for All Rights Reserved and Creative Commons shows
    • Creative Commons details:
      image
    • All Rights Reserved details:
image

@tonybusa
Copy link
Contributor

tonybusa commented Jun 26, 2025

Video Editor Component

  • Transcript Widget:
    image

Side note - I checked on both this branch and master, and if you have multiple transcripts added, and delete 1 of them, all rows get deleted and user has to start over:
image

@tonybusa
Copy link
Contributor

Problem Editor Component:

  • Edit Problem View Settings Widget
    • details render correctly:
image

I wasn't sure how to test the Randomization settings of the component from a product/user perspective but tests did pass.

import {
render, screen, initializeMocks, fireEvent,
} from '@src/testUtils';
import { formatMessage } from '../../../../../../../testUtils';
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious if we should use a barrel file or a baseUrl in the tsconfig settings to avoid these long relative paths. I see a couple of imports like this throughout these tests. See: https://stackoverflow.com/a/34926643 for examples.

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.

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the depr-shallow-spanshot-test-12 branch from e111ebc to f1b2e9f Compare June 27, 2025 14:58
Comment on lines 135 to 157
describe('mapDispatchToProps', () => {
test('setBlockTitle from actions.app.setBlockTitle', () => {
expect(mapDispatchToProps.setBlockTitle).toEqual(actions.app.setBlockTitle);
});
});

describe('mapDispatchToProps', () => {
test('updateSettings from actions.problem.updateSettings', () => {
expect(mapDispatchToProps.updateSettings).toEqual(actions.problem.updateSettings);
});
});

describe('mapDispatchToProps', () => {
test('updateField from actions.problem.updateField', () => {
expect(mapDispatchToProps.updateField).toEqual(actions.problem.updateField);
});
});

describe('mapDispatchToProps', () => {
test('updateAnswer from actions.problem.updateAnswer', () => {
expect(mapDispatchToProps.updateAnswer).toEqual(actions.problem.updateAnswer);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these are useful tests, and they're definitely not user-centric in any way. In particular, mapDispatchToProps should be eventually replaced with useDispatch hooks, and mapStateToProps should be replaced with useSelector hooks (ref), so I don't really want the tests to be depending on that sort of implementation detail.

If it's a coverage issue that you're trying to solve, it may be necessary to just do that mapDispatchToProps -> useDispatch refactor now (it's easy), and the lines will be covered since the hooks will be used in the component render.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually those test were already there, I did not remove/update them because were not using any of the elements of the react-unit-test-utils library. I will remove it now since they are not providing any extra value and are not user centric.

Comment on lines 354 to 360
describe('mapDispatchToProps', () => {
const dispatch = jest.fn();
test('updateField from actions.video.updateField', () => {
// @ts-ignore
expect(mapDispatchToProps.updateField).toEqual(dispatch(actions.video.updateField));
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, don't think there's any value in doing basic tests on the values of mapDispatchToProps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the depr-shallow-spanshot-test-12 branch from f1b2e9f to b958d75 Compare July 1, 2025 15:12
@jacobo-dominguez-wgu jacobo-dominguez-wgu requested review from bradenmacdonald and a team July 1, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

Deprecate react-unit-test-utils part 12
4 participants