From 40d0b52a8783d7e729fe0f66434a4a084cfeae12 Mon Sep 17 00:00:00 2001 From: Sawjan Gurung Date: Fri, 2 Feb 2024 10:12:23 +0545 Subject: [PATCH] move upload file exceeding quota test to e2e (#10428) --- ...ed-failures-with-ocis-server-ocis-storage.md | 3 --- .../uploadFileGreaterThanQuotaSize.feature | 16 ---------------- .../e2e/cucumber/features/smoke/upload.feature | 9 ++++++++- tests/e2e/cucumber/steps/ui/resources.ts | 15 +++++++++++++++ .../objects/app-admin-settings/users/actions.ts | 4 ++-- .../objects/app-files/resource/actions.ts | 17 ++++++++++++++++- .../support/objects/app-files/resource/index.ts | 6 ++++++ 7 files changed, 47 insertions(+), 23 deletions(-) delete mode 100644 tests/acceptance/features/webUIUpload/uploadFileGreaterThanQuotaSize.feature diff --git a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md index 69c0010cf10..9b679d44f44 100644 --- a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md +++ b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md @@ -18,9 +18,6 @@ Other free text and markdown formatting can be used elsewhere in the document if ### [Different path for shares inside folder](https://github.com/owncloud/ocis/issues/1231) -### [Conflict / overwrite issues with TUS](https://github.com/owncloud/ocis/issues/1294) -- [webUIUpload/uploadFileGreaterThanQuotaSize.feature:11](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIUpload/uploadFileGreaterThanQuotaSize.feature#L11) - ### [restoring a file deleted from a received shared folder is not possible](https://github.com/owncloud/ocis/issues/1124) - [webUITrashbinRestore/trashbinRestore.feature:176](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature#L176) diff --git a/tests/acceptance/features/webUIUpload/uploadFileGreaterThanQuotaSize.feature b/tests/acceptance/features/webUIUpload/uploadFileGreaterThanQuotaSize.feature deleted file mode 100644 index 9b40456c11c..00000000000 --- a/tests/acceptance/features/webUIUpload/uploadFileGreaterThanQuotaSize.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Upload a file - - As a user - I would like to upload a file - So that I can store it in owncloud - - Background: - Given user "Alice" has been created with default attributes and without skeleton files in the server - - @smokeTest @issue-1049 - Scenario: simple upload of a file with the size greater than the size of quota - Given the quota of user "Alice" has been set to "10 MB" in the server - And user "Alice" has logged in using the webUI - And a file with the size of "30000000" bytes and the name "big-video.mp4" has been created locally in the middleware - When the user uploads a created file "big-video.mp4" using the webUI - Then file "big-video.mp4" should not be listed on the webUI diff --git a/tests/e2e/cucumber/features/smoke/upload.feature b/tests/e2e/cucumber/features/smoke/upload.feature index 3349c18dd0f..5d54bae5ce9 100644 --- a/tests/e2e/cucumber/features/smoke/upload.feature +++ b/tests/e2e/cucumber/features/smoke/upload.feature @@ -4,10 +4,14 @@ Feature: Upload So that I can store them in owncloud Background: - Given "Admin" creates following user using API + Given "Admin" logs in + And "Admin" creates following user using API | id | | Alice | And "Alice" logs in + And "Admin" opens the "admin-settings" app + And "Admin" navigates to the users management page + When "Admin" changes the quota of the user "Alice" to "0.00001" using the sidebar panel And "Alice" opens the "files" app @@ -30,6 +34,9 @@ Feature: Upload | resource | | simple.pdf | | testavatar.jpg | + And "Alice" tries to upload the following resource + | resource | error | + | lorem-big.txt | Not enough quota | # currently upload folder feature is not available in playwright # And "Alice" uploads the following resources # | resource | diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index 62b66a09af7..fbde77b1853 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -46,6 +46,21 @@ When( } ) +When( + '{string} tries to upload the following resource', + async function (this: World, stepUser: string, stepTable: DataTable): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const resourceObject = new objects.applicationFiles.Resource({ page }) + for (const info of stepTable.hashes()) { + await resourceObject.tryToUpload({ + to: info.to, + resources: [this.filesEnvironment.getFile({ name: info.resource })], + error: info.error + }) + } + } +) + When( '{string} starts uploading the following large resource(s) from the temp upload directory', async function (this: World, stepUser: string, stepTable: DataTable): Promise { diff --git a/tests/e2e/support/objects/app-admin-settings/users/actions.ts b/tests/e2e/support/objects/app-admin-settings/users/actions.ts index e7df3b35127..26a6a73d683 100644 --- a/tests/e2e/support/objects/app-admin-settings/users/actions.ts +++ b/tests/e2e/support/objects/app-admin-settings/users/actions.ts @@ -22,7 +22,7 @@ const userFilter = '.item-filter-%s' const userFilterOption = '//ul[contains(@class, "item-filter-list")]//button[@data-test-value="%s"]' const usersTable = '.users-table' const quotaInput = '#quota-select-form .vs__search' -const quotaValueDropDown = `.vs__dropdown-option :text-is("%s")` +const quotaValueDropDown = 'ul.vs__dropdown-menu' const userCheckboxSelector = `[data-item-id="%s"] input[type=checkbox]` const editQuotaBtn = '.oc-users-actions-edit-quota-trigger' const quotaInputBatchAction = '#quota-select-batch-action-form .vs__search' @@ -102,7 +102,7 @@ export const changeQuota = async (args: { }): Promise => { const { page, value, uuid } = args await page.locator(quotaInput).pressSequentially(value) - await page.locator(util.format(quotaValueDropDown, `${value} GB`)).click() + await page.locator(quotaValueDropDown).first().click() await Promise.all([ page.waitForResponse( diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 836123dd12c..3bf22ad4149 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -40,6 +40,7 @@ const resourceNameInput = '.oc-modal input' const resourceUploadButton = '#upload-menu-btn' const fileUploadInput = '#files-file-upload-input' const uploadInfoCloseButton = '#close-upload-info-btn' +const uploadErrorCloseButton = '.oc-notification-message-danger button[aria-label="Close"]' const filesBatchAction = '.files-app-bar-actions .oc-files-actions-%s-trigger' const pasteButton = '.paste-files-btn' const breadcrumbRoot = '//nav[contains(@class, "oc-breadcrumb")]/ol/li[1]' @@ -450,10 +451,12 @@ export interface uploadResourceArgs { resources: File[] to?: string option?: string + error?: string + expectToFail?: boolean } const performUpload = async (args: uploadResourceArgs): Promise => { - const { page, resources, to, option } = args + const { page, resources, to, option, error, expectToFail } = args if (to) { await clickResource({ page, path: to }) } @@ -483,6 +486,12 @@ const performUpload = async (args: uploadResourceArgs): Promise => { } } } + + if (expectToFail) { + expect(await page.locator(notificationMessageDialog).textContent()).toBe(error) + return + } + await Promise.all([ page.waitForResponse( (resp) => @@ -517,6 +526,12 @@ export const uploadResource = async (args: uploadResourceArgs): Promise => }) } +export const tryToUploadResource = async (args: uploadResourceArgs): Promise => { + const { page } = args + await performUpload({ ...args, expectToFail: true }) + await page.locator(uploadErrorCloseButton).click() +} + export const dropUploadFiles = async (args: uploadResourceArgs): Promise => { const { page, resources } = args diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index b0f29c4bc1c..dfb17427c1c 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -22,6 +22,12 @@ export class Resource { await this.#page.goto(startUrl) } + async tryToUpload(args: Omit): Promise { + const startUrl = this.#page.url() + await po.tryToUploadResource({ ...args, page: this.#page }) + await this.#page.goto(startUrl) + } + async uploadLargeNumberOfResources(args: Omit): Promise { const startUrl = this.#page.url() await po.uploadLargeNumberOfResources({ ...args, page: this.#page })