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

test.describe('download space', () => {
let actorsEnvironment
const usersEnvironment = new UsersEnvironment()
const linksEnvironment = new LinksEnvironment()
const spacesEnvironment = new SpacesEnvironment()
const filesEnvironment = new FilesEnvironment()

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 () => {
// clean up users
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' })
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Brian' })
})

test('download space', 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'
})

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




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


// And "Alice" creates the following folder in space "team" using API
// | name |
// | spaceFolder |
await api.createFolderInsideSpaceBySpaceName({usersEnvironment,stepUser:'Alice',space:'team',folder:'spaceFolder'})







// And "Alice" creates the following file in space "team" using API
// | name | content |
// | spaceFolder/lorem.txt | space team |
await api.uploadFileInsideSpaceBySpaceName({usersEnvironment,stepUser:'Alice',space:'team',pathToFile:'spaceFolder/lorem.txt'})



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

// When "Alice" downloads the space "team.1"
await ui.downloadSpace({actorsEnvironment,stepUser:'Alice'})


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


// And "Alice" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
// And "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' })

// When "Alice" downloads the space "team.1"
await ui.downloadSpace({actorsEnvironment,stepUser:'Brian'})
// And "Brian" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Brian' })
})
})
41 changes: 41 additions & 0 deletions tests/e2e-playwright/steps/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,44 @@ export async function uploadFileInPersonalSpace({
content
})
}

export async function uploadFileInsideSpaceBySpaceName({
usersEnvironment,
stepUser,
space,
pathToFile,
content,
}: {
usersEnvironment: UsersEnvironment
stepUser: string
space: string
pathToFile: string
content?: string
}) {
const user = usersEnvironment.getUser({ key: stepUser })
await api.dav.uploadFileInsideSpaceBySpaceName({
user,
pathToFile: pathToFile,
spaceName: space,
content: content
})
}

export async function createFolderInsideSpaceBySpaceName({
usersEnvironment,
stepUser,
space,
folder,
}: {
usersEnvironment: UsersEnvironment
stepUser: string
space: string
folder: string
}) {
const user = usersEnvironment.getUser({ key: stepUser })
await api.dav.createFolderInsideSpaceBySpaceName({
user,
folder: folder,
spaceName: space
})
}
12 changes: 12 additions & 0 deletions tests/e2e-playwright/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ 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 downloadSpace({
actorsEnvironment,
stepUser,
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const downloadedResource = await spacesObject.downloadSpace()
expect(downloadedResource).toContain('download.zip')
}