Skip to content

Commit

Permalink
add step sharing with group
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor committed Aug 29, 2022
1 parent b716730 commit 4bebc82
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
17 changes: 7 additions & 10 deletions tests/e2e/cucumber/features/integrations/reshare.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ 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
And "Alice" creates the following resources
| 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
And "Brian" accepts the following share
| 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
Expand All @@ -49,6 +49,3 @@ Feature: reshare
| resource | user | role |
| folder_to_shared | Alice | viewer |
And "Carol" logs out



2 changes: 1 addition & 1 deletion tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/cucumber/steps/app-files/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ 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
Expand All @@ -29,7 +29,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'
})
Expand All @@ -43,13 +43,13 @@ 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
Expand All @@ -58,7 +58,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
})
}
Expand Down
22 changes: 11 additions & 11 deletions tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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<void> => {
const { page, folder, users, role, via } = args
const { page, folder, recipients, role, via } = args
const folderPaths = folder.split('/')
const folderName = folderPaths.pop()

Expand All @@ -46,19 +46,19 @@ export const createShare = async (args: createShareArgs): Promise<void> => {
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<void> => {
const { page, folder, users, role } = args
const { page, folder, recipients, role } = args
const folderPaths = folder.split('/')
const folderName = folderPaths.pop()

Expand All @@ -68,23 +68,23 @@ export const createReshare = async (args: createReshareArgs): Promise<void> => {
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<void> => {
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')
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/support/objects/app-files/spaces/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ export const changeQuota = async (args: {
}

export const addSpaceMembers = async (args: inviteMembersArgs): Promise<void> => {
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 })
}

Expand Down

0 comments on commit 4bebc82

Please sign in to comment.