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

[tests-only][full-ci]Extended download folders for kinder garden feature #8264

Merged
merged 4 commits into from
Jan 30, 2023
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
47 changes: 28 additions & 19 deletions tests/e2e/cucumber/features/journeys/kindergarten.oc10.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Feature: Kindergarten can use web to organize a day
| meal plan |
And "Brian" navigates to the personal space page
And "Brian" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | Shares/meal plan |
| resource | from | type |
| data.zip | Shares/meal plan | file |
# Then what do we check for to be confident that the above things done by Brian have worked?
# Then the downloaded zip should contain... ?
When "Carol" logs in
Expand All @@ -60,31 +60,40 @@ Feature: Kindergarten can use web to organize a day
| meal plan |
And "Carol" navigates to the personal space page
And "Carol" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | Shares/meal plan |
| lorem.txt | Shares/meal plan |
| lorem-big.txt | Shares/meal plan |
| resource | from | type |
| data.zip | Shares/meal plan | file |
| lorem.txt | Shares/meal plan | file |
| lorem-big.txt | Shares/meal plan | file |
| meal plan | Shares | folder |
# Then what do we check for to be confident that the above things done by Carol have worked?
# Then the downloaded files should have content "abc..."
And "Carol" logs out
When "Brian" downloads the following resources using the sidebar panel
| resource | from |
| lorem.txt | Shares/meal plan |
| lorem-big.txt | Shares/meal plan |
| resource | from | type |
| lorem.txt | Shares/meal plan | file |
| lorem-big.txt | Shares/meal plan | file |
| meal plan | Shares | folder |
# Then what do we check for to be confident that the above things done by Brian have worked?
# Then the downloaded files should have content "abc..."
And "Brian" logs out
And "Alice" downloads the following resources using the sidebar panel
| resource | from |
| parent.txt | groups/Kindergarten Koalas/meal plan |
| lorem.txt | groups/Kindergarten Koalas/meal plan |
| lorem-big.txt | groups/Kindergarten Koalas/meal plan |
| data.zip | groups/Pre-Schools Pirates/meal plan |
| lorem.txt | groups/Pre-Schools Pirates/meal plan |
| lorem-big.txt | groups/Pre-Schools Pirates/meal plan |
| data.zip | groups/Teddy Bear Daycare/meal plan |
| lorem.txt | groups/Teddy Bear Daycare/meal plan |
| lorem-big.txt | groups/Teddy Bear Daycare/meal plan |
| resource | from | type |
| parent.txt | groups/Kindergarten Koalas/meal plan | file |
| lorem.txt | groups/Kindergarten Koalas/meal plan | file |
| lorem-big.txt | groups/Kindergarten Koalas/meal plan | file |
| data.zip | groups/Pre-Schools Pirates/meal plan | file |
| lorem.txt | groups/Pre-Schools Pirates/meal plan | file |
| lorem-big.txt | groups/Pre-Schools Pirates/meal plan | file |
| data.zip | groups/Teddy Bear Daycare/meal plan | file |
| lorem.txt | groups/Teddy Bear Daycare/meal plan | file |
| lorem-big.txt | groups/Teddy Bear Daycare/meal plan | file |
| meal plan | groups/Kindergarten Koalas | folder |
| meal plan | groups/Pre-Schools Pirates | folder |
| meal plan | groups/Teddy Bear Daycare | folder |
| Kindergarten Koalas | groups | folder |
| Pre-Schools Pirates | groups | folder |
| Teddy Bear Daycare | groups | folder |
| groups | | folder |
# Then what do we check for to be confident that the above things done by Alice have worked?
# Then the downloaded files should have content "abc..."
And "Alice" logs out
47 changes: 28 additions & 19 deletions tests/e2e/cucumber/features/journeys/kindergarten.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Feature: Kindergarten can use web to organize a day
| name |
| meal plan |
And "Brian" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | meal plan |
| resource | from | type |
| data.zip | meal plan | file |
# Then what do we check for to be confident that the above things done by Brian have worked?
# Then the downloaded zip should contain... ?
When "Carol" logs in
Expand All @@ -57,31 +57,40 @@ Feature: Kindergarten can use web to organize a day
| name |
| meal plan |
And "Carol" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | meal plan |
| lorem.txt | meal plan |
| lorem-big.txt | meal plan |
| resource | from | type |
| data.zip | meal plan | file |
| lorem.txt | meal plan | file |
| lorem-big.txt | meal plan | file |
| meal plan | | folder |
# Then what do we check for to be confident that the above things done by Carol have worked?
# Then the downloaded files should have content "abc..."
And "Carol" logs out
When "Brian" downloads the following resources using the sidebar panel
| resource | from |
| lorem.txt | meal plan |
| lorem-big.txt | meal plan |
| resource | from | type |
| lorem.txt | meal plan | file |
| lorem-big.txt | meal plan | file |
| meal plan | | folder |
# Then what do we check for to be confident that the above things done by Brian have worked?
# Then the downloaded files should have content "abc..."
And "Brian" logs out
And "Alice" downloads the following resources using the sidebar panel
| resource | from |
| parent.txt | groups/Kindergarten Koalas/meal plan |
| lorem.txt | groups/Kindergarten Koalas/meal plan |
| lorem-big.txt | groups/Kindergarten Koalas/meal plan |
| data.zip | groups/Pre-Schools Pirates/meal plan |
| lorem.txt | groups/Pre-Schools Pirates/meal plan |
| lorem-big.txt | groups/Pre-Schools Pirates/meal plan |
| data.zip | groups/Teddy Bear Daycare/meal plan |
| lorem.txt | groups/Teddy Bear Daycare/meal plan |
| lorem-big.txt | groups/Teddy Bear Daycare/meal plan |
| resource | from | type |
| parent.txt | groups/Kindergarten Koalas/meal plan | file |
| lorem.txt | groups/Kindergarten Koalas/meal plan | file |
| lorem-big.txt | groups/Kindergarten Koalas/meal plan | file |
| data.zip | groups/Pre-Schools Pirates/meal plan | file |
| lorem.txt | groups/Pre-Schools Pirates/meal plan | file |
| lorem-big.txt | groups/Pre-Schools Pirates/meal plan | file |
| data.zip | groups/Teddy Bear Daycare/meal plan | file |
| lorem.txt | groups/Teddy Bear Daycare/meal plan | file |
| lorem-big.txt | groups/Teddy Bear Daycare/meal plan | file |
| meal plan | groups/Kindergarten Koalas | folder |
| meal plan | groups/Pre-Schools Pirates | folder |
| meal plan | groups/Teddy Bear Daycare | folder |
| Kindergarten Koalas | groups | folder |
| Pre-Schools Pirates | groups | folder |
| Teddy Bear Daycare | groups | folder |
| groups | | folder |
# Then what do we check for to be confident that the above things done by Alice have worked?
# Then the downloaded files should have content "abc..."
And "Alice" logs out
12 changes: 6 additions & 6 deletions tests/e2e/cucumber/features/smoke/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Feature: link
#Then the public should not see the following files on the files-drop page
# | textfile.txt |
When "Alice" downloads the following resources using the batch action
| resource | from |
| lorem.txt | folderPublic |
| textfile.txt | folderPublic |
| resource | from | type |
| lorem.txt | folderPublic | file |
| textfile.txt | folderPublic | file |
And "Alice" edits the public link named "myPublicLink" of resource "folderPublic" changing role to "editor"
And "Anonymous" refreshes the old link
And "Anonymous" downloads the following public link resources using the sidebar panel
| resource |
| lorem.txt |
| textfile.txt |
| resource | type |
| lorem.txt | file |
| textfile.txt | file |
And "Anonymous" uploads the following resources in public link page
| resource |
| new-lorem.txt |
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/cucumber/features/smoke/share.oc10.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Feature: share
| PARENT/simple.pdf | folder_to_shared | replace |
#Then "Alice" should see that the resource "folder_to_shared/simple.pdf" has 1 version
And "Brian" downloads old version of the following resource
| resource | to |
| simple.pdf | Shares/folder_to_shared |
| resource | to | type |
| simple.pdf | Shares/folder_to_shared | file |
When "Brian" restores following resources
| resource | to | version |
| simple.pdf | Shares/folder_to_shared | 1 |
Expand Down Expand Up @@ -102,8 +102,8 @@ Feature: share
| resource | to |
| Shares/testavatar.jpeg | Personal |
And "Brian" downloads the following resource using the sidebar panel
| resource | from |
| testavatar.jpeg | Shares |
| resource | from | type |
| testavatar.jpeg | Shares | file |
And "Alice" updates following sharee role
| resource | recipient | role | resourceType |
| folder_to_shared/testavatar.jpeg | Brian | editor | file |
Expand Down
66 changes: 40 additions & 26 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,21 @@ export const processDownload = async (
pageObject: any,
actionType: string
) => {
let downloads, files, parentFolder
let downloads,
files,
parentFolder,
downloadedResources = []
const downloadInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { resource, from } = stepRow

const { resource, from, type } = stepRow
const resourceInfo = {
name: resource,
type: type
}
if (!acc[from]) {
acc[from] = []
}

acc[from].push(resource)
acc[from].push(resourceInfo)

return acc
}, {})
Expand All @@ -281,37 +287,45 @@ export const processDownload = async (
parentFolder = folder !== 'undefined' ? folder : null
downloads = await pageObject.download({
folder: parentFolder,
names: files,
resources: files,
via: actionType === 'batch action' ? 'BATCH_ACTION' : 'SIDEBAR_PANEL'
})

downloads.forEach((download) => {
const { name } = path.parse(download.suggestedFilename())
downloadedResources.push(name)
})

if (actionType === 'sidebar panel') {
expect(files.length).toBe(downloads.length)
downloads.forEach((download) => {
expect(files).toContain(download.suggestedFilename())
})
for (const resource of files) {
const fileOrFolderName = path.parse(resource.name).name
if (resource.type === 'file') {
expect(downloadedResources).toContain(fileOrFolderName)
} else {
// downloading folders in oc10 downloads with name of resource but in ocis it is downloaded as 'download.tar'
config.ocis
? expect(downloadedResources).toContain('download')
: expect(downloadedResources).toContain(fileOrFolderName)
}
}
}
}

if (actionType === 'batch action') {
if (files.length === 1) {
expect(files.length).toBe(downloads.length)
downloads.forEach((download) => {
expect(files[0]).toBe(download.suggestedFilename())
})
} else {
expect(downloads.length).toBe(1)
downloads.forEach((download) => {
const { name } = path.parse(download.suggestedFilename())
if (config.ocis) {
expect(name).toBe('download')
expect(downloads.length).toBe(1)
downloads.forEach((download) => {
const { name } = path.parse(download.suggestedFilename())
if (config.ocis) {
expect(name).toBe('download')
} else {
if (parentFolder) {
expect(name).toBe(parentFolder)
} else {
if (parentFolder) {
expect(name).toBe(parentFolder)
} else {
expect(name).toBe('download')
}
expect(name).toBe('download')
}
})
}
}
})
}
}

Expand Down
47 changes: 27 additions & 20 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import path from 'path'
import { File } from '../../../types'
import { sidebar } from '../utils'

const downloadButtonSideBar = '#oc-files-actions-sidebar .oc-files-actions-download-file-trigger'
const downloadButtonBatchActionSingleFile = '.oc-files-actions-download-file-trigger'
const downloadButtonBatchActionMultiple = '.oc-files-actions-download-archive-trigger'
const downloadFileButtonSideBar =
'#oc-files-actions-sidebar .oc-files-actions-download-file-trigger'
const downloadFolderButtonSidedBar =
'#oc-files-actions-sidebar .oc-files-actions-download-archive-trigger'
const downloadButtonBatchAction = '.oc-files-actions-download-archive-trigger'
const checkBox = `//*[@data-test-resource-name="%s"]//ancestor::tr//input`
const checkBoxForTrashbin = `//*[@data-test-resource-path="%s"]//ancestor::tr//input`
export const fileRow = '//ancestor::tr'
Expand Down Expand Up @@ -242,29 +244,35 @@ export const uploadResource = async (args: uploadResourceArgs): Promise<void> =>

/**/

interface resourceArgs {
name: string
type: string
}

export interface downloadResourcesArgs {
page: Page
names: string[]
resources: resourceArgs[]
folder?: string
via: 'SIDEBAR_PANEL' | 'BATCH_ACTION'
}

export const downloadResources = async (args: downloadResourcesArgs): Promise<Download[]> => {
const { page, names, folder, via } = args
const { page, resources, folder, via } = args
const downloads = []

switch (via) {
case 'SIDEBAR_PANEL': {
if (folder) {
await clickResource({ page, path: folder })
}
for (const name of names) {
await sidebar.open({ page, resource: name })
for (const resource of resources) {
await sidebar.open({ page, resource: resource.name })
await sidebar.openPanel({ page, name: 'actions' })

const downloadResourceSelector =
resource.type === 'file' ? downloadFileButtonSideBar : downloadFolderButtonSidedBar
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadButtonSideBar).click()
page.locator(downloadResourceSelector).click()
])

await sidebar.close({ page })
Expand All @@ -275,14 +283,13 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
}

case 'BATCH_ACTION': {
await selectOrDeselectResources({ page, names, folder, select: true })
let downloadSelector = downloadButtonBatchActionMultiple
if (names.length === 1) {
downloadSelector = downloadButtonBatchActionSingleFile
await selectOrDeselectResources({ page, resources, folder, select: true })
if (resources.length === 1) {
throw new Error('Single resource cannot be downloaded with batch action')
}
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadSelector).click()
page.locator(downloadButtonBatchAction).click()
])
downloads.push(download)
break
Expand All @@ -294,32 +301,32 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do

export type selectResourcesArgs = {
page: Page
names: string[]
resources: resourceArgs[]
folder?: string
select: boolean
}

export const selectOrDeselectResources = async (args: selectResourcesArgs): Promise<void> => {
const { page, folder, names, select } = args
const { page, folder, resources, select } = args
if (folder) {
await clickResource({ page, path: folder })
}

for (const resource of names) {
for (const resource of resources) {
const exists = await resourceExists({
page,
name: resource
name: resource.name
})
if (exists) {
const resourceCheckbox = page.locator(util.format(checkBox, resource))
const resourceCheckbox = page.locator(util.format(checkBox, resource.name))

if (!(await resourceCheckbox.isChecked()) && select) {
await resourceCheckbox.check()
} else if (await resourceCheckbox.isChecked()) {
await resourceCheckbox.uncheck()
}
} else {
throw new Error(`The resource ${resource} you are trying to select does not exist`)
throw new Error(`The resource ${resource.name} you are trying to select does not exist`)
}
}
}
Expand Down