Skip to content

Test mathjax #1991

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
Sep 6, 2017
Merged

Test mathjax #1991

merged 2 commits into from
Sep 6, 2017

Conversation

alexcjohnson
Copy link
Collaborator

  • Tests the current state of our MathJax rendering, including a "visual TODO list" of things that we would like to support but currently either do not or they are actively broken ($ is replaced by H in the mock where it wouldn't work correctly)
  • Fixes a bug with our Plotly.plot promise chain that meant multiple MathJax items in different parts of the plot would render but the plot would report being done before it really had finished. Prior to this change, the mock fails.

cc @etpinard - hopefully this will fix our MathJax image export issues.

@@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) {
// any part of the plotting code can push to gd._promises, then
// before we move to the next step, we check that they're all
// complete, and empty out the promise list again.
gd._promises = [];
if(!Array.isArray(gd._promises)) gd._promises = [];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This I didn't write a test for... but I made this change so that if you make a plot, then change it before its promises have finished, you should still wait for them (via previousPromises) so you don't get a race condition between them and the new plot (with the old ones potentially overwriting elements of the new plot you made).

I haven't actually managed to cause any ill effects without this change in manual testing, but I think it's safer this way.

// even if everything we did was synchronous, return a promise
// so that the caller doesn't care which route we took
return Promise.all(gd._promises).then(function() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the crux of the issue: if you have more than one async item in seq, only the promises added to gd._promises by the first one will exist when this Promise.all is called (at the synchronous return of Lib.syncOrAsync), so any added after that will not be awaited. But Plots.previousPromises (added to the end of seq above) looks at gd._promises when it's actually invoked so it gets them all.

Copy link
Contributor

Choose a reason for hiding this comment

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

Solid investigation work 🔬 🎉 🥇

Is this enough to close #76 you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this enough to close #76 you think?

I think so!

@etpinard etpinard added status: reviewable bug something broken labels Sep 6, 2017
@etpinard
Copy link
Contributor

etpinard commented Sep 6, 2017

I tested this locally using the old (i.e. current aka imagetest) image server and I didn't detect any flakiness. The new image-exporter is working beautifully too.

To make sure (sure), I'll manually rebuild this branch on CI a few times.

@etpinard
Copy link
Contributor

etpinard commented Sep 6, 2017

Moreover, I'm thinking that we could start testing MathJax using jasmine in a separate bundle_tests/ suite. The MathJax <script> could be added here.

@alexcjohnson
Copy link
Collaborator Author

To make sure (sure), I'll manually rebuild this branch on CI a few times.

One unrelated error, but the mathjax part succeeded 4/4 times on circle and all the times we've done it locally - looks pretty solid to me, ready to go?

@etpinard
Copy link
Contributor

etpinard commented Sep 6, 2017

4/4 times

I want 5/5; so one more run -> https://circleci.com/gh/plotly/plotly.js/4955

@etpinard
Copy link
Contributor

etpinard commented Sep 6, 2017

It's green ✅

💃 💃 💃

@alexcjohnson alexcjohnson merged commit 832a4f8 into master Sep 6, 2017
@alexcjohnson alexcjohnson deleted the test-mathjax branch September 6, 2017 22:28
@etpinard etpinard added this to the v1.31.0 milestone Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants