Skip to content

Commit

Permalink
Refactor for folder share
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Jan 12, 2023
1 parent 2920b11 commit 3277ddc
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/features/smoke/share.oc10.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Feature: share
| resource | recipient |
| folder_to_shared/testavatar.jpeg | Brian |
And "Alice" logs out
When "Brian" opens the "files" app
#When "Brian" opens the "files" app
#Then "Brian" should not see the following resource
# | Shares/testavatar_new.jpeg |
#But "Brian" should see the following resource
Expand Down
42 changes: 26 additions & 16 deletions tests/e2e/cucumber/features/smoke/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,50 @@ Feature: share
| Brian |

Scenario: folder
When "Alice" logs in
Given "Alice" creates the following folder in personal space using API
| name |
| folder_to_shared |
| folder_to_customShared |
And "Alice" logs in
And "Alice" opens the "files" app
And "Alice" creates the following resources
| resource | type |
| folder_to_shared | folder |
And "Alice" uploads the following resource
| resource | to |
| lorem.txt | folder_to_shared |
| resource | to |
| lorem.txt | folder_to_shared |
| lorem-big.txt | folder_to_customShared |
When "Alice" shares the following resource using the sidebar panel
| resource | recipient | type | role |
| folder_to_shared | Brian | user | editor |
| resource | recipient | type | role |
| folder_to_shared | Brian | user | editor |
| folder_to_customShared | Brian | user | editor |
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 |
| name |
| folder_to_shared |
| folder_to_customShared |
And "Brian" renames the following resource
| resource | as |
| folder_to_shared/lorem.txt | lorem_new.txt |
And "Brian" uploads the following resource
| resource | to |
| simple.pdf | folder_to_shared |
When "Alice" opens the "files" app
And "Alice" opens the "files" app
And "Alice" uploads the following resource
| resource | to | option |
| PARENT/simple.pdf | folder_to_shared | replace |
And "Brian" downloads old version of the following resource
| resource | to |
| simple.pdf | folder_to_shared |
When "Brian" restores following resources
And "Brian" restores following resources
| resource | to | version |
| simple.pdf | folder_to_shared | 1 |
When "Alice" deletes the following resources
And "Alice" removes following sharee
| resource | recipient |
| folder_to_customShared | Brian |
Then "Brian" should not be able to see the following shares
| resource | owner |
| folder_to_customShared | Alice Hansen |
And "Alice" deletes the following resources
| resource |
| folder_to_shared/lorem_new.txt |
| folder_to_shared |
Expand All @@ -49,7 +59,7 @@ Feature: share


Scenario: file
When "Alice" logs in
Given "Alice" logs in
And "Alice" opens the "files" app
And "Alice" creates the following resources
| resource | type | content |
Expand All @@ -60,7 +70,7 @@ Feature: share
| resource |
| testavatar.jpeg |
| simple.pdf |
And "Alice" shares the following resource using the sidebar panel
When "Alice" shares the following resource using the sidebar panel
| resource | recipient | type | role |
| shareToBrian.txt | Brian | user | editor |
| shareToBrian.md | Brian | user | editor |
Expand Down Expand Up @@ -90,7 +100,7 @@ Feature: share
| shareToBrian.txt | Brian |
| shareToBrian.md | Brian |
And "Alice" logs out
And "Brian" should not be able to see the following shares
Then "Brian" should not be able to see the following shares
| resource | owner |
| shareToBrian.txt | Alice Hansen |
| shareToBrian.md | Alice Hansen |
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/cucumber/steps/ui/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ Then(
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const shareObject = new objects.applicationFiles.Share({ page })
for (const { resource, owner } of stepTable.hashes()) {
const hasAcceptedShareExist = await shareObject.checkShareContext(resource, owner)
expect(hasAcceptedShareExist).toBe(shouldExist)
const isAcceptedSharePresent = await shareObject.isAcceptedSharePresent(resource, owner)
expect(isAcceptedSharePresent).toBe(shouldExist)
}
}
)
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const checkSharee = async (args: ShareArgs): Promise<void> => {
}
}

export const checkShareContext = async (
export const isAcceptedSharePresent = async (
page: Page,
resource: string,
owner: string
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/support/objects/app-files/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
acceptShare,
changeShareeRole,
removeShareeArgs,
checkShareContext,
isAcceptedSharePresent,
removeSharee,
ShareArgs,
ShareStatusArgs,
Expand Down Expand Up @@ -55,9 +55,9 @@ export class Share {
await this.#page.goto(startUrl)
}

async checkShareContext(resource: string, owner: string): Promise<boolean> {
async isAcceptedSharePresent(resource: string, owner: string): Promise<boolean> {
await this.#page.reload()
return await checkShareContext(this.#page, resource, owner)
return await isAcceptedSharePresent(this.#page, resource, owner)
}

async hasPermissionToShare(resource: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/share/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import util from 'util'

const acceptedShareList =
'//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]'

export const acceptedShareExists = async ({
page,
resource,
Expand All @@ -15,7 +16,6 @@ export const acceptedShareExists = async ({
timeout?: number
}): Promise<boolean> => {
let exist = true
// page.locator(util.format(acceptedShareList, resource, owner)).waitFor()
await page
.waitForSelector(util.format(acceptedShareList, resource, owner), { timeout })
.catch((e) => {
Expand Down

0 comments on commit 3277ddc

Please sign in to comment.