Skip to content

Commit

Permalink
Do not share versions. change e2e test
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
ScharfViktor committed Apr 5, 2023
1 parent 664951b commit 5143e26
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 15 deletions.
5 changes: 1 addition & 4 deletions tests/e2e/cucumber/features/smoke/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ Feature: share
And "Alice" uploads the following resource
| resource | to | option |
| PARENT/simple.pdf | folder_to_shared | replace |
And "Brian" downloads old version of the following resource
And "Brian" should not see the version of the file
| resource | to |
| simple.pdf | folder_to_shared |
And "Brian" restores following resources
| resource | to | version |
| simple.pdf | folder_to_shared | 1 |
And "Alice" removes following sharee
| resource | recipient |
| folder_to_customShared | Brian |
Expand Down
48 changes: 48 additions & 0 deletions tests/e2e/cucumber/features/smoke/spaces/project.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,51 @@ Feature: spaces.personal
When "Anonymous" logs out


Scenario: members of the space can control the versions of the files
Given "Admin" creates following users using API
| id |
| Alice |
| Brian |
| Carol |
And "Admin" assigns following roles to the users using API
| id | role |
| Alice | Space Admin |
And "Alice" creates the following project space using API
| name | id |
| team | team.1 |
And "Alice" logs in
And "Alice" navigates to the projects space page
And "Alice" navigates to the project space "team.1"
And "Alice" creates the following resources
| resource | type | content |
| parent/textfile.txt | txtFile | some random content |
When "Alice" uploads the following resources
| resource | to | option |
| textfile.txt | parent | replace |
And "Alice" adds following users to the project space
| user | role | kind |
| Carol | viewer | user |
| Brian | editor | user |
And "Alice" logs out

When "Carol" logs in
And "Carol" opens the "files" app
And "Carol" navigates to the projects space page
And "Carol" navigates to the project space "team.1"
And "Carol" should not see the version of the file
| resource | to |
| textfile.txt | parent |
And "Carol" logs out

When "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the projects space page
And "Brian" navigates to the project space "team.1"
And "Brian" downloads old version of the following resource
| resource | to |
| textfile.txt | parent |
And "Brian" restores following resources
| resource | to | version |
| textfile.txt | parent | 1 |
And "Brian" logs out

23 changes: 23 additions & 0 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,26 @@ When(
})
}
)

When(
'{string} should not see the version of the file(s)',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const fileInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { to, resource } = stepRow

if (!acc[to]) {
acc[to] = []
}

acc[to].push(this.filesEnvironment.getFile({ name: resource }))

return acc
}, {})

for (const folder of Object.keys(fileInfo)) {
await resourceObject.checkThatFileVersionIsNotAvailable({ folder, files: fileInfo[folder] })
}
}
)
37 changes: 29 additions & 8 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const tagInInputForm =
const tagFormInput = '#tags-form input'
const compareDialogConfirmBtn = '.compare-save-dialog-confirm-btn'
const resourcesAsTiles = '#files-view .oc-tiles'
const fileVersionSidebar = '#oc-file-versions-sidebar'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -194,11 +195,10 @@ export const createNewFileOrFolder = async (args: createResourceArgs): Promise<v
await page.locator(createNewDrawioFileButton).click()
await page.locator(resourceNameInput).fill(name)

await Promise.all([
page.waitForResponse((resp) => resp.status() === 201 && resp.request().method() === 'PUT'),
page.locator(util.format(actionConfirmationButton, 'Create')).click()
])

await page.locator(util.format(actionConfirmationButton, 'Create')).click()
await page.waitForResponse(
(resp) => resp.status() === 201 && resp.request().method() === 'PUT'
)
await page.waitForLoadState()
await page.frameLocator(drawioIframe).locator(drawioSaveButton).click()
await page.waitForURL('**/draw-io/personal/**')
Expand Down Expand Up @@ -536,13 +536,13 @@ export const renameResource = async (args: renameResourceArgs): Promise<void> =>

/**/

export interface restoreResourceVersionArgs {
export interface resourceVersionArgs {
page: Page
files: File[]
folder?: string
}

export const restoreResourceVersion = async (args: restoreResourceVersionArgs) => {
export const restoreResourceVersion = async (args: resourceVersionArgs) => {
const { page, files, folder } = args
const fileName = files.map((file) => path.basename(file.name))
await clickResource({ page, path: folder })
Expand All @@ -554,7 +554,7 @@ export const restoreResourceVersion = async (args: restoreResourceVersionArgs) =
(resp) =>
resp.url().includes('/v/') && resp.status() === 204 && resp.request().method() === 'COPY'
),
await page.locator(versionRevertButton).click()
await page.locator(versionRevertButton).first().click()
])
}

Expand Down Expand Up @@ -1006,3 +1006,24 @@ export const openFileInViewer = async (args: openFileInViewerArgs): Promise<void

await Promise.all([page.waitForNavigation(), page.locator(closeTextEditorOrViewerButton).click()])
}

export const checkThatFileVersionIsNotAvailable = async (
args: resourceVersionArgs
): Promise<void> => {
const { page, files, folder } = args
const fileName = files.map((file) => path.basename(file.name))
await clickResource({ page, path: folder })

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('dav/meta') &&
resp.status() === 403 &&
resp.request().method() === 'PROPFIND'
),
sidebar.open({ page, resource: fileName[0] })
])

await sidebar.openPanel({ page, name: 'versions' })
await expect(page.locator(fileVersionSidebar)).toHaveText('No Versions available for this file')
}
13 changes: 10 additions & 3 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
renameResource,
renameResourceArgs,
restoreResourceVersion,
restoreResourceVersionArgs,
resourceVersionArgs,
uploadResource,
uploadResourceArgs,
restoreResourceTrashbinArgs,
Expand Down Expand Up @@ -47,7 +47,8 @@ import {
createSpaceFromFolder,
createSpaceFromFolderArgs,
createSpaceFromSelection,
createSpaceFromSelectionArgs
createSpaceFromSelectionArgs,
checkThatFileVersionIsNotAvailable
} from './actions'
import { Space } from '../../../types'

Expand Down Expand Up @@ -118,7 +119,7 @@ export class Resource {
// eslint-disable-next-line @typescript-eslint/no-empty-function
async open(): Promise<void> {}

async restoreVersion(args: Omit<restoreResourceVersionArgs, 'page'>): Promise<void> {
async restoreVersion(args: Omit<resourceVersionArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await restoreResourceVersion({ ...args, page: this.#page })
// Files details page does not update after restore button is clicked
Expand Down Expand Up @@ -237,4 +238,10 @@ export class Resource {
async createSpaceFromSelection(args: Omit<createSpaceFromSelectionArgs, 'page'>): Promise<Space> {
return createSpaceFromSelection({ ...args, page: this.#page })
}

async checkThatFileVersionIsNotAvailable(args: Omit<resourceVersionArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await checkThatFileVersionIsNotAvailable({ ...args, page: this.#page })
await this.#page.goto(startUrl)
}
}

0 comments on commit 5143e26

Please sign in to comment.