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

[full-ci][tests-only] Add internal link e2e tests for project space #8361

Merged
merged 3 commits into from
Feb 8, 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
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 |
| Brian | editor |
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
39 changes: 39 additions & 0 deletions tests/e2e/cucumber/steps/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,42 @@ Given(
}
}
)

Given(
'{string} creates the following file(s) in space {string} using API',
async function (
this: World,
stepUser: string,
space: string,
stepTable: DataTable
): Promise<void> {
const user = this.usersEnvironment.getUser({ key: stepUser })
for (const info of stepTable.hashes()) {
await api.dav.uploadFileInsideSpaceBySpaceName({
user,
pathToFile: info.name,
spaceName: space,
content: info.content
})
}
}
)

Given(
'{string} creates the following folder(s) in space {string} using API',
async function (
this: World,
stepUser: string,
space: string,
stepTable: DataTable
): Promise<void> {
const user = this.usersEnvironment.getUser({ key: stepUser })
for (const info of stepTable.hashes()) {
await api.dav.createFolderInsideSpaceBySpaceName({
user,
folder: info.name,
spaceName: space
})
}
}
)
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 @@ -121,6 +121,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
6 changes: 4 additions & 2 deletions tests/e2e/support/api/davSpaces/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ export const createFolderInsidePersonalSpace = async ({
export const uploadFileInsideSpaceBySpaceName = async ({
user,
pathToFile,
spaceName
spaceName,
content = ''
}: {
user: User
pathToFile: string
spaceName: string
content?: string
}): Promise<void> => {
const webDavEndPathToRoot =
'spaces/' + (await getSpaceIdBySpaceName({ user, spaceType: 'project', spaceName }))
await createFile({ user, pathToFile, webDavEndPathToRoot })
await createFile({ user, pathToFile, content, webDavEndPathToRoot })
}

export const getDataOfFileInsideSpace = async ({
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
SwikritiT marked this conversation as resolved.
Show resolved Hide resolved
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