Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e2e-test] Do not share versions. added test where share receiver does not see file version #8779

Merged
merged 5 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
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
54 changes: 51 additions & 3 deletions tests/e2e/cucumber/features/smoke/spaces/project.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ Feature: spaces.personal
And "Alice" uploads the following resource
| resource | to | option |
| PARENT/simple.pdf | folder_to_shared | replace |
When "Brian" restores following resources
| resource | to | version |
| simple.pdf | folder_to_shared | 1 |
When "Brian" should not see the version of the file
| resource | to |
| simple.pdf | folder_to_shared |
When "Alice" deletes the following resources using the sidebar panel
| resource | from |
| lorem_new.txt | folder_to_shared |
Expand All @@ -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] })
}
}
)
28 changes: 25 additions & 3 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 @@ -536,13 +537,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 +555,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 +1007,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)
}
}