-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib: add drag events helper function #21296
Conversation
This enables to simulate drag events and allows to test drag&drop file upload in c-files in cockpit-project/cockpit-files#551
You need to add that to tools/vulture_suppressions/testlib.py. Note that you can add a temporary extra commit to the files PR to point the COCKPIT_REPO_COMMIT to this SHA, to prove that it works. |
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.
My recommendation is that this is currently too specific to be in testlib (hardcoded file contents, we don't want that approach for non-files DnD). How about for now you just keep this in that one c-files test case with b.eval_js()
?
Thanks!
@@ -194,6 +194,33 @@ window.ph_mouse = function(sel, type, x, y, btn, ctrlKey, shiftKey, altKey, meta | |||
throw new Error(sel + " is disabled or somehow doesn't process events"); | |||
}; | |||
|
|||
window.ph_drag_event = function(sel, eventType, filename) { |
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.
Please rename that to drag_file_event() -- it is (or rather, should be) specific to dnd'ing files, not e.g. an object from/to within the page.
if (el.offsetWidth <= 0 && el.offsetHeight <= 0 && el.tagName != 'svg') | ||
throw new Error(sel + " is not visible"); |
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.
Please call ph_is_visible()
. But moreover, don't call this at all here. testlib.py already calls wait_visible()
on the selector, so this is redundant.
""" | ||
|
||
self.wait_visible(selector) | ||
return self.call_js_func('ph_drag_event', selector, dragType, filename) |
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.
We really shouldn't use this "create direct Event objects" approach for generic DnD events. We found a lot of bugs when we moved Firefox tests to actual mouse clicks/moves/etc. I understand why we need it for that specific "file DnD" use case, though.
yes I think this makes a lot of sense. |
This enables to simulate drag events and allows to test drag&drop file upload in c-files in cockpit-project/cockpit-files#551