Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci]Add remove sharee step in share.ocis.feature #8174

Merged
merged 5 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
| resource | recipient |
| folder_to_customShared | Brian |
And "Alice" deletes the following resources
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
| resource |
| folder_to_shared/lorem_new.txt |
| folder_to_shared |
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
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
kiranparajuli589 marked this conversation as resolved.
Show resolved Hide resolved
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,
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
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(
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
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
}