-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Widget resize tests #3620
Widget resize tests #3620
Conversation
db959a9
to
7e4a821
Compare
d708729
to
689e1a6
Compare
gridstack-item="widget.options.position" gridstack-item-id="{{ widget.id }}"> | ||
<div class="grid-stack-item-content" data-test="WidgetId{{ widget.id }}"> | ||
gridstack-item="widget.options.position" gridstack-item-id="{{ widget.id }}" data-test="WidgetId{{ widget.id }}"> | ||
<div class="grid-stack-item-content"> |
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.
Moved to parent node in order to locate the handle (which is a sibling)
wip - I'm adding another resize related test |
Added 2 tests for auto height cause resizing disables it. |
@gabrieldutra this is ready for review |
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.
Not that different from the Drag tests 😁. Left some comments :)
cy.get('@refreshButton').click(); | ||
cy.wait('@FreshResults'); | ||
|
||
// expect height to stay unchanged (would have been 435) |
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.
Just to show a different way to assert the same thing:
expect(() => {
// add 4 table rows
cy.get('@paramInput').clear().type('5');
cy.get('@refreshButton').click();
cy.wait('@FreshResults');
}).not.to.change(this.widget, 'height');
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.
Oooh that's nice.
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 I don't think this specifically would work cause
height
is a method, not a property.this.widget
is a cy object, not jquery.
Right?
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.
Ideally the dragBy
and resizeBy
functions would not return a delta value but instead:
it('moves one column', () => {
const getLeft = () => $el.offset().left;
const drag = () => dragBy($el, 200);
expect(drag).to.increase(getLeft).by(200);
});
Then resizeBy
would simply be a dragBy
of the element's handle. So nice.
BUT, disconnecting the drag from the delta calculation is currently problematic since the dragged element animates to its new position on mouseup (compensated by calculating the drag placeholder position instead).
Any workaround suggestion? (wait for animation end, disable animation for test, ...)
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.
Really cool, once I get to my laptop I'll run a few tests with it. For the questions:
But I don't think this specifically would work cause
It worked for success, need to try on failure haha. The assertion is essentially the same, they just run it before the function and then guarantee it's the same after.
height is a method, not a property
I hope not to have seen the above wrongly, but this is not supposed to be a problem
this.widget is a cy object, not jquery.
Need to confirm, but I think it is a jQuery object, when I saw it in docs it seemed the same as getting the result of cy.get('@widget')
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.
If you can make it work that would be awesome 👍
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 could not 😅. That works well with javascript objects, not with elements (I could use a helper object to represent the element, but I don't think it is worth it for my example).
Yours is much better, it would make tests a lot more readable.
Any workaround suggestion?
Can we use the placeholder position for the getLeft
method? If not, NP, we can move on.
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.
Can we use the placeholder position for the getLeft method? If not, NP, we can move on.
It doesn't get rendered in the dom until mousedown (or mousemove, I didn't check) so it's not ideal.
Co-Authored-By: ranbena <ranbena@gmail.com>
Co-Authored-By: ranbena <ranbena@gmail.com>
Co-Authored-By: ranbena <ranbena@gmail.com>
Co-Authored-By: ranbena <ranbena@gmail.com>
Co-Authored-By: ranbena <ranbena@gmail.com>
Co-Authored-By: ranbena <ranbena@gmail.com>
What type of PR is this? (check all applicable)
Description