Skip to content

Commit

Permalink
add e2e test for space image (#7112)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor authored Jun 24, 2022
1 parent 06c1383 commit b9811c4
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Feature: spaces.personal

Scenario: unstructured collection of testable space interactions,
once all needed features are there, split this into independent tests.
contains following features:
- ✓ assign role to user
- ✓ create space & internal alias to differentiate multiple spaces with the same name
- ✓ open space
- ✓ rename space
- ✓ change/set space subtitle
- ✓ change/set space description
- ✓ change/set space quota
- ✓ resources & existing resource actions
- ✗ change/set space image
- ✗ trash bin
- ✗ share
- ✗ link
once all needed features are there, split this into independent tests.
contains following features:
- ✓ assign role to user
- ✓ create space & internal alias to differentiate multiple spaces with the same name
- ✓ open space
- ✓ rename space
- ✓ change/set space subtitle
- ✓ change/set space description
- ✓ change/set space quota
- ✓ resources & existing resource actions
- ✓ change/set space image
- ✗ trash bin
- ✗ share
- ✗ link
Given "Admin" creates following users
| id |
| Alice |
Expand All @@ -36,6 +36,7 @@ Feature: spaces.personal
And "Alice" updates the space "team.1" subtitle to "developer team - subtitle"
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"

# shared examples
And "Alice" creates the following resources
Expand Down Expand Up @@ -65,6 +66,7 @@ Feature: spaces.personal
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 "sampleGif.gif"

And "Alice" creates the following resources
| resource | type |
Expand Down Expand Up @@ -101,6 +103,7 @@ Feature: spaces.personal
| simple.pdf | folder_to_shared |
And "Alice" navigates to the projects space page
And "Alice" navigates to the project space "team.1"
And "Alice" updates the space "team.1" image to "testavatar.jpeg"
And "Alice" uploads the following resource
| resource | to | create_version |
| PARENT/simple.pdf | folder_to_shared | true |
Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/cucumber/steps/app-files/page/spaces/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ When(
)

When(
/^"([^"]*)" (changes|updates) the space "([^"]*)" (name|subtitle|description|quota) to "([^"]*)"$/,
/^"([^"]*)" (changes|updates) the space "([^"]*)" (name|subtitle|description|quota|image) to "([^"]*)"$/,
async function (
this: World,
stepUser: string,
Expand All @@ -60,6 +60,12 @@ When(
case 'quota':
await spacesObject.changeQuota({ key, value })
break
case 'image':
await spacesObject.changeSpaceImage({
key,
resource: this.filesEnvironment.getFile({ name: value })
})
break
default:
throw new Error(`${action} not implemented`)
}
Expand Down
46 changes: 46 additions & 0 deletions tests/e2e/support/objects/app-files/spaces/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Page } from 'playwright'
import { sidebar } from '../utils'
import { File } from '../../../types'
import util from 'util'
import { inviteMembers, inviteMembersArgs } from '../share/actions'
import { expect } from '@playwright/test'

const newSpaceMenuButton = '#new-space-menu-btn'
const spaceNameInputField = '.oc-modal input'
Expand All @@ -10,6 +12,7 @@ const spaceIdSelector = `[data-space-id="%s"]`
const spacesRenameOptionSelector = '.oc-files-actions-rename-trigger'
const editSpacesSubtitleOptionSelector = '.oc-files-actions-edit-description-trigger'
const editQuotaOptionSelector = '.oc-files-actions-edit-quota-trigger'
const editImageOptionSelector = '.oc-files-actions-upload-space-image-trigger'
const spacesQuotaSearchField = '.oc-modal .vs__search'
const selectedQuotaValueField = '.vs--open'
const quotaValueDropDown = `.vs__dropdown-option :text-is("%s")`
Expand All @@ -19,6 +22,9 @@ const sideBarActions =
'//ul[@id="oc-files-actions-sidebar"]//span[@class="oc-files-context-action-label"]'
const spaceDeletedFilesButton = '.oc-files-actions-delete-trigger'
const spaceContextButton = '#space-context-btn'
const spaceOverviewImg = '.space-overview-image'

export let spaceImageId = ''
/**/

export interface createSpaceArgs {
Expand Down Expand Up @@ -206,3 +212,43 @@ export const openSpaceTrashBin = async (args: openSpaceTrashBinArgs): Promise<vo
await page.locator(spaceContextButton).click()
await page.locator(spaceDeletedFilesButton).click()
}

/**/

export const changeSpaceImage = async (args: {
id: string
page: Page
resource: File
}): Promise<void> => {
const { id, page, resource } = args
await sidebar.open({ page: page })
await sidebar.openPanel({ page: page, name: 'space-actions' })

const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'),
page.locator(editImageOptionSelector).click()
])

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().endsWith(encodeURIComponent(id)) &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
),
page.waitForResponse(
(resp) =>
resp.url().endsWith(resource.name) &&
resp.status() === 207 &&
resp.request().method() === 'PROPFIND'
),
fileChooser.setFiles(resource.path)
])

const img = await page.locator(spaceOverviewImg)
const src = await img.evaluate((e) => (e as HTMLImageElement).src)
expect(src).not.toBe(spaceImageId)
spaceImageId = src

await sidebar.close({ page: page })
}
7 changes: 7 additions & 0 deletions tests/e2e/support/objects/app-files/spaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Page } from 'playwright'
import { SpacesEnvironment } from '../../../environment'
import { File } from '../../../types'
import {
addSpaceMembers,
canUserEditSpaceResource,
Expand All @@ -8,6 +9,7 @@ import {
changeSpaceDescription,
changeSpaceName,
changeSpaceSubtitle,
changeSpaceImage,
createSpace,
createSpaceArgs,
openSpace,
Expand Down Expand Up @@ -79,4 +81,9 @@ export class Spaces {
const { id } = this.#spacesEnvironment.getSpace({ key })
await openSpaceTrashBin({ id, page: this.#page })
}

async changeSpaceImage({ key, resource }: { key: string; resource: File }): Promise<void> {
const { id } = this.#spacesEnvironment.getSpace({ key })
await changeSpaceImage({ id, resource, page: this.#page })
}
}

0 comments on commit b9811c4

Please sign in to comment.