-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
Reset scroll state on render #732
base: master
Are you sure you want to change the base?
Conversation
is it possible to rerun the test? yarn is throwing Segmentation fault for some reason. |
restarted |
@@ -144,6 +144,8 @@ export function render(template: TemplateFactory): Promise<void> { | |||
}; | |||
toplevelView.setOutletState(outletState); | |||
|
|||
resetScrollState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the correct place to call this. It would still have the same issue if a rendering test scrolls somewhere and then an application test follows that relies on the scroll position. Should we call this in "afterEach()
" instead? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand that issue. Please help me understand your thoughts on the recommendation for afterEach()
.
Are you suggestion that perhaps resetScrollState()
should be a helper and then it'd be at the discretion of the user to call it in the afterEach hook whenever scroll state needs to be guaranteed? That way it will work regardless if it is an acceptance test or an integration test.
setupRenderingTest(hooks);
//OR
//setupApplicationTest(hooks);
hooks.afterEach(async function() {
await resetScrollState()
});
test('it renders', async function(assert) {
await render(hbs`<MyComponent />`);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm. But even that wouldn't solve the issue is there were two renders in a single component test.
await render(hbs`
await render(hbs`<MyComponent />`);
`);
clearRender();
await render(hbs`
<div>SomethingElse</div>
`);
So maybe it has to be in either render()
or clearRender()
for integration tests as well as used in afterEach
for acceptance tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But even that wouldn't solve the issue is there were two renders in a single component test.
FWIW, I think this is pretty rare.
We can add logic to teardownContext
and clearRender
to reset the scroll state, that would work for both rendering and application tests as well as using render
twice...
👋🏻 Is this likely to get in? It's just started to affect me... Scenario: Testing dragging and dropping something. The test that is run before the drag and drop test (depending on test order with Ember Exam) may have scrolled |
hello! sorry for not looking at this PR sooner -- would you be willing to rebase? |
Ensures
div#ember-testing-container
scrollTop and scrollLeft are zero on render.Fixes #729, where scrolling during testA will persist container scroll position to testB and thus make the tests brittle.
+Adds ember-qunit CSS so we can properly test the container.
Feedback/Changes welcome!