Skip to content
Open
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
124 changes: 124 additions & 0 deletions tests/e2e-playwright/specs/spaces/memberExpiry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { test } from '@playwright/test'
import { config } from './../../../e2e/config.js'
import {
ActorsEnvironment,
SpacesEnvironment,
UsersEnvironment
} from '../../../e2e/support/environment'
import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken'
import * as ui from '../../steps/ui/index'
import * as api from '../../steps/api/api'

test.describe('spaces member expiry', () => {
let actorsEnvironment: ActorsEnvironment
const usersEnvironment = new UsersEnvironment()
const spacesEnvironment = new SpacesEnvironment()

test.beforeEach(async ({ browser }) => {
actorsEnvironment = new ActorsEnvironment({
context: {
acceptDownloads: config.acceptDownloads,
reportDir: config.reportDir,
tracingReportDir: config.tracingReportDir,
reportHar: config.reportHar,
reportTracing: config.reportTracing,
reportVideo: config.reportVideo,
failOnUncaughtConsoleError: config.failOnUncaughtConsoleError
},
browser: browser
})

await setAccessAndRefreshToken(usersEnvironment)
})

test.afterEach(async () => {
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' })
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Brian' })
await api.userHasDeletedProjectSpace({
usersEnvironment,
stepUser: 'Admin',
name: 'team',
id: 'team.1'
})
})

test('space members can be invited with an expiration date', async () => {
// Given "Admin" creates following users using API
// | id |
// | Alice |
// | Brian |
await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' })
await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Brian' })

// And "Admin" assigns following roles to the users using API
// | id | role |
// | Alice | Space Admin |
await api.userHasAssignRolesToUsers({
usersEnvironment,
stepUser: 'Admin',
targetUserId: 'Alice',
role: 'Space Admin'
})

// And "Alice" logs in
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' })

// And "Alice" creates the following project space using API
// | name | id |
// | team | team.1 |
await api.userHasCreatedProjectSpace({
usersEnvironment,
spacesEnvironment,
stepUser: 'Alice',
name: 'team',
id: 'team.1'
})

// And "Alice" navigates to the project space "team.1"
await ui.navigateToSpace({ actorsEnvironment, stepUser: 'Alice', space: 'team.1' })

// And "Alice" adds following users to the project space
// | user | role | kind |
// | Brian | Can edit | user |
await ui.addMembersToSpace({
actorsEnvironment,
usersEnvironment,
stepUser: 'Alice',
sharee: 'Brian',
role: 'Can edit',
kind: 'user'
})

// And "Alice" sets the expiration date of the member "Brian" of the project space to "+5 days"
await ui.addExpirationDate({
usersEnvironment,
actorsEnvironment,
stepUser: 'Alice',
memberName: 'Brian',
expirationDate: '+5 days'
})

// When "Brian" logs in
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Brian' })

// And "Brian" navigates to the project space "team.1"
await ui.navigateToSpace({ actorsEnvironment, stepUser: 'Brian', space: 'team.1' })

// And "Brian" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Brian' })

// And "Alice" navigates to the project space "team.1"
await ui.navigateToSpace({ actorsEnvironment, stepUser: 'Alice', space: 'team.1' })

// And "Alice" removes the expiration date of the member "Brian" of the project space
await ui.removeExpirationDate({
usersEnvironment,
actorsEnvironment,
stepUser: 'Alice',
memberName: 'Brian'
})

// And "Alice" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
})
})
15 changes: 15 additions & 0 deletions tests/e2e-playwright/steps/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,18 @@ export async function createFileInsideSpaceBySpaceName({
content: content
})
}

export async function userHasDeletedProjectSpace({
usersEnvironment,
stepUser,
name,
id
}: {
usersEnvironment: UsersEnvironment
stepUser: string
name: string
id: string
}) {
const user = usersEnvironment.getUser({ key: stepUser })
await api.graph.deleteSpace({ user, space: { id, name } as unknown as Space })
}
69 changes: 68 additions & 1 deletion tests/e2e-playwright/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActorsEnvironment } from '../../../e2e/support/environment'
import { ActorsEnvironment, UsersEnvironment } from '../../../e2e/support/environment'
import { objects } from '../../../e2e/support'
import { Space } from '../../../e2e/support/types'
import { getDynamicRoleIdByName, ResourceType } from '../../../e2e/support/api/share/share'

export async function navigateToPersonalSpacePage({
actorsEnvironment,
Expand Down Expand Up @@ -57,3 +58,69 @@ export async function createProjectSpace({
const spacesObject = new objects.applicationFiles.Spaces({ page })
await spacesObject.create({ key: id || name, space: { name: name, id: id } as unknown as Space })
}
export async function addMembersToSpace({
actorsEnvironment,
usersEnvironment,
stepUser,
sharee,
role,
kind
}: {
actorsEnvironment: ActorsEnvironment
usersEnvironment: UsersEnvironment
stepUser: string
sharee: string
role: string
kind: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const sharer = usersEnvironment.getUser({ key: stepUser })

const collaborator =
kind === 'user'
? usersEnvironment.getUser({ key: sharee })
: usersEnvironment.getGroup({ key: sharee })
const roleId = await getDynamicRoleIdByName(sharer, role, 'space' as ResourceType)
const collaboratorWithRole = {
collaborator,
role: roleId
}
await spacesObject.addMembers({ users: [collaboratorWithRole] })
}

export async function addExpirationDate({
actorsEnvironment,
usersEnvironment,
stepUser,
memberName,
expirationDate
}: {
actorsEnvironment: ActorsEnvironment
usersEnvironment: UsersEnvironment
stepUser: string
memberName: string
expirationDate: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const member = { collaborator: usersEnvironment.getUser({ key: memberName }) }
await spacesObject.addExpirationDate({ member, expirationDate })
}

export async function removeExpirationDate({
actorsEnvironment,
usersEnvironment,
stepUser,
memberName
}: {
actorsEnvironment: ActorsEnvironment
usersEnvironment: UsersEnvironment
stepUser: string
memberName: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const member = { collaborator: usersEnvironment.getUser({ key: memberName }) }
await spacesObject.removeExpirationDate({ member })
}
25 changes: 0 additions & 25 deletions tests/e2e/cucumber/features/spaces/memberExpiry.feature

This file was deleted.

17 changes: 17 additions & 0 deletions tests/e2e/support/objects/app-files/share/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ export default class Collaborator {
page.waitForResponse((resp) => resp.url().includes('users') && resp.status() === 200),
collaboratorInputLocator.fill(collaborator.displayName)
])
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
page,
['appSidebar'],
'account page'
)
await collaboratorInputLocator.focus()
await page.locator('.vs--open').waitFor()
await page
Expand Down Expand Up @@ -194,6 +199,7 @@ export default class Collaborator {
.locator(util.format(Collaborator.collaboratorEditDropdownButton, collaboratorRow))
.first()
.click()
await objects.a11y.Accessibility.assertNoSevereA11yViolations(page, ['tippyBox'], 'files modal')
await page.locator(util.format(Collaborator.removeCollaboratorButton, collaboratorRow)).click()
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
page,
Expand Down Expand Up @@ -252,6 +258,11 @@ export default class Collaborator {
await page
.locator(util.format(Collaborator.collaboratorEditDropdownButton, collaboratorRow))
.click()
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
page,
['tippyBox'],
'account page'
)

const panel = page.locator(Collaborator.invitePanel)
await Promise.all([
Expand All @@ -260,6 +271,7 @@ export default class Collaborator {
.locator(util.format(Collaborator.setExpirationDateCollaboratorButton, collaboratorRow))
.click()
])
await objects.a11y.Accessibility.assertNoSevereA11yViolations(page, ['ocModal'], 'account page')

await Collaborator.setExpirationDate(page, expirationDate)
}
Expand Down Expand Up @@ -288,6 +300,11 @@ export default class Collaborator {
await page
.locator(util.format(Collaborator.collaboratorEditDropdownButton, collaboratorRow))
.click()
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
page,
['tippyBox'],
'account page'
)
await Promise.all([
page.waitForResponse(
(resp) =>
Expand Down