From fdf46b0b33e47066e94e9433ec9092dc45a97d1b Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 29 Aug 2022 17:20:17 +0200 Subject: [PATCH] add step sharing with group lint fix fix run reshare test in oc10 --- .../{reshare.ocis.feature => reshare.feature} | 21 +++++++--------- .../features/integrations/share.oc10.feature | 8 +++---- .../features/integrations/share.ocis.feature | 4 ++-- .../integrations/spaces/project.ocis.feature | 4 ++-- .../journeys/kindergarten.oc10.feature | 6 ++--- .../journeys/kindergarten.ocis.feature | 6 ++--- .../steps/app-files/page/spaces/projects.ts | 2 +- tests/e2e/cucumber/steps/app-files/share.ts | 24 ++++++++++++------- .../objects/app-files/share/actions.ts | 22 ++++++++--------- .../objects/app-files/spaces/actions.ts | 4 ++-- 10 files changed, 53 insertions(+), 48 deletions(-) rename tests/e2e/cucumber/features/integrations/{reshare.ocis.feature => reshare.feature} (79%) diff --git a/tests/e2e/cucumber/features/integrations/reshare.ocis.feature b/tests/e2e/cucumber/features/integrations/reshare.feature similarity index 79% rename from tests/e2e/cucumber/features/integrations/reshare.ocis.feature rename to tests/e2e/cucumber/features/integrations/reshare.feature index fda28ed5572..3b323d35808 100644 --- a/tests/e2e/cucumber/features/integrations/reshare.ocis.feature +++ b/tests/e2e/cucumber/features/integrations/reshare.feature @@ -16,7 +16,7 @@ Feature: reshare And "Admin" adds user to the group | user | group | | Carol | sales | - + And "Alice" logs in And "Alice" opens the "files" app And "Alice" navigates to the personal space page @@ -24,10 +24,10 @@ Feature: reshare | resource | type | | folder_to_shared | folder | When "Alice" shares the following resource using the sidebar panel - | resource | user | role | - | folder_to_shared | Brian | editor | + | resource | recipient | type | role | + | folder_to_shared | Brian | user | editor | And "Alice" logs out - + And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page @@ -35,10 +35,10 @@ Feature: reshare | name | | folder_to_shared | And "Brian" reshares the following resource - | resource | user | role | - | folder_to_shared | Carol | viewer | + | resource | recipient | type | role | + | folder_to_shared | sales | group | viewer | And "Brian" logs out - + And "Carol" logs in And "Carol" opens the "files" app And "Carol" navigates to the shared with me page @@ -46,9 +46,6 @@ Feature: reshare | name | | folder_to_shared | And "Carol" reshares the following resource - | resource | user | role | - | folder_to_shared | Alice | viewer | + | resource | recipient | type | role | + | folder_to_shared | Alice | user | viewer | And "Carol" logs out - - - diff --git a/tests/e2e/cucumber/features/integrations/share.oc10.feature b/tests/e2e/cucumber/features/integrations/share.oc10.feature index 5df75508e2f..d51d3279d83 100644 --- a/tests/e2e/cucumber/features/integrations/share.oc10.feature +++ b/tests/e2e/cucumber/features/integrations/share.oc10.feature @@ -21,8 +21,8 @@ Feature: share #Then "Alice" should see the following resource # | folder_to_shared/lorem.txt | When "Alice" shares the following resource using the sidebar panel - | resource | user | role | - | folder_to_shared | Brian | editor | + | resource | recipient | type | role | + | folder_to_shared | Brian | user | editor | And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page @@ -78,8 +78,8 @@ Feature: share | resource | to | | testavatar.jpeg | folder_to_shared | And "Alice" shares the following resource using the quick action - | resource | user | role | - | folder_to_shared/testavatar.jpeg | Brian | viewer | + | resource | recipient | type | role | + | folder_to_shared/testavatar.jpeg | Brian | user | viewer | And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page diff --git a/tests/e2e/cucumber/features/integrations/share.ocis.feature b/tests/e2e/cucumber/features/integrations/share.ocis.feature index 4d539355546..e01645345a6 100644 --- a/tests/e2e/cucumber/features/integrations/share.ocis.feature +++ b/tests/e2e/cucumber/features/integrations/share.ocis.feature @@ -20,8 +20,8 @@ Feature: share #Then "Alice" should see the following resource # | folder_to_shared/lorem.txt | When "Alice" shares the following resource using the sidebar panel - | resource | user | role | - | folder_to_shared | Brian | editor | + | resource | recipient | type | role | + | folder_to_shared | Brian | user | editor | And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page diff --git a/tests/e2e/cucumber/features/integrations/spaces/project.ocis.feature b/tests/e2e/cucumber/features/integrations/spaces/project.ocis.feature index dbcb52f911e..134cf24a2dd 100644 --- a/tests/e2e/cucumber/features/integrations/spaces/project.ocis.feature +++ b/tests/e2e/cucumber/features/integrations/spaces/project.ocis.feature @@ -56,8 +56,8 @@ Feature: spaces.personal # borrowed from share.feature When "Alice" shares the following resource using the sidebar panel - | resource | user | role | - | folder_to_shared | Brian | editor | + | resource | recipient | type | role | + | folder_to_shared | Brian | user | editor | # team.2 And "Alice" navigates to the projects space page diff --git a/tests/e2e/cucumber/features/journeys/kindergarten.oc10.feature b/tests/e2e/cucumber/features/journeys/kindergarten.oc10.feature index 6bb353ca2bb..d8b632f996b 100644 --- a/tests/e2e/cucumber/features/journeys/kindergarten.oc10.feature +++ b/tests/e2e/cucumber/features/journeys/kindergarten.oc10.feature @@ -36,9 +36,9 @@ Feature: Kindergarten can use web to organize a day # Implementation of sharing with different roles is currently broken # since we switched to bulk creating of shares with a single dropdown And "Alice" shares the following resources using the sidebar panel - | resource | user | role | - | groups/Pre-Schools Pirates/meal plan | Brian | editor | - | groups/Pre-Schools Pirates/meal plan | Carol | viewer | + | resource | recipient | type | role | + | groups/Pre-Schools Pirates/meal plan | Brian | user | editor | + | groups/Pre-Schools Pirates/meal plan | Carol | user | viewer | # Then what do we check for to be confident that the above things done by Alice have worked? When "Brian" logs in And "Brian" opens the "files" app diff --git a/tests/e2e/cucumber/features/journeys/kindergarten.ocis.feature b/tests/e2e/cucumber/features/journeys/kindergarten.ocis.feature index f88068a6940..94223acf29b 100644 --- a/tests/e2e/cucumber/features/journeys/kindergarten.ocis.feature +++ b/tests/e2e/cucumber/features/journeys/kindergarten.ocis.feature @@ -35,9 +35,9 @@ Feature: Kindergarten can use web to organize a day # Implementation of sharing with different roles is currently broken # since we switched to bulk creating of shares with a single dropdown And "Alice" shares the following resources using the sidebar panel - | resource | user | role | - | groups/Pre-Schools Pirates/meal plan | Brian | editor | - | groups/Pre-Schools Pirates/meal plan | Carol | viewer | + | resource | recipient | type | role | + | groups/Pre-Schools Pirates/meal plan | Brian | user | editor | + | groups/Pre-Schools Pirates/meal plan | Carol | user | viewer | # Then what do we check for to be confident that the above things done by Alice have worked? When "Brian" logs in And "Brian" opens the "files" app diff --git a/tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts b/tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts index 96151c238a6..28443c07d23 100644 --- a/tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts +++ b/tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts @@ -79,7 +79,7 @@ When( const spacesObject = new objects.applicationFiles.Spaces({ page }) for (const info of stepTable.hashes()) { await spacesObject.addMembers({ - users: [this.usersEnvironment.getUser({ key: info.user })], + recipients: [this.usersEnvironment.getUser({ key: info.user })], role: info.role }) } diff --git a/tests/e2e/cucumber/steps/app-files/share.ts b/tests/e2e/cucumber/steps/app-files/share.ts index cceee4b4c64..0af76d0cd87 100644 --- a/tests/e2e/cucumber/steps/app-files/share.ts +++ b/tests/e2e/cucumber/steps/app-files/share.ts @@ -14,13 +14,17 @@ When( const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const shareObject = new objects.applicationFiles.Share({ page }) const shareInfo = stepTable.hashes().reduce((acc, stepRow) => { - const { user, resource, role } = stepRow + const { resource, recipient, type, role } = stepRow if (!acc[resource]) { - acc[resource] = { users: [], role: '' } + acc[resource] = { recipients: [], role: '', type: '' } } - acc[resource].users.push(this.usersEnvironment.getUser({ key: user })) + acc[resource].recipients.push( + type === 'group' + ? this.usersEnvironment.getGroup({ key: recipient }) + : this.usersEnvironment.getUser({ key: recipient }) + ) acc[resource].role = role return acc @@ -29,7 +33,7 @@ When( for (const folder of Object.keys(shareInfo)) { await shareObject.create({ folder, - users: shareInfo[folder].users, + recipients: shareInfo[folder].recipients, role: shareInfo[folder].role, via: actionType === 'quick action' ? 'QUICK_ACTION' : 'SIDEBAR_PANEL' }) @@ -43,13 +47,17 @@ When( const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const shareObject = new objects.applicationFiles.Share({ page }) const shareInfo = stepTable.hashes().reduce((acc, stepRow) => { - const { user, resource, role } = stepRow + const { recipient, type, resource, role } = stepRow if (!acc[resource]) { - acc[resource] = { users: [], role: '' } + acc[resource] = { recipients: [], role: '', type: '' } } - acc[resource].users.push(this.usersEnvironment.getUser({ key: user })) + acc[resource].recipients.push( + type === 'group' + ? this.usersEnvironment.getGroup({ key: recipient }) + : this.usersEnvironment.getUser({ key: recipient }) + ) acc[resource].role = role return acc @@ -58,7 +66,7 @@ When( for (const folder of Object.keys(shareInfo)) { await shareObject.createReshare({ folder, - users: shareInfo[folder].users, + recipients: shareInfo[folder].recipients, role: shareInfo[folder].role }) } diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 997ff82a0d1..e3641d9884f 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -1,5 +1,5 @@ import { Page } from 'playwright' -import { User } from '../../../types' +import { Group, User } from '../../../types' import { sidebar } from '../utils' import { clickResource } from '../resource/actions' import util from 'util' @@ -21,13 +21,13 @@ const removeShareConfirmationButton = '.oc-modal-body-actions-confirm' export interface createShareArgs { page: Page folder: string - users: User[] + recipients: User[] | Group[] role: string via: 'SIDEBAR_PANEL' | 'QUICK_ACTION' } export const createShare = async (args: createShareArgs): Promise => { - const { page, folder, users, role, via } = args + const { page, folder, recipients, role, via } = args const folderPaths = folder.split('/') const folderName = folderPaths.pop() @@ -46,19 +46,19 @@ export const createShare = async (args: createShareArgs): Promise => { break } - await inviteMembers({ page, users, role }) + await inviteMembers({ page, recipients, role }) await sidebar.close({ page: page }) } export interface createReshareArgs { page: Page folder: string - users: User[] + recipients: User[] | Group[] role: string } export const createReshare = async (args: createReshareArgs): Promise => { - const { page, folder, users, role } = args + const { page, folder, recipients, role } = args const folderPaths = folder.split('/') const folderName = folderPaths.pop() @@ -68,23 +68,23 @@ export const createReshare = async (args: createReshareArgs): Promise => { await sidebar.open({ page: page, resource: folderName }) await sidebar.openPanel({ page: page, name: 'sharing' }) - await inviteMembers({ page, users, role }) + await inviteMembers({ page, recipients, role }) await sidebar.close({ page: page }) } export interface inviteMembersArgs { page: Page - users: User[] + recipients: User[] | Group[] role: string } export const inviteMembers = async (args: inviteMembersArgs): Promise => { - const { page, role, users } = args - for (const user of users) { + const { page, role, recipients } = args + for (const recipient of recipients) { const shareInputLocator = page.locator(invitationInput) await Promise.all([ page.waitForResponse((resp) => resp.url().includes('sharees') && resp.status() === 200), - shareInputLocator.fill(user.id) + shareInputLocator.fill(recipient.id) ]) await shareInputLocator.focus() await page.waitForSelector('.vs--open') diff --git a/tests/e2e/support/objects/app-files/spaces/actions.ts b/tests/e2e/support/objects/app-files/spaces/actions.ts index 13c669df524..98e1f10f305 100644 --- a/tests/e2e/support/objects/app-files/spaces/actions.ts +++ b/tests/e2e/support/objects/app-files/spaces/actions.ts @@ -171,10 +171,10 @@ export const changeQuota = async (args: { } export const addSpaceMembers = async (args: inviteMembersArgs): Promise => { - const { page, role, users } = args + const { page, role, recipients } = args await sidebar.open({ page: page }) await sidebar.openPanel({ page: page, name: 'space-share' }) - await inviteMembers({ page, users, role }) + await inviteMembers({ page, recipients, role }) await sidebar.close({ page: page }) }