Skip to content

test: give MathJax v4 Problem specs from openedx-platform a home in xblocks-core - #320

Open
irfanuddinahmad wants to merge 2 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/problem-mathjax-v4-specs
Open

irfanuddinahmad wants to merge 2 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/problem-mathjax-v4-specs

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Update (2026-11-10): Rebased onto main after #244: the files are now src/xblock_problem/assets/spec/display_spec.js and src/xblock_problem/capa/tests/test_inputtypes.py. No test changed. On the rebased branch: FormulaEquationTest 12/12, and the Problem karma suite 113 of 113 (headless Chrome locally).

Summary

Gives every test that openedx/openedx-platform#33555 (MathJax v4 upgrade, merged 2026-11-05) added to the built-in block's xmodule/js/spec/capa/display_spec.js a counterpart here. openedx/openedx-platform#38751 removes that file along with the built-in Problem block. This follows the Slash-n-Burn rule agreed with @farhan: no platform test is deleted; each one is moved here, or kept in the platform with modifications.

Moved unchanged (3)

These apply to the extracted block and pass against it as is:

Original test (name kept) Where
should clear and typeset the math element assets/spec/display_spec.js › refreshMath
wraps calculator input in backticks for input.math assets/spec/display_spec.js › refreshMath
clears preview and skips typesetPromise on empty input assets/spec/display_spec.js › refreshMath formula and delimiter handling

The only adaptation is the extracted block's Problem(runtime, element) constructor.

Replaced with tests of the path that runs (6)

The other 6 specs tested the built-in block's client-side refreshMath rendering of formula-equation input previews. That path never runs on master, because the toggle is True, and #38751 removes it. In this repo, formula-equation previews are deliberately rendered only by the server (preview_formcalc, via formula_equation_preview.js). That's the most recent design, from 989ae32, and the October follow-ups kept it. So the replacements assert what that path actually does for the same inputs:

Original platform spec Counterpart here
bind the formulaequationinput Existing: formula_equation_preview_spec › makes a request on user input, and display_spec › does not bind refreshMath to formula equation inputs
wraps calculator syntax in backticks for formulaequationinput New: FormulaEquationTest.test_formcalc_ajax_calculator_syntax_renders_as_latex. R_1*R_2/R_3 → \frac{R_{1}\cdot R_{2}}{R_{3}}
preserves explicit TeX delimiters \(...\) New: test_formcalc_ajax_inline_tex_delimiters_rejected
preserves display math TeX delimiters \[\] New: test_formcalc_ajax_display_tex_delimiters_rejected
preserves double-dollar delimiters New: test_formcalc_ajax_double_dollar_delimiters_rejected
preserves single-dollar delimiters New: test_formcalc_ajax_single_dollar_delimiters_rejected

The four delimiter tests assert that the server rejects TeX-delimited input with Sorry, couldn't parse formula and echoes the formula back. The new Python tests call the real latex_preview, with no mocks.

Test plan

  • Problem karma suite run locally (headless Chrome): 113 of 113 SUCCESS (110 existing + 3 moved)
  • pytest src/xblock_problem/capa/tests/test_inputtypes.py::FormulaEquationTest: 12 passed (7 existing + 5 new)
  • ruff check, ruff format --check, pylint clean
  • CI green

Related: openedx/openedx-platform#38751, openedx/openedx-platform#33555, epic openedx/openedx-platform#37819

🤖 Generated with Claude Code

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 6, 2026
@openedx-webhooks

openedx-webhooks commented Nov 6, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/axim-engineering.

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.

Details
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 Nov 6, 2026
@irfanuddinahmad irfanuddinahmad changed the title test: port MathJax v4 refreshMath specs (Problem) from openedx-platform test: give MathJax v4 Problem specs from openedx-platform a home in xblocks-core Nov 6, 2026
@irfanuddinahmad
irfanuddinahmad marked this pull request as ready for review November 6, 2026 10:11
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

@farhan @navinkarkera this gives every test that openedx/openedx-platform#33555 added to the built-in Problem display_spec.js a home here, so openedx/openedx-platform#38751 can remove the built-in block without deleting any tests.

  • 3 tests moved unchanged. They apply to the extracted block as is.
  • 6 tests replaced. They covered the built-in block's client-side refreshMath formula-equation preview, which never runs with the toggle on. Navin, your most recent design here (989ae32) renders those previews only through the server's preview_formcalc, so the replacements assert what that path does for the same inputs. For example, R_1*R_2/R_3 renders as \frac{R_{1}\cdot R_{2}}{R_{3}}, and \(..\), \[..\], $$..$$ and $..$ are rejected with a parse error.

Navin, if the server-rendered behavior isn't what you intend for formula-equation previews, let us know and we'll adjust the assertions. The full mapping is in the PR description, and CI is green.

| Generated using Claude Code

irfanuddinahmad and others added 2 commits November 10, 2026 12:49
Ports three tests that openedx/openedx-platform#33555 (MathJax v4
upgrade) added to xmodule/js/spec/capa/display_spec.js, which
openedx/openedx-platform#38751 removes along with the built-in Problem
block:

- should clear and typeset the math element
- wraps calculator input in backticks for input.math
- clears preview and skips typesetPromise on empty input

Names, bodies and assertions are unchanged except for the extracted
block's Problem(runtime, element) constructor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pecs

openedx/openedx-platform#33555 added six specs for the built-in block's
client-side refreshMath formula-equation preview, which
openedx/openedx-platform#38751 removes. The extracted block renders these
previews only via the server (preview_formcalc, 989ae32), so add tests
asserting that path's behavior for the same inputs:

- calculator syntax R_1*R_2/R_3 renders as LaTeX
- \(..\), \[..\], $$..$$ and $..$ inputs are rejected with a parse error

The binding spec maps to existing coverage (formula_equation_preview_spec
'makes a request on user input' and display_spec 'does not bind
refreshMath to formula equation inputs').

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/problem-mathjax-v4-specs branch from c3a7928 to e03f244 Compare November 10, 2026 07:54
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). 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.

2 participants