Skip to content
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
3 changes: 2 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ config = {
# NOTE: make the pipelines similar to the above e2e
# along with the addition of new test suites
"e2e-playwright": {
"1": {
"3": {
"earlyFail": True,
"skip": False,
"suites": [
"shares",
"search",
],
},
},
Expand Down
133 changes: 133 additions & 0 deletions tests/e2e-playwright/specs/search/searchProjectSpace.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { expect, test } from '@playwright/test'
import { config } from '../../../e2e/config.js'
import {
ActorsEnvironment,
UsersEnvironment,
SpacesEnvironment,
FilesEnvironment
} from '../../../e2e/support/environment'
import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken'
import * as api from '../../steps/api/api'
import * as ui from '../../steps/ui/index'

test.describe('Search in the project space', () => {
let actorsEnvironment
const usersEnvironment = new UsersEnvironment()
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)

await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' })

await api.userHasAssignRolesToUsers({
usersEnvironment,
stepUser: 'Admin',
targetUserId: 'Alice',
role: 'Space Admin'
})

await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' })

await api.userHasCreatedProjectSpace({
usersEnvironment,
spacesEnvironment,
stepUser: 'Alice',
name: 'team',
id: 'team.1'
})

await ui.navigateToProjectSpace({ actorsEnvironment, stepUser: 'Alice', space: 'team.1' })

await ui.createResource({
actorsEnvironment,
stepUser: 'Alice',
resource: 'folder(WithSymbols:!;_+-&)',
type: 'folder'
})

await ui.uploadResource({
actorsEnvironment,
filesEnvironment,
stepUser: 'Alice',
resource: "new-'single'quotes.txt",
to: 'folder(WithSymbols:!;_+-&)'
})

await ui.navigateToPersonalSpacePage({ actorsEnvironment, stepUser: 'Alice' })
})

test.afterEach(async () => {
// clean up users
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' })
})

test('Search in the project spaces', async () => {
// search for project space objects
await ui.searchGloballyWithFilter({
actorsEnvironment,
stepUser: 'Alice',
keyword: "-'s",
filter: 'all files'
})

expect(
await ui.resourceExists({
actorsEnvironment,
listType: 'search list',
stepUser: 'Alice',
resource: "new-'single'quotes.txt"
})
).toBeTruthy()

expect(
await ui.resourceExists({
actorsEnvironment,
listType: 'search list',
stepUser: 'Alice',
resource: 'folder(WithSymbols:!;_+-&)'
})
).toBeFalsy()

await ui.searchGloballyWithFilter({
actorsEnvironment,
stepUser: 'Alice',
keyword: '!;_+-&)',
filter: 'all files'
})

expect(
await ui.resourceExists({
actorsEnvironment,
listType: 'search list',
stepUser: 'Alice',
resource: 'folder(WithSymbols:!;_+-&)'
})
).toBeTruthy()

expect(
await ui.resourceExists({
actorsEnvironment,
listType: 'search list',
stepUser: 'Alice',
resource: "new-'single'quotes.txt"
})
).toBeFalsy()

await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
})
})
49 changes: 48 additions & 1 deletion tests/e2e-playwright/steps/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { config } from '../../../e2e/config.js'
import { UsersEnvironment } from '../../../e2e/support/environment'
import { UsersEnvironment, SpacesEnvironment } from '../../../e2e/support/environment'
import { api } from '../../../e2e/support'
import { ResourceType } from '../../../e2e/support/api/share/share'
import { Space } from '../../../e2e/support/types'

export async function userHasBeenCreated({
usersEnvironment,
Expand Down Expand Up @@ -138,3 +139,49 @@ export async function userHasCreatedPublicLinkOfResource({
spaceName: space
})
}

export async function userHasAssignRolesToUsers({
usersEnvironment,
stepUser,
targetUserId,
role
}: {
usersEnvironment: UsersEnvironment
stepUser: string
targetUserId: string
role: string
}) {
const admin = usersEnvironment.getUser({ key: stepUser })
const user = usersEnvironment.getUser({ key: targetUserId })
/**
The oCIS API request for assigning roles allows only one role per user,
whereas the Keycloak API request can assign multiple roles to a user.
If multiple roles are assigned to a user in Keycloak,
oCIS map the highest priority role among Keycloak assigned roles.
Therefore, we need to unassign the previous role before
assigning a new one when using the Keycloak API.
*/
await api.provision.unAssignRole({ admin, user })
await api.provision.assignRole({ admin, user, role })
}

export async function userHasCreatedProjectSpace({
usersEnvironment,
spacesEnvironment,
stepUser,
name,
id
}: {
usersEnvironment: UsersEnvironment
spacesEnvironment: SpacesEnvironment
stepUser: string
name: string
id: string
}) {
const user = usersEnvironment.getUser({ key: stepUser })
const spaceId = await api.graph.createSpace({ user, space: { id, name } as unknown as Space })
spacesEnvironment.createSpace({
key: id || name,
space: { name: name, id: spaceId }
})
}
50 changes: 44 additions & 6 deletions tests/e2e-playwright/steps/ui/resources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { objects } from '../../../e2e/support'
import { ActorsEnvironment, FilesEnvironment } from '../../../e2e/support/environment'
import { displayedResourceType } from '../../../e2e/support/objects/app-files/resource/actions'
import {
createResourceTypes,
displayedResourceType,
searchFilter
} from '../../../e2e/support/objects/app-files/resource/actions'

export async function uploadResource({
actorsEnvironment,
Expand Down Expand Up @@ -44,20 +48,54 @@ export async function isAbleToEditFileOrFolder({
return userCanEdit
}

export async function createDir({
export async function createResource({
actorsEnvironment,
stepUser,
directoryName
resource,
type,
content,
password
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
directoryName: string
resource: string
type: string
content?: string
password?: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.create({
name: directoryName,
type: 'folder'
name: resource,
type: type as createResourceTypes,
content: content,
password: password
})
}

export async function searchGloballyWithFilter({
actorsEnvironment,
stepUser,
keyword,
filter,
command
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
keyword: string
filter: string
command?: string
}): Promise<void> {
keyword = keyword ?? ''
const pressEnter = !!command && command.endsWith('presses enter')
const { page } = actorsEnvironment.getActor({ key: stepUser })
// let search indexing to complete
await page.waitForTimeout(1000)
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.searchResource({
keyword,
filter: filter as searchFilter,
pressEnter
})
}

Expand Down
16 changes: 16 additions & 0 deletions tests/e2e-playwright/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,19 @@ export async function navigateToPersonalSpacePage({
const pageObject = new objects.applicationFiles.page.spaces.Personal({ page })
await pageObject.navigate()
}

export async function navigateToProjectSpace({
actorsEnvironment,
stepUser,
space
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
space: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
const pageObject = new objects.applicationFiles.page.spaces.Projects({ page })
await pageObject.navigate()
await spacesObject.open({ key: space })
}
38 changes: 0 additions & 38 deletions tests/e2e/cucumber/features/search/searchProjectSpace.feature

This file was deleted.