From 5e6bcc417506f00bc3e57bc3008dcf691134427b Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 5 Apr 2023 15:35:25 +0200 Subject: [PATCH 1/3] Fix flaky 'create-space-from-resource'-e2e test --- .../objects/app-files/resource/actions.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 92a60997d7b..65bf4e8cb52 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -13,6 +13,7 @@ const downloadFolderButtonSidedBar = '#oc-files-actions-sidebar .oc-files-actions-download-archive-trigger' const downloadButtonBatchAction = '.oc-files-actions-download-archive-trigger' 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` const checkBoxForTrashbin = `//*[@data-test-resource-path="%s"]//ancestor::tr//input` export const fileRow = @@ -43,6 +44,7 @@ const versionRevertButton = '//*[@data-testid="file-versions-revert-button"]' const actionButton = '//*[contains(@data-testid, "action-handler")]/span[text()="%s"]' const emptyTrashBinButton = '.oc-files-actions-empty-trash-bin-trigger' const notificationMessageDialog = '.oc-notification-message-title' +const notificationMessage = '.oc-notification-message' const permanentDeleteButton = '.oc-files-actions-delete-permanent-trigger' const restoreResourceButton = '.oc-files-actions-restore-trigger' const globalSearchInput = '.oc-search-input' @@ -108,15 +110,14 @@ export const createSpaceFromFolder = async ({ spaceName: string }): Promise => { await page.locator(util.format(resourceNameSelector, folderName)).click({ button: 'right' }) - await page.locator('text=Create Space from selection').first().click() - await page.locator('.oc-text-input').first().fill(spaceName) + await page.locator(createSpaceFromResourceAction).first().click() + await page.locator(resourceNameInput).first().fill(spaceName) await page.locator(util.format(actionConfirmationButton, 'Create')).click() const response = await page.waitForResponse( (resp) => resp.status() === 201 && resp.request().method() === 'POST' && resp.url().endsWith('/drives') ) - await page.waitForSelector('#oc-loading-indicator') - await page.waitForSelector('#oc-loading-indicator', { state: 'detached' }) + await page.waitForSelector(notificationMessage) return (await response.json()) as Space } @@ -136,15 +137,14 @@ export const createSpaceFromSelection = async ({ }) await page.locator(util.format(resourceNameSelector, resources[0])).click({ button: 'right' }) - await page.locator('text=Create Space from selection').first().click() - await page.locator('.oc-text-input').first().fill(spaceName) + await page.locator(createSpaceFromResourceAction).first().click() + await page.locator(resourceNameInput).first().fill(spaceName) await page.locator(util.format(actionConfirmationButton, 'Create')).click() const response = await page.waitForResponse( (resp) => resp.status() === 201 && resp.request().method() === 'POST' && resp.url().endsWith('/drives') ) - await page.waitForSelector('#oc-loading-indicator') - await page.waitForSelector('#oc-loading-indicator', { state: 'detached' }) + await page.waitForSelector(notificationMessage) return (await response.json()) as Space } From b876991d24dc1b6037badc1803b26cc3fecc5925 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 5 Apr 2023 18:19:43 +0200 Subject: [PATCH 2/3] Remove superfluous first()-calls --- .../objects/app-files/resource/actions.ts | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 65bf4e8cb52..57ae6b10b38 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -110,13 +110,18 @@ export const createSpaceFromFolder = async ({ spaceName: string }): Promise => { await page.locator(util.format(resourceNameSelector, folderName)).click({ button: 'right' }) - await page.locator(createSpaceFromResourceAction).first().click() - await page.locator(resourceNameInput).first().fill(spaceName) - await page.locator(util.format(actionConfirmationButton, 'Create')).click() - const response = await page.waitForResponse( - (resp) => - resp.status() === 201 && resp.request().method() === 'POST' && resp.url().endsWith('/drives') - ) + await page.locator(createSpaceFromResourceAction).click() + await page.locator(resourceNameInput).fill(spaceName) + const [response] = await Promise.all([ + page.waitForResponse( + (resp) => + resp.status() === 201 && + resp.request().method() === 'POST' && + resp.url().endsWith('/drives') + ), + page.locator(util.format(actionConfirmationButton, 'Create')).click() + ]) + await page.waitForSelector(notificationMessage) return (await response.json()) as Space } @@ -137,13 +142,17 @@ export const createSpaceFromSelection = async ({ }) await page.locator(util.format(resourceNameSelector, resources[0])).click({ button: 'right' }) - await page.locator(createSpaceFromResourceAction).first().click() - await page.locator(resourceNameInput).first().fill(spaceName) - await page.locator(util.format(actionConfirmationButton, 'Create')).click() - const response = await page.waitForResponse( - (resp) => - resp.status() === 201 && resp.request().method() === 'POST' && resp.url().endsWith('/drives') - ) + await page.locator(createSpaceFromResourceAction).click() + await page.locator(resourceNameInput).fill(spaceName) + const [response] = await Promise.all([ + page.waitForResponse( + (resp) => + resp.status() === 201 && + resp.request().method() === 'POST' && + resp.url().endsWith('/drives') + ), + page.locator(util.format(actionConfirmationButton, 'Create')).click() + ]) await page.waitForSelector(notificationMessage) return (await response.json()) as Space } From dbccf35c8fc55a2645ba82543afc6cde86ab48e5 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 12 Apr 2023 08:47:26 +0200 Subject: [PATCH 3/3] Enable e2e tests for space-shortcut-action --- .../createSpaceFromSelection.ocis.feature | 113 +++++++++--------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/createSpaceFromSelection.ocis.feature b/tests/e2e/cucumber/features/smoke/createSpaceFromSelection.ocis.feature index cda434c373c..7426c9cdbba 100644 --- a/tests/e2e/cucumber/features/smoke/createSpaceFromSelection.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/createSpaceFromSelection.ocis.feature @@ -1,58 +1,57 @@ Feature: create Space shortcut -# -# FIXME: skipped because of oCIS pipeline, un-skip and check if https://github.com/owncloud/web/pull/8781 solves the issue -# Scenario: create Space from folder -# Given "Admin" creates following users using API -# | id | -# | Alice | -# And "Admin" assigns following roles to the users using API -# | id | role | -# | Alice | Space Admin | -# And "Alice" creates the following folder in personal space using API -# | name | -# | spaceFolder | -# | spaceFolder/test | -# When "Alice" logs in -# And "Alice" navigates to the personal space page -# And "Alice" uploads the following resources -# | resource | to | -# | data.zip | spaceFolder | -# | lorem.txt | spaceFolder | -# And "Alice" navigates to the personal space page -# And "Alice" creates space "folderSpace" from folder "spaceFolder" using the context menu -# And "Alice" navigates to the projects space page -# And "Alice" navigates to the project space "folderSpace" -# Then following resources should be displayed in the files list for user "Alice" -# | resource | -# | data.zip | -# | lorem.txt | -# And "Alice" logs out -# -# Scenario: create space from resources -# Given "Admin" creates following users using API -# | id | -# | Alice | -# And "Admin" assigns following roles to the users using API -# | id | role | -# | Alice | Space Admin | -# And "Alice" creates the following folder in personal space using API -# | name | -# | resourceFolder | -# When "Alice" logs in -# And "Alice" navigates to the personal space page -# And "Alice" uploads the following resources -# | resource | to | -# | data.zip | resourceFolder | -# | lorem.txt | | -# And "Alice" navigates to the personal space page -# And "Alice" creates space "resourceSpace" from resources using the context menu -# | resource | -# | resourceFolder | -# | lorem.txt | -# And "Alice" navigates to the projects space page -# And "Alice" navigates to the project space "resourceSpace" -# Then following resources should be displayed in the files list for user "Alice" -# | resource | -# | resourceFolder | -# | lorem.txt | -# And "Alice" logs out + + Scenario: create Space from folder + Given "Admin" creates following users using API + | id | + | Alice | + And "Admin" assigns following roles to the users using API + | id | role | + | Alice | Space Admin | + And "Alice" creates the following folder in personal space using API + | name | + | spaceFolder | + | spaceFolder/test | + When "Alice" logs in + And "Alice" navigates to the personal space page + And "Alice" uploads the following resources + | resource | to | + | data.zip | spaceFolder | + | lorem.txt | spaceFolder | + And "Alice" navigates to the personal space page + And "Alice" creates space "folderSpace" from folder "spaceFolder" using the context menu + And "Alice" navigates to the projects space page + And "Alice" navigates to the project space "folderSpace" + Then following resources should be displayed in the files list for user "Alice" + | resource | + | data.zip | + | lorem.txt | + And "Alice" logs out + + Scenario: create space from resources + Given "Admin" creates following users using API + | id | + | Alice | + And "Admin" assigns following roles to the users using API + | id | role | + | Alice | Space Admin | + And "Alice" creates the following folder in personal space using API + | name | + | resourceFolder | + When "Alice" logs in + And "Alice" navigates to the personal space page + And "Alice" uploads the following resources + | resource | to | + | data.zip | resourceFolder | + | lorem.txt | | + And "Alice" navigates to the personal space page + And "Alice" creates space "resourceSpace" from resources using the context menu + | resource | + | resourceFolder | + | lorem.txt | + And "Alice" navigates to the projects space page + And "Alice" navigates to the project space "resourceSpace" + Then following resources should be displayed in the files list for user "Alice" + | resource | + | resourceFolder | + | lorem.txt | + And "Alice" logs out