web icon indicating copy to clipboard operation
web copied to clipboard

Write smoke tests for drag&drop upload

Open pascalwengerter opened this issue 4 years ago • 7 comments

Current state

We support uploads via drag&drop, but don't have them covered in our test suite

Acceptance criteria

Write two smoke tests

  • [x] upload file via drag&drop and assert that it
    • [x] is visible on the web UI https://github.com/owncloud/web/pull/9065
    • [x] arrives in the backend https://github.com/owncloud/web/pull/9065
  • [ ] upload a folder (containing files & folders) via drag&drop and assert that it - still relevant. We cannot use solution from #9065 because Error: EISDIR: illegal operation on a directory, read
    • [ ] is visible on the web UI
    • [ ] arrives in the backend

pascalwengerter avatar Nov 23 '21 15:11 pascalwengerter

For information, in oC10 we "simulate":

  • drag-and-drop of a file/folder from outside the browser
  • selection of a file/folder to upload (that would actually open some file explorer interface to browse to the file to upload).
  • drag-and-drop of a file/folder from its source in the browser into another folder

When the user uploads file "new-lorem.txt" using the webUI ends up calling https://github.com/owncloud/core/blob/master/tests/acceptance/features/lib/FilesPageCRUD.php uploadFile

That calls:

$uploadField->attachFile(UploadHelper::getUploadFilesDir($name));

attachFile() is a method in Behat-Mink that interfaces through selenium to the browser and "knows" how to insert a file reference into a file-input field. The actual user "motion" of drag-and-drop or browsing the file system outside of the browser does not happen. But after the file-input field is filled, the browser responds and does the action to the server to do the upload.

moveFileTo() uses a dragTo() method provided by Behat-Mink to selenium and the browser that "simulates" dragging a UI element (e.g. a file) onto another UI element (e.g. a folder). That achieves drag-and-drop between elements that are already visible in the browser tab.

Maybe Playwright and/or Nightwatch will have similar abstractions available.

phil-davis avatar Nov 24 '21 09:11 phil-davis

@ScharfViktor seems like the Playwright team received a feature request for that functionality recently: https://github.com/microsoft/playwright/issues/9823 Perhaps best to wait a bit until they fully support it?

pascalwengerter avatar Nov 24 '21 09:11 pascalwengerter

@pascalwengerter this is very similar to our case, we should wait. it would be great to use the custom method Today I tried how the "page.dragAndDrop" method works. It works within a single page and is suitable for "Move" and "Copy". But it doesn't suit uploading a file or folder

ScharfViktor avatar Nov 24 '21 17:11 ScharfViktor

drag'n'drop folder uploads still don't seem to be supported in playwright, see https://github.com/microsoft/playwright/issues/6854 (old issue was closed due to inactivity)

kulmann avatar Jun 04 '24 04:06 kulmann

Reached a dead-end. Could not find a working solution for uploading Folder via drag-n-drop event. For Files upload, we do have some tests.

saw-jan avatar Aug 06 '24 09:08 saw-jan

@saw-jan "Could find a working solution" Do you mean "could not"?

phil-davis avatar Aug 06 '24 09:08 phil-davis

Do you mean "could not"?

yeah, updated the comment :sweat_smile:

saw-jan avatar Aug 06 '24 09:08 saw-jan

Reached a dead-end. Could not find a working solution for uploading Folder via drag-n-drop event. For Files upload, we do have some tests.

Test for folder upload added in https://github.com/owncloud/web/pull/12540

saw-jan avatar May 06 '25 12:05 saw-jan