From c77a67a3511d65ec55091f7e169960b410a7d38b Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 14 Oct 2024 15:26:32 +0200 Subject: [PATCH 1/2] expand Activity test --- .../cucumber/features/smoke/activity.feature | 61 ++++++++++++++++--- tests/e2e/cucumber/steps/api.ts | 18 +++++- tests/e2e/support/api/share/index.ts | 2 +- tests/e2e/support/api/share/share.ts | 44 +++++++++++++ 4 files changed, 113 insertions(+), 12 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/activity.feature b/tests/e2e/cucumber/features/smoke/activity.feature index 43b424453fd..7d6c9e396ec 100644 --- a/tests/e2e/cucumber/features/smoke/activity.feature +++ b/tests/e2e/cucumber/features/smoke/activity.feature @@ -10,31 +10,72 @@ Feature: Users can see all activities of the resources and spaces | Alice | Space Admin | Scenario: activity - When "Alice" creates the following project space using API + Given "Alice" creates the following project space using API | name | id | | team | team.1 | + And "Alice" adds the following members to the space "team" using API + | user | role | shareType | + | Brian | Can view | user | + And "Alice" creates a public link of the space using API + | space | name | password | + | team | space link | %public% | And "Alice" creates the following folder in personal space using API | name | | sharedFolder/subFolder | + And "Alice" uploads the following local file into personal space using API + | localFile | to | + | filesForUpload/textfile.txt | sharedFolder/textfile.txt | And "Alice" shares the following resource using API | resource | recipient | type | role | | sharedFolder | Brian | user | Can edit | + And "Alice" creates a public link of following resource using API + | resource | role | password | + | sharedFolder | Can edit | %public% | + + When "Anonymous" opens the public link "Unnamed link" + And "Anonymous" unlocks the public link with password "%public%" + And "Anonymous" edits the following resources + | resource | content | + | textfile.txt | new content | + Then "Anonymous" should not see any activity of the following resource + | resource | + | textfile.txt | + And "Alice" logs in + And "Alice" renames the following resource + | resource | as | + | sharedFolder/textfile.txt | new.txt | + And "Alice" deletes the following resource using the sidebar panel + | resource | from | + | subFolder | sharedFolder | Then "Alice" should see activity of the following resource - | resource | activity | - | sharedFolder | Alice Hansen shared sharedFolder with brian | + | resource | activity | + | sharedFolder | Alice Hansen deleted subFolder from sharedFolder | + | sharedFolder | Alice Hansen renamed textfile.txt to new.txt | + | sharedFolder | Public updated textfile.txt in sharedFolder | + | sharedFolder | Alice Hansen shared sharedFolder via link | + | sharedFolder | Alice Hansen shared sharedFolder with brian | + | sharedFolder | Alice Hansen added textfile.txt to sharedFolder | + | sharedFolder | Alice Hansen added subFolder to sharedFolder | + | sharedFolder | Alice Hansen added sharedFolder to Alice Hansen | + + | sharedFolder/new.txt | Alice Hansen renamed textfile.txt to new.txt | + | new.txt | Public updated textfile.txt in sharedFolder | + | new.txt | Alice Hansen added textfile.txt to sharedFolder | + And "Alice" logs out # see activity in the project space - And "Alice" navigates to the project space "team.1" - Then "Alice" should see activity of the space + When "Brian" logs in + And "Brian" navigates to the project space "team.1" + Then "Brian" should see activity of the space | activity | + |Alice Hansen shared team via link| + |Alice Hansen added brian as member of team| | Alice Hansen added readme.md to .space | - And "Alice" logs out # see activity in the shared resources - When "Brian" logs in - And "Brian" navigates to the shared with me page + When "Brian" navigates to the shared with me page Then "Brian" should not see any activity of the following resource - | resource | - | sharedFolder/subFolder | + | resource | + | sharedFolder/new.txt | And "Brian" logs out diff --git a/tests/e2e/cucumber/steps/api.ts b/tests/e2e/cucumber/steps/api.ts index 9ce84921583..e5884a6e4de 100644 --- a/tests/e2e/cucumber/steps/api.ts +++ b/tests/e2e/cucumber/steps/api.ts @@ -297,10 +297,26 @@ Given( user, path: info.resource, password: info.password, - name: 'Unnamed link', + name: info.name ? info.name : 'Unnamed link', role: info.role, spaceName: info.space }) } } ) + +Given( + '{string} creates a public link of the space using API', + async function (this: World, stepUser: string, stepTable: DataTable) { + const user = this.usersEnvironment.getUser({ key: stepUser }) + for (const info of stepTable.hashes()) { + await api.share.createLinkSpace({ + user, + spaceName: info.space, + password: info.password, + name: info.name ? info.name : 'Unnamed link', + role: info.role, + }) + } + } +) diff --git a/tests/e2e/support/api/share/index.ts b/tests/e2e/support/api/share/index.ts index d0d11a96822..81de6b948ba 100644 --- a/tests/e2e/support/api/share/index.ts +++ b/tests/e2e/support/api/share/index.ts @@ -1 +1 @@ -export { createShare, addMembersToTheProjectSpace, createLinkShare } from './share' +export { createShare, addMembersToTheProjectSpace, createLinkShare, createLinkSpace } from './share' diff --git a/tests/e2e/support/api/share/share.ts b/tests/e2e/support/api/share/share.ts index 945c27801fd..2b6d9ad4ecd 100644 --- a/tests/e2e/support/api/share/share.ts +++ b/tests/e2e/support/api/share/share.ts @@ -253,3 +253,47 @@ export const createLinkShare = async ({ checkResponseStatus(response, 'Failed while creating public link share') } + +export const createLinkSpace = async ({ + user, + spaceName, + password, + name, + role = 'Can view' +}: { + user: User + spaceName: string + password: string + name: string + role?: string +}): Promise => { + const driveId: string = await getSpaceIdBySpaceName({ + user, + spaceType: 'project', + spaceName + }) + + const roleType: string = linkShareRoles[role as keyof typeof linkShareRoles] + password = password === '%public%' ? securePassword : password + + const response = await request({ + method: 'POST', + path: join('graph', 'v1beta1', 'drives', driveId, 'root', 'createLink'), + body: JSON.stringify({ + type: roleType, + password, + displayName: name + }), + user + }) + + const responseData = (await response.json()) as { link: { webUrl: string } } + const webUrl = responseData.link.webUrl + const linksEnvironment: LinksEnvironment = new LinksEnvironment() + linksEnvironment.createLink({ + key: name, + link: { name: name, url: webUrl } + }) + + checkResponseStatus(response, 'Failed while creating public link space') +} From 5d31af26392db104d5a5424af0dd7cebede84936 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Tue, 15 Oct 2024 08:17:12 +0200 Subject: [PATCH 2/2] lint fix. fix naming --- tests/e2e/cucumber/steps/api.ts | 4 ++-- tests/e2e/support/api/share/index.ts | 7 ++++++- tests/e2e/support/api/share/share.ts | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/e2e/cucumber/steps/api.ts b/tests/e2e/cucumber/steps/api.ts index e5884a6e4de..5e2811a20b5 100644 --- a/tests/e2e/cucumber/steps/api.ts +++ b/tests/e2e/cucumber/steps/api.ts @@ -310,12 +310,12 @@ Given( async function (this: World, stepUser: string, stepTable: DataTable) { const user = this.usersEnvironment.getUser({ key: stepUser }) for (const info of stepTable.hashes()) { - await api.share.createLinkSpace({ + await api.share.createSpaceLinkShare({ user, spaceName: info.space, password: info.password, name: info.name ? info.name : 'Unnamed link', - role: info.role, + role: info.role }) } } diff --git a/tests/e2e/support/api/share/index.ts b/tests/e2e/support/api/share/index.ts index 81de6b948ba..7192e500399 100644 --- a/tests/e2e/support/api/share/index.ts +++ b/tests/e2e/support/api/share/index.ts @@ -1 +1,6 @@ -export { createShare, addMembersToTheProjectSpace, createLinkShare, createLinkSpace } from './share' +export { + createShare, + addMembersToTheProjectSpace, + createLinkShare, + createSpaceLinkShare +} from './share' diff --git a/tests/e2e/support/api/share/share.ts b/tests/e2e/support/api/share/share.ts index 2b6d9ad4ecd..ee4c73f594d 100644 --- a/tests/e2e/support/api/share/share.ts +++ b/tests/e2e/support/api/share/share.ts @@ -254,7 +254,7 @@ export const createLinkShare = async ({ checkResponseStatus(response, 'Failed while creating public link share') } -export const createLinkSpace = async ({ +export const createSpaceLinkShare = async ({ user, spaceName, password, @@ -275,7 +275,7 @@ export const createLinkSpace = async ({ const roleType: string = linkShareRoles[role as keyof typeof linkShareRoles] password = password === '%public%' ? securePassword : password - + const response = await request({ method: 'POST', path: join('graph', 'v1beta1', 'drives', driveId, 'root', 'createLink'),