Skip to content

Return and handle promises in tests #5340

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 42 commits into from
Jan 4, 2021
Merged

Return and handle promises in tests #5340

merged 42 commits into from
Jan 4, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Dec 11, 2020

In respect to #5336 (comment).

As a result of this PR we could now drop most of the noCI flags and run mapbox and parcoords tests on the CI.
The number of auto retry is also reduced from 5 to 1.

@alexcjohnson @antoinerg
cc: @plotly/plotly_js

@alexcjohnson
Copy link
Collaborator

Whew, there's a lot here! I don't mind us updating these tests to support the possibility that these operations may become async in the future, it is the usage we want to promote for our users. But I don't see it as particularly high priority, and for the vast majority of these tests if the operation did become async the test would simply fail and could be addressed at that time.

The cases I'd be worried about are when we're testing that something didn't happen, like:

Plotly.newPlot(gd, someFigureThatPreviouslyHadABug);
expect(Loggers.error).not.toHaveBeenCalled();

In that case, if the bug were to return but the plot became async, the test would still pass because the error would be thrown after we checked. But as long as we're also testing that something did change as a result of the operation, the test will fail as soon as the operation becomes async and we'll be alerted to fix it then.

@archmoj archmoj force-pushed the ensure-return-promise branch from 4a5cc96 to f023347 Compare December 21, 2020 20:06
@archmoj archmoj force-pushed the ensure-return-promise branch from f023347 to 5769cde Compare December 21, 2020 20:38
'translate(0,' + -dataScroll + ')');
expect(scrollBar.getAttribute('width')).toBeGreaterThan(0);
expect(scrollBar.getAttribute('height')).toBeGreaterThan(0);
done();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this wants the new Promise / resolve pattern you used a few other places. Also there's a second Plotly.relayout above that should get its own async step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attempt addressing in 3a313e7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.. after that change the tests started failing. So I revert the changes to this test in 5a127f0 but we may come back to improve those in a separate PR.

Plotly.plot(gd, reversedMockCopy).then(function() {
Plotly.react(gd, mockCopy)
.then(function() {
return Plotly.plot(gd, reversedMockCopy);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should get rid of Plotly.plot in v2 - Etienne liked to use it in tests instead of newPlot when we know the div we're plotting into is new, as it saves some time purging previous items, esp. gl contexts IIRC. But if it's used like this on a div that already has a plot the effects are extremely confusing, and I don't think we've had a legitimate use of this behavior (appending its traces to the existing graph) for a long long time.

Copy link
Contributor

Choose a reason for hiding this comment

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

do you think this is something we could just do or do we need to make more noise about it being deprecated somehow?

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: it looks like we have zero instances of Plotly.plot() in our current docs, so that suggests we could just drop it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep - Plotly.plot behaves exactly like Plotly.newPlot except when it does confusing things that are much better done with Plotly.react. Thanks for verifying that we don't use it in our docs!

'yaxis.title': 'Y',
'polar.radialaxis.title': 'Radial'
});
done();
Copy link
Collaborator

Choose a reason for hiding this comment

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

also may be better with the new Promise / resolve pattern.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃

@archmoj archmoj merged commit 446123c into master Jan 4, 2021
@archmoj archmoj deleted the ensure-return-promise branch January 4, 2021 21:02
@archmoj archmoj added this to the 1.59.0 milestone Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants