Skip to content

Commit

Permalink
[e2e] separate upload step for internal link
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Feb 8, 2023
1 parent 0dae7f6 commit 2f43ac2
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 41 deletions.
41 changes: 0 additions & 41 deletions tests/e2e/cucumber/features/smoke/spaces/internalLink.feature

This file was deleted.

39 changes: 39 additions & 0 deletions tests/e2e/cucumber/features/smoke/spaces/internalLink.ocis.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Feature: internal link share in project space

Scenario: share a link with internal role
Given "Admin" creates following users
| id |
| Alice |
| Brian |
And "Admin" assigns following roles to the users
| id | role |
| Alice | SpaceAdmin |
And "Alice" creates the following project space using API
| name | id |
| Marketing | marketing.1 |
And "Alice" creates the following folder in space "Marketing" using API
| name |
| myfolder |
And "Alice" creates the following file in space "Marketing" using API
| name | content |
| myfolder/plan.txt | secret plan |
And "Alice" logs in
And "Alice" navigates to the projects space page
And "Alice" navigates to the project space "marketing.1"
And "Alice" adds following users to the project space
| user | role | kind |
| Brian | editor | user |
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" uploads the following resource in internal link named "Link"
| resource |
| simple.pdf |
When "Alice" changes the roles of the following users in the project space
| user | role |
| Brian | viewer |
And "Alice" logs out
And "Brian" reloads the spaces page
Then "Brian" should see file "plan.txt" but should not be able to edit
And "Brian" logs out
22 changes: 22 additions & 0 deletions tests/e2e/cucumber/steps/ui/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ When(
}
)

When(
'{string} uploads the following resource(s) in internal link named {string}',
async function (
this: World,
stepUser: string,
link: string,
stepTable: DataTable
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const pageObject = new objects.applicationFiles.page.Public({ page })
const { url } = this.linksEnvironment.getLink({ name: link })
for (const info of stepTable.hashes()) {
await pageObject.uploadInternal({
to: info.to,
resources: [this.filesEnvironment.getFile({ name: info.resource })],
option: info.option,
link: url
})
}
}
)

Then(
'{string} should not be able to open the old link {string}',
function (this: World, stepUser: string, name: string): void {
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/cucumber/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ Then(
}
)

Then(
'{string} should see file {string} but should not be able to edit',
async function (this: World, stepUser: string, resource: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const userCanEdit = await spacesObject.canUserEditResource({ resource })
expect(userCanEdit).toBe(false)
}
)

Then(
'{string} should not be able to see space {string}',
async function (this: World, stepUser: string, space: string): Promise<void> {
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/support/objects/app-files/page/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export class Public {
await this.#page.locator('body').click()
}

async uploadInternal(args: Omit<uploadResourceArgs, 'page'> & { link: string }): Promise<void> {
// link is the public link url
const { link } = args
delete args.link
await uploadResource({ ...args, page: this.#page })
await this.#page.goto(link)
}

async delete(args: Omit<deleteResourceArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await deleteResource({ ...args, page: this.#page })
Expand Down

0 comments on commit 2f43ac2

Please sign in to comment.