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
18 changes: 11 additions & 7 deletions tests/e2e/cucumber/features/spaces/project.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Feature: spaces.personal
And "Alice" updates the space "team.1" description to "developer team - description"
And "Alice" updates the space "team.1" quota to "50"
And "Alice" updates the space "team.1" image to "testavatar.png"
Then space image should match 16/9 ratio for user "Alice"
And space image should match 16/9 ratio for user "Alice"
And "Alice" deletes the space "team.1" image
And "Alice" changes the space "team.1" icon to "😍"

# shared examples
And "Alice" creates the following resources
Expand All @@ -60,13 +62,15 @@ Feature: spaces.personal
| resource | recipient | type | role | resourceType |
| folder_to_shared | Brian | user | Can edit | folder |

# team.2
# team.2: do the same thing, but using the context menu
And "Alice" navigates to the project space "team.2"
And "Alice" updates the space "team.2" name to "management team"
And "Alice" updates the space "team.2" subtitle to "management team - subtitle"
And "Alice" updates the space "team.2" description to "management team - description"
And "Alice" updates the space "team.2" quota to "500"
And "Alice" updates the space "team.2" image to "testavatar.png"
And "Alice" changes the space "team.2" name to "management team" using context menu
And "Alice" changes the space "team.2" subtitle to "management team - subtitle" using context menu
And "Alice" changes the space "team.2" description to "management team - description" using context menu
And "Alice" changes the space "team.2" quota to "500" using context menu
And "Alice" changes the space "team.2" image to "testavatar.png" using context menu
And "Alice" deletes the space "team.2" image using context menu
And "Alice" changes the space "team.2" icon to "😜" using context menu

And "Alice" creates the following resources
| resource | type |
Expand Down
64 changes: 63 additions & 1 deletion tests/e2e/cucumber/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ When(
)

When(
/^"([^"]*)" (?:changes|updates) the space "([^"]*)" (name|subtitle|description|quota|image) to "([^"]*)"$/,
/^"([^"]*)" (?:changes|updates) the space "([^"]*)" (name|subtitle|description|quota|image|icon) to "([^"]*)"$/,
async function (
this: World,
stepUser: string,
Expand Down Expand Up @@ -76,12 +76,74 @@ When(
resource: this.filesEnvironment.getFile({ name: value })
})
break
case 'icon':
await spacesObject.changeSpaceIcon({ key, icon: value })
break
default:
throw new Error(`${attribute} not implemented`)
}
}
)

When(
/^"([^"]*)" changes the space "([^"]*)" (name|subtitle|description|quota|image|icon) to "([^"]*)" using context menu$/,
async function (
this: World,
stepUser: string,
key: string,
attribute: string,
value: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })

switch (attribute) {
case 'name':
await spacesObject.changeName({ key, value, contextMenu: true })
break
case 'subtitle':
await spacesObject.changeSubtitle({ key, value, contextMenu: true })
break
case 'description':
await spacesObject.changeDescription({ value, contextMenu: true })
break
case 'quota':
await spacesObject.changeQuota({ key, value, contextMenu: true })
break
case 'image':
await spacesObject.changeSpaceImage({
key,
resource: this.filesEnvironment.getFile({ name: value }),
contextMenu: true
})
break
case 'icon':
await spacesObject.changeSpaceIcon({ key, icon: value, contextMenu: true })
break
default:
throw new Error(`${attribute} not implemented`)
}
}
)

When(
'{string} deletes the space {string} image using context menu',
async function (this: World, stepUser: string, space: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
await spacesObject.deleteSpaceImage({ space, contextMenu: true })
}
)

When(
'{string} deletes the space {string} image',
async function (this: World, stepUser: string, space: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationFiles.Spaces({ page })
await spacesObject.deleteSpaceImage({ space })
}
)

When(
'{string} adds following user(s) to the project space',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
Expand Down
123 changes: 103 additions & 20 deletions tests/e2e/support/objects/app-files/spaces/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import { createLink } from '../link/actions'
import { File } from '../../../types'

const newSpaceMenuButton = '#new-space-menu-btn'
const spaceContextMenuButton = '#space-context-btn'
const spaceNameInputField = '.oc-modal input'
const actionConfirmButton = '.oc-modal-body-actions-confirm'
const spaceIdSelector = `[data-item-id="%s"] .oc-resource-basename`
const spacesRenameOptionSelector = '.oc-files-actions-rename-trigger:visible'
const editSpacesSubtitleOptionSelector = '.oc-files-actions-edit-description-trigger:visible'
const editQuotaOptionSelector = '.oc-files-actions-edit-quota-trigger:visible'
const editImageOptionSelector = '.oc-files-actions-upload-space-image-trigger:visible'
const editImageOptionSelector = '.oc-files-actions-upload-space-image-trigger'
const deleteImageButton = '.oc-files-actions-delete-space-image-trigger'
const setIconButton = '.oc-files-actions-set-space-icon-trigger'
const downloadSpaceSelector = '.oc-files-actions-download-archive-trigger:visible'
const spacesQuotaSearchField = '.oc-modal .vs__search'
const selectedQuotaValueField = '.vs--open'
Expand All @@ -24,6 +27,8 @@ const spacesDescriptionSaveTextFileInEditorButton = '#app-save-action:visible'
const spaceHeaderSelector = '.space-header'
const activitySidebarPanel = 'sidebar-panel-activities'
const activitySidebarPanelBodyContent = '#sidebar-panel-activities .sidebar-panel__body-content'
const editImageInContextMenuButton =
'//button[contains(@id, "oc-files-context-actions-space-image")]'

export const openActionsPanel = async (page: Page): Promise<void> => {
await sidebar.open({ page })
Expand Down Expand Up @@ -87,9 +92,10 @@ export const changeSpaceName = async (args: {
page: Page
id: string
value: string
contextMenu?: boolean
}): Promise<void> => {
const { page, value, id } = args
await openActionsPanel(page)
const { page, value, id, contextMenu = false } = args
await (contextMenu ? page.locator(spaceContextMenuButton).click() : openActionsPanel(page))

await page.locator(spacesRenameOptionSelector).click()
await page.locator(spaceNameInputField).fill(value)
Expand All @@ -103,7 +109,7 @@ export const changeSpaceName = async (args: {
page.locator(actionConfirmButton).click()
])

await sidebar.close({ page: page })
!contextMenu && (await sidebar.close({ page }))
}

/**/
Expand All @@ -112,9 +118,10 @@ export const changeSpaceSubtitle = async (args: {
page: Page
id: string
value: string
contextMenu?: boolean
}): Promise<void> => {
const { page, value, id } = args
await openActionsPanel(page)
const { page, value, id, contextMenu = false } = args
await (contextMenu ? page.locator(spaceContextMenuButton).click() : openActionsPanel(page))

await page.locator(editSpacesSubtitleOptionSelector).click()
await page.locator(spaceNameInputField).fill(value)
Expand All @@ -128,17 +135,19 @@ export const changeSpaceSubtitle = async (args: {
page.locator(actionConfirmButton).click()
])

await sidebar.close({ page: page })
!contextMenu && (await sidebar.close({ page }))
}

/**/

export const changeSpaceDescription = async (args: {
page: Page
value: string
contextMenu?: boolean
}): Promise<void> => {
const { page, value } = args
await openActionsPanel(page)
const { page, value, contextMenu = false } = args
await (contextMenu ? page.locator(spaceContextMenuButton).click() : openActionsPanel(page))

const waitForUpdate = () =>
page.waitForResponse(
(resp) =>
Expand All @@ -163,9 +172,10 @@ export const changeQuota = async (args: {
id: string
page: Page
value: string
contextMenu?: boolean
}): Promise<void> => {
const { id, page, value } = args
await openActionsPanel(page)
const { id, page, value, contextMenu = false } = args
await (contextMenu ? page.locator(spaceContextMenuButton).click() : openActionsPanel(page))

await page.locator(editQuotaOptionSelector).click()
const searchLocator = page.locator(spacesQuotaSearchField)
Expand All @@ -183,7 +193,7 @@ export const changeQuota = async (args: {
page.locator(actionConfirmButton).click()
])

await sidebar.close({ page: page })
!contextMenu && (await sidebar.close({ page }))
}

export interface SpaceMembersArgs {
Expand All @@ -203,15 +213,19 @@ export const changeSpaceImage = async (args: {
id: string
page: Page
resource: File
contextMenu?: boolean
}): Promise<void> => {
const { id, page, resource } = args
await openActionsPanel(page)

const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'),
page.locator(editImageOptionSelector).click()
])
const { id, page, resource, contextMenu = false } = args
if (contextMenu) {
await page.locator(spaceContextMenuButton).click()
await page.locator(editImageInContextMenuButton).hover()
} else {
await openActionsPanel(page)
}
const uploadTrigger = page.locator(editImageOptionSelector)
await expect(uploadTrigger).toBeVisible()

const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), uploadTrigger.click()])
await Promise.all([
page.waitForResponse(
(resp) =>
Expand All @@ -229,7 +243,76 @@ export const changeSpaceImage = async (args: {
fileChooser.setFiles(resource.path)
])

await sidebar.close({ page: page })
!contextMenu && (await sidebar.close({ page }))
}

export const changeSpaceIcon = async (args: {
id: string
page: Page
icon: string
contextMenu?: boolean
}): Promise<void> => {
const { id, page, icon, contextMenu = false } = args
if (contextMenu) {
await page.locator(spaceContextMenuButton).click()
await page.locator(editImageInContextMenuButton).hover()
} else {
await openActionsPanel(page)
}
const setIcon = page.locator(setIconButton)
await expect(setIcon).toBeVisible()
await setIcon.click()

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().endsWith(encodeURIComponent(id)) &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
),
page.waitForResponse(
(resp) =>
resp.url().includes('image.png') &&
resp.status() === 201 &&
resp.request().method() === 'PUT'
),
page.locator(`button[aria-label="${icon}"]`).first().click()
])
!contextMenu && (await sidebar.close({ page }))
}

export const deleteSpaceImage = async (args: {
id: string
page: Page
contextMenu?: boolean
}): Promise<void> => {
const { id, page, contextMenu = false } = args
if (contextMenu) {
await page.locator(spaceContextMenuButton).click()
await page.locator(editImageInContextMenuButton).hover()
} else {
await openActionsPanel(page)
}
const deleteTrigger = page.locator(deleteImageButton)
await expect(deleteTrigger).toBeVisible()

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('image.png') &&
resp.status() === 204 &&
resp.request().method() === 'DELETE'
),
page.waitForResponse(
(resp) =>
resp.url().endsWith(encodeURIComponent(id)) &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
),
page.locator(actionConfirmButton).click(),
deleteTrigger.click()
])
!contextMenu && (await sidebar.close({ page }))
}

export interface removeAccessMembersArgs extends Omit<SpaceMembersArgs, 'users'> {
Expand Down
Loading