Skip to content

Commit

Permalink
refactor share via api for link share
Browse files Browse the repository at this point in the history
address reviews
  • Loading branch information
saw-jan committed Jan 30, 2023
1 parent ab4bcb7 commit 1cbee7a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
37 changes: 17 additions & 20 deletions tests/e2e/cucumber/features/smoke/internalLink.ocis.feature
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
Feature: internal link share

Scenario: link share as an internal role
Scenario: share a link with internal role
Given "Admin" creates following users
| id |
| Alice |
| Brian |
And "Alice" creates the following folder in personal space using API
| name |
| folderPublic |
| name |
| myfolder |
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| myfolder | Brian | user | editor |
And "Alice" logs in
And "Alice" opens the "files" app
And "Alice" uploads the following resources
| resource | to |
| lorem.txt | folderPublic |
And "Alice" shares the following resource using the sidebar panel
| resource | recipient | type | role |
| folderPublic | Brian | user | editor |
And "Alice" creates a public link for the resource "folderPublic" using the sidebar panel
When "Alice" edits the public link named "Link" of resource "folderPublic" changing role to "internal"
And "Alice" creates a public link for the resource "myfolder" using the sidebar panel
When "Alice" edits the public link named "Link" of resource "myfolder" changing role to "internal"
And "Brian" opens the public link "Link"
And "Brian" logs in from the internal link
And "Brian" opens shared-with-me page from the internal link
And "Brian" accepts the following share
| name |
| folderPublic |
| name |
| myfolder |
And "Brian" uploads the following resource
| resource | to |
| simple.pdf | folderPublic |
| resource | to |
| simple.pdf | myfolder |
And "Alice" updates following sharee role
| resource | recipient | type | role |
| folderPublic | Brian | user | custom_permissions:read |
| resource | recipient | type | role |
| myfolder | Brian | user | custom_permissions:read |
And "Alice" logs out
# Then "Brian" should not able to edit the following resources
# | resource |
# | folderPublic |
Then "Brian" should not be able to reshare the following resource
| resource |
| myfolder |
And "Brian" logs out
5 changes: 3 additions & 2 deletions tests/e2e/cucumber/steps/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ Given(
await api.share.createShare({
user,
path: info.resource,
shareWith: info.recipient,
shareType: info.type,
role: info.role
shareWith: info.recipient,
role: info.role,
name: info.name
})
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/cucumber/steps/ui/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Then, When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import { World } from '../../environment'
import { objects } from '../../../support'
import { kebabCase } from 'lodash'
import { DateTime } from 'luxon'

When(
'{string} creates a public link for the resource {string} using the sidebar panel',
Expand Down
9 changes: 6 additions & 3 deletions tests/e2e/support/api/share/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ export const createShare = async ({
path,
shareWith,
shareType,
role
role,
name
}: {
user: User
path: string
shareWith: string
shareType: string
role: string
shareWith?: string
role?: string
name?: string
}): Promise<void> => {
const body = new URLSearchParams()
body.append('path', path)
body.append('shareWith', shareWith)
body.append('shareType', shareTypes[shareType])
body.append('role', role)
body.append('name', name)

const response = await request({
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/support/objects/runtime/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Ocis implements LoginAdapter {

async login({ user }: { user: User }): Promise<void> {
const { id, password } = user

await this.#page.locator('#oc-login-username').fill(id)
await this.#page.locator('#oc-login-password').fill(password)
await this.#page.locator('button[type="submit"]').click()
Expand Down

0 comments on commit 1cbee7a

Please sign in to comment.