Skip to content

Commit

Permalink
[tests-only][full-ci]Add remove sharee step in share.ocis.feature (#8174
Browse files Browse the repository at this point in the history
)

* Add then step in share feature file

* Refactor for folder share

* Address review

* Review address

* Rebase conflict
  • Loading branch information
amrita-shrestha authored and SagarGi committed Jan 19, 2023
1 parent b827a6b commit 7f0049c
Show file tree
Hide file tree
Showing 5 changed files with 98 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
63 changes: 42 additions & 21 deletions tests/e2e/cucumber/features/smoke/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@ 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 |
| shared_folder |
And "Alice" logs in
And "Alice" opens the "files" app
And "Alice" creates the following resources
| resource | type |
| folder_to_shared | folder |
| shared_folder | 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 |
| shared_folder | Brian | user | editor |
| resource | recipient | type | role |
| folder_to_shared | Brian | user | editor |
| shared_folder | 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 |
| folder_to_customShared |
Then "Brian" should not be able to open the folder "shared_folder"
When "Brian" accepts the following share
| name |
| folder_to_shared |
When "Brian" accepts the following share from the context menu
| name |
| shared_folder |
And "Brian" declines the following share
| name |
| shared_folder |
Expand All @@ -44,26 +51,33 @@ Feature: share
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 |
And "Alice" deletes the following resources
| resource |
| folder_to_shared/lorem_new.txt |
| folder_to_shared |
And "Alice" logs out
Then "Brian" should not be able to see the following shares
| resource | owner |
| folder_to_customShared | Alice Hansen |
| folder_to_shared | Alice Hansen |
And "Brian" logs out


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 @@ -75,16 +89,14 @@ 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 |
| testavatar.jpeg | Brian | user | viewer |
| simple.pdf | Brian | user | viewer |
| sharedFile.txt | Brian | user | editor |
And "Alice" logs out

When "Brian" logs in
And "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
Then "Brian" should not be able to open the file "shareToBrian.txt"
Expand Down Expand Up @@ -115,4 +127,13 @@ Feature: share
And "Brian" opens the following file in pdfviewer
| resource |
| simple.pdf |
And "Alice" removes following sharee
| resource | recipient |
| shareToBrian.txt | Brian |
| shareToBrian.md | Brian |
And "Alice" logs out
Then "Brian" should not be able to see the following shares
| resource | owner |
| shareToBrian.txt | Alice Hansen |
| shareToBrian.md | Alice Hansen |
And "Brian" logs out
20 changes: 20 additions & 0 deletions tests/e2e/cucumber/steps/ui/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,23 @@ When(
expect(await shareObject.resourceIsNotOpenable(resource)).toBe(true)
}
)

Then(
/"([^"]*)" should( not | )be able to see the following shares$/,
async function (
this: World,
stepUser: string,
condition: string,
stepTable: DataTable
): Promise<void> {
const shouldExist = condition.trim() !== 'not'
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const shareObject = new objects.applicationFiles.Share({ page })
for (const { resource, owner } of stepTable.hashes()) {
const isAcceptedSharePresent = await shareObject.isAcceptedSharePresent(resource, owner)
expect(isAcceptedSharePresent, '${resource} does not exist in accepted share').toBe(
shouldExist
)
}
}
)
7 changes: 6 additions & 1 deletion tests/e2e/support/objects/app-files/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
hasPermissionToShare,
copyQuickLink
} from './actions'
import { resourceIsNotOpenable } from './utils'
import { resourceIsNotOpenable, isAcceptedSharePresent } from './utils'
import { copyLinkArgs } from '../link/actions'

export class Share {
Expand Down Expand Up @@ -57,6 +57,11 @@ export class Share {
await this.#page.goto(startUrl)
}

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

async hasPermissionToShare(resource: string): Promise<boolean> {
return await hasPermissionToShare({ page: this.#page, resource })
}
Expand Down
30 changes: 29 additions & 1 deletion tests/e2e/support/objects/app-files/share/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Page } from 'playwright'
import { errors, Page } from 'playwright'
import util from 'util'
import { resourceNameSelector, fileRow } from '../resource/actions'

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

export const resourceIsNotOpenable = async ({
page,
resource
Expand All @@ -26,3 +29,28 @@ export const resourceIsNotOpenable = async ({
})
return true
}

export const isAcceptedSharePresent = async ({
page,
resource,
owner,
timeout = 500
}: {
page: Page
resource: string
owner: string
timeout?: number
}): Promise<boolean> => {
let exist = true
await page
.waitForSelector(util.format(acceptedShareItem, resource, owner), { timeout })
.catch((e) => {
if (!(e instanceof errors.TimeoutError)) {
throw e
}

exist = false
})

return exist
}

0 comments on commit 7f0049c

Please sign in to comment.