Skip to content

Commit

Permalink
Merge pull request #7544 from owncloud/sharingWithGroupTest
Browse files Browse the repository at this point in the history
[tests-only] add step sharing with group
  • Loading branch information
phil-davis authored Aug 31, 2022
2 parents 768c687 + fdf46b0 commit e386e4c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,36 @@ 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
And "Carol" accepts the following share
| 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



8 changes: 4 additions & 4 deletions tests/e2e/cucumber/features/integrations/share.oc10.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/cucumber/features/integrations/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
24 changes: 16 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,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
Expand All @@ -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'
})
Expand All @@ -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
Expand All @@ -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
})
}
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 e386e4c

Please sign in to comment.