Skip to content

Commit

Permalink
[tests-only]Add tests for pagination in personal space (#9008)
Browse files Browse the repository at this point in the history
* Add tests for pagination presonal space

* set skeleton to emply for tests

* remove the reduntant config

* add logout step

* address reviews

* address reviews
  • Loading branch information
SwikritiT authored May 15, 2023
1 parent 82d4380 commit b5d75e9
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 5 deletions.
1 change: 1 addition & 0 deletions dev/docker/oc10.entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ then
true
occ config:system:set trusted_domains 0 --value="localhost"
occ config:system:set cors.allowed-domains 0 --value="http://localhost:9100"
occ config:system:set skeletondirectory --value=''
fi

if [ -d /var/www/owncloud/apps/web/ ]
Expand Down
3 changes: 1 addition & 2 deletions tests/drone/setup-server-and-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ else
then
php occ config:system:set web.baseUrl --value="http://owncloud/index.php/apps/web"
php occ config:system:set enable_previews --type=boolean --value=false
php occ config:system:set skeletondirectory --value=''
else
php occ config:system:set web.baseUrl --value="http://web"
php occ config:system:set cors.allowed-domains 0 --value=http://web
fi
php occ config:system:set sharing.federation.allowHttpFallback --value=true --type=bool
php occ config:system:set web.rewriteLinks --value=true
# Remove when https://github.com/owncloud/core/pull/40024 is merged and released
php occ config:system:set cors.allowed-headers --type json --value '["cache-control"]'
fi
24 changes: 24 additions & 0 deletions tests/e2e/cucumber/features/smoke/personalSpacePagination.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: check files pagination in personal space
As a user
I want to navigate a large number of files using pagination
So that I do not have to scroll deep down

Scenario: pagination
Given "Admin" creates following user using API
| id |
| Alice |
And "Alice" creates 55 folders in personal space using API
And "Alice" creates 55 files in personal space using API
And "Alice" creates the following files into personal space using API
| pathToFile | content |
| .hidden-testFile.txt | This is a hidden file. |
And "Alice" logs in
And "Alice" opens the "files" app
When "Alice" navigates to page "2" of the personal space files view
Then "Alice" should see the text "111 items with 1 kB in total (56 files, 55 folders)" at the footer of the page
And "Alice" should see 10 resources in the personal space files view
When "Alice" enables the option to display the hidden file
Then "Alice" should see 11 resources in the personal space files view
When "Alice" changes the items per page to "500"
Then "Alice" should not see the pagination in the personal space files view
And "Alice" logs out
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Feature: spaces.personal
And "Alice" uploads the following resource
| resource | to | option |
| PARENT/simple.pdf | folder_to_shared | replace |
When "Brian" should not see the version of the file
And "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
Expand Down
24 changes: 24 additions & 0 deletions tests/e2e/cucumber/steps/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ Given(
}
)

Given(
'{string} creates {int} folder(s) in personal space using API',
async function (this: World, stepUser: string, numberOfFolders: number): Promise<void> {
const user = this.usersEnvironment.getUser({ key: stepUser })
for (let i = 1; i <= numberOfFolders; i++) {
await api.dav.createFolderInsidePersonalSpace({ user, folder: `testFolder${i}` })
}
}
)

Given(
'{string} shares the following resource using API',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
Expand Down Expand Up @@ -146,6 +156,20 @@ Given(
}
)

Given(
'{string} creates {int} file(s) in personal space using API',
async function (this: World, stepUser: string, numberOfFiles: number): Promise<void> {
const user = this.usersEnvironment.getUser({ key: stepUser })
for (let i = 1; i <= numberOfFiles; i++) {
await api.dav.uploadFileInPersonalSpace({
user,
pathToFile: `testfile${i}.txt`,
content: `This is a test file${i}`
})
}
}
)

Given(
'{string} uploads the following local file(s) into personal space using API',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
Expand Down
49 changes: 48 additions & 1 deletion tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ When(
}
)

When(
Then(
'{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 })
Expand All @@ -542,3 +542,50 @@ When(
}
}
)

When(
'{string} navigates to page {string} of the personal space files view',
async function (this: World, stepUser: string, pageNumber: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.changePagePersonalSpace({ pageNumber })
}
)

When(
'{string} changes the items per page to {string}',
async function (this: World, stepUser: string, itemsPerPage: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.changeItemsPerPage({ itemsPerPage })
}
)

Then(
'{string} should see the text {string} at the footer of the page',
async function (this: World, stepUser: string, expectedText: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const actualText = await resourceObject.getFileListFooterText()
await expect(actualText).toBe(expectedText)
}
)

Then(
'{string} should see {int} resources in the personal space files view',
async function (this: World, stepUser: string, expectedNumberOfResources: number) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const actualNumberOfResources = await resourceObject.getNumberOfResourcesInThePage()
await expect(actualNumberOfResources).toBe(expectedNumberOfResources)
}
)

Then(
'{string} should not see the pagination in the personal space files view',
async function (this: World, stepUser: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.expectPageNumberNotToBeVisible()
}
)
44 changes: 44 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ const tagFormInput = '#tags-form input'
const compareDialogConfirmBtn = '.compare-save-dialog-confirm-btn'
const resourcesAsTiles = '#files-view .oc-tiles'
const fileVersionSidebar = '#oc-file-versions-sidebar'
const listItemPageSelector = '//*[contains(@class,"oc-pagination-list-item-page") and text()="%s"]'
const itemsPerPageDropDownOptionSelector =
'//li[contains(@class,"vs__dropdown-option") and text()="%s"]'
const footerTextSelector = '//*[@data-testid="files-list-footer-info"]'
const filesTableResourcesDetailsSelector =
'//td[contains(@class,"oc-table-data-cell-name")]//div//div[contains(@class,"oc-resource-details")]'
const itemsPerPageDropDownSelector = '.vs__actions'
const filesPaginationNavSelector = '.files-pagination'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -934,6 +942,8 @@ export const expectThatResourcesAreTiles = async (args): Promise<void> => {
export const showHiddenResources = async (page): Promise<void> => {
await page.locator(filesViewOptionButton).click()
await page.locator(hiddenFilesToggleButton).click()
// close the files view option
await page.locator(filesViewOptionButton).click()
}

export interface editResourcesArgs {
Expand Down Expand Up @@ -1058,3 +1068,37 @@ export const checkThatFileVersionIsNotAvailable = async (
await sidebar.openPanel({ page, name: 'versions' })
await expect(page.locator(fileVersionSidebar)).toHaveText('No Versions available for this file')
}

export interface changePageArgs {
page: Page
pageNumber: string
}
export const changePagePersonalSpace = async (args: changePageArgs): Promise<void> => {
const { page, pageNumber } = args
await page.locator(util.format(listItemPageSelector, pageNumber)).click()
}

export interface changeItemsPerPageArgs {
page: Page
itemsPerPage: string
}
export const changeItemsPerPage = async (args: changeItemsPerPageArgs): Promise<void> => {
const { page, itemsPerPage } = args
await page.locator(filesViewOptionButton).click()
await page.locator(itemsPerPageDropDownSelector).click()
await page.locator(util.format(itemsPerPageDropDownOptionSelector, itemsPerPage)).click()
// close the files view option
await page.locator(filesViewOptionButton).click()
}

export const getFileListFooterText = ({ page }): Promise<string> => {
return page.locator(footerTextSelector).textContent()
}

export const getNumberOfResourcesInThePage = ({ page }): Promise<string> => {
return page.locator(filesTableResourcesDetailsSelector).count()
}

export const expectPageNumberNotToBeVisible = async ({ page }): Promise<void> => {
await expect(page.locator(filesPaginationNavSelector)).not.toBeVisible()
}
29 changes: 28 additions & 1 deletion tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ import {
createSpaceFromFolderArgs,
createSpaceFromSelection,
createSpaceFromSelectionArgs,
checkThatFileVersionIsNotAvailable
checkThatFileVersionIsNotAvailable,
changePageArgs,
changePagePersonalSpace,
getFileListFooterText,
getNumberOfResourcesInThePage,
changeItemsPerPage,
changeItemsPerPageArgs,
expectPageNumberNotToBeVisible
} from './actions'
import { Space } from '../../../types'

Expand Down Expand Up @@ -245,4 +252,24 @@ export class Resource {
await checkThatFileVersionIsNotAvailable({ ...args, page: this.#page })
await this.#page.goto(startUrl)
}

async changePagePersonalSpace(args: Omit<changePageArgs, 'page'>): Promise<void> {
await changePagePersonalSpace({ ...args, page: this.#page })
}

async changeItemsPerPage(args: Omit<changeItemsPerPageArgs, 'page'>): Promise<void> {
await changeItemsPerPage({ ...args, page: this.#page })
}

getFileListFooterText(): Promise<string> {
return getFileListFooterText({ page: this.#page })
}

getNumberOfResourcesInThePage(): Promise<string> {
return getNumberOfResourcesInThePage({ page: this.#page })
}

async expectPageNumberNotToBeVisible(): Promise<void> {
await expectPageNumberNotToBeVisible({ page: this.#page })
}
}

0 comments on commit b5d75e9

Please sign in to comment.