Skip to content

Commit

Permalink
[test-only]download image file from editor (#10637)
Browse files Browse the repository at this point in the history
* download image file from editor

* Update download.feature
  • Loading branch information
ScharfViktor committed Mar 27, 2024
1 parent ce89bfd commit d2490f3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 29 deletions.
24 changes: 0 additions & 24 deletions tests/acceptance/features/webUIPreview/mediaPreview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,6 @@ Feature: display image in preview app on the webUI
| testavatar.jpg | testavatar.png |


Scenario: downloading media resource is possible
Given user "Alice" has uploaded file "testavatar.jpg" to "testavatar.jpg" in the server
And user "Alice" has logged in using the webUI
And the user has viewed the file "testavatar.jpg" in the preview app using the webUI
When the user downloads the media resource using the webUI
Then no message should be displayed on the webUI


Scenario: closing preview app is possible
Given user "Alice" has uploaded file "testavatar.jpg" to "testavatar.jpg" in the server
And user "Alice" has logged in using the webUI
And the user has viewed the file "testavatar.jpg" in the preview app using the webUI
When the user closes the media resource using the webUI
Then the file "testavatar.jpg" should not be displayed in the preview app webUI
And the user should be in the root directory on the webUI


Scenario: preview of image with preview app by clicking on the file name
Given user "Alice" has uploaded file "testavatar.jpg" to "testavatar.jpg" in the server
And user "Alice" has logged in using the webUI
When the user views the file "testavatar.jpg" in the preview app by clicking on the file name using the webUI
Then the file "testavatar.jpg" should be displayed in the preview app webUI


Scenario: preview of mp3 file with preview app by clicking on the file name
Given user "Alice" has uploaded file "testimage.mp3" to "testimage.mp3" in the server
And user "Alice" has logged in using the webUI
Expand Down
4 changes: 0 additions & 4 deletions tests/e2e/cucumber/features/shares/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ Feature: link
And "Anonymous" drop uploads following resources
| resource |
| textfile.txt |
When "Alice" downloads the following resources using the batch action
| resource | from | type |
| lorem.txt | folderPublic | file |
| textfile.txt | folderPublic | file |
And "Alice" edits the public link named "myPublicLink" of resource "folderPublic" changing role to "Can edit"
And "Anonymous" refreshes the old link
And "Anonymous" downloads the following public link resources using the sidebar panel
Expand Down
65 changes: 65 additions & 0 deletions tests/e2e/cucumber/features/smoke/download.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Feature: Download
As a user
I want to download resources


Background:
Given "Admin" creates following user using API
| id |
| Alice |
| Brian |


Scenario: download resources
When "Alice" logs in
And "Alice" creates the following folders in personal space using API
| name |
| folderPublic |
| emptyFolder |
And "Alice" creates the following files into personal space using API
| pathToFile | content |
| folderPublic/lorem.txt | lorem ipsum |
And "Alice" uploads the following local file into personal space using API
| localFile | to |
| filesForUpload/testavatar.jpg | testavatar.jpg |
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| folderPublic | Brian | user | Can edit |
| emptyFolder | Brian | user | Can edit |
| testavatar.jpg | Brian | user | Can edit |

When "Alice" opens the "files" app
And "Alice" downloads the following resources using the batch action
| resource | type |
| folderPublic | folder |
| emptyFolder | folder |
| testavatar.jpg | file |
And "Alice" opens the following file in mediaviewer
| resource |
| testavatar.jpg |
And "Alice" downloads the following image from the mediaviewer
| resource |
| testavatar.jpg |
And "Alice" closes the file viewer
And "Alice" logs out

And "Brian" logs in
And "Brian" navigates to the shared with me page
And "Brian" downloads the following resources using the batch action
| resource | type |
| folderPublic | folder |
| emptyFolder | folder |
| testavatar.jpg | file |
And "Brian" downloads the following resources using the sidebar panel
| resource | from | type |
| lorem.txt | folderPublic | file |
| testavatar.jpg | | file |
| folderPublic | | folder |
| emptyFolder | | folder |
And "Brian" opens the following file in mediaviewer
| resource |
| testavatar.jpg |
And "Brian" downloads the following image from the mediaviewer
| resource |
| testavatar.jpg |
And "Brian" logs out
12 changes: 12 additions & 0 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ When(
}
)

When(
/^"([^"]*)" downloads the following image(?:s)? from the mediaviewer$/,
async function (this: World, stepUser: string, stepTable: DataTable) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await processDownload(stepTable, resourceObject, 'preview')
}
)

When(
/^"([^"]*)" deletes the following resource(?:s)? using the (sidebar panel|batch action)$/,
async function (this: World, stepUser: string, actionType: string, stepTable: DataTable) {
Expand Down Expand Up @@ -461,6 +470,9 @@ export const processDownload = async (
case 'sidebar panel':
via = 'SIDEBAR_PANEL'
break
case 'preview':
via = 'PREVIEW'
break
default:
break
}
Expand Down
11 changes: 10 additions & 1 deletion tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const downloadFileButtonSideBar =
const downloadFolderButtonSideBar =
'#oc-files-actions-sidebar .oc-files-actions-download-archive-trigger'
const downloadButtonBatchAction = '.oc-files-actions-download-archive-trigger'
const downloadPreviewButton = '#preview-download'
const deleteButtonBatchAction = '.oc-files-actions-delete-trigger'
const createSpaceFromResourceAction = '.oc-files-actions-create-space-from-resource-trigger'
const checkBox = `//*[@data-test-resource-name="%s"]//ancestor::tr//input`
Expand Down Expand Up @@ -620,7 +621,7 @@ interface resourceArgs {
type?: string
}

export type ActionViaType = 'SIDEBAR_PANEL' | 'BATCH_ACTION' | 'SINGLE_SHARE_VIEW'
export type ActionViaType = 'SIDEBAR_PANEL' | 'BATCH_ACTION' | 'SINGLE_SHARE_VIEW' | 'PREVIEW'

export interface downloadResourcesArgs {
page: Page
Expand Down Expand Up @@ -686,6 +687,14 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
}
break
}
case 'PREVIEW': {
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadPreviewButton).click()
])
downloads.push(download)
break
}
}

return downloads
Expand Down

0 comments on commit d2490f3

Please sign in to comment.