Skip to content

Commit 525b841

Browse files
adding test for flat list (#12535)
1 parent ee8ab05 commit 525b841

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

tests/e2e/cucumber/features/spaces/pagination.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ Feature: check files pagination in project space
3030
Then "Alice" should be on page "2"
3131
When "Alice" changes the items per page to "500"
3232
Then "Alice" should not see the pagination in the project space files view
33+
When "Alice" enables flat list
34+
Then "Alice" should see files being sorted in alphabetic order
3335
And "Alice" logs out

tests/e2e/cucumber/steps/ui/resources.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,25 @@ When(
406406
}
407407
)
408408

409+
When('{string} enables flat list', async function (this: World, stepUser: string): Promise<void> {
410+
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
411+
const resourceObject = new objects.applicationFiles.Resource({ page })
412+
await resourceObject.toggleFlatList()
413+
})
414+
415+
Then(
416+
'{string} should see files being sorted in alphabetic order',
417+
async function (this: World, stepUser: string): Promise<void> {
418+
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
419+
const resourceObject = new objects.applicationFiles.Resource({ page })
420+
const allFiles: string[] = await resourceObject.getAllFiles()
421+
const sortedFiles = [...allFiles].sort((a, b) =>
422+
a.localeCompare(b, 'en-us', { numeric: true, ignorePunctuation: true })
423+
)
424+
expect(allFiles).toEqual(sortedFiles)
425+
}
426+
)
427+
409428
When(
410429
'{string} switches to the tiles-view',
411430
async function (this: World, stepUser: string): Promise<void> {

tests/e2e/support/objects/app-files/resource/actions.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ const searchList =
9191
const globalSearchOptions = '#files-global-search-options'
9292
const loadingSpinner = '#files-global-search-options .loading'
9393
const filesViewOptionButton = '#files-view-options-btn'
94-
const hiddenFilesToggleButton = '//*[@data-testid="files-switch-hidden-files"]//button'
94+
const hiddenFilesToggleButton = '//*[@data-testid="files-switch-hidden-files"]/button'
95+
const flatListToggleButton = '//*[@data-testid="files-switch-flat-list"]/button'
96+
const fileNameSelector = '.oc-resource-basename'
9597
const previewImage = '//main[@id="preview"]//div[contains(@class,"stage_media")]//img'
9698
const previewAudio = '//main[@id="preview"]//div[contains(@class,"stage_media")]//audio//source'
9799
const previewVideo = '//main[@id="preview"]//div[contains(@class,"stage_media")]//video//source'
@@ -1607,6 +1609,19 @@ export const showHiddenResources = async (page: Page): Promise<void> => {
16071609
await page.locator(filesViewOptionButton).click()
16081610
}
16091611

1612+
export const toggleFlatList = async (page: Page): Promise<void> => {
1613+
await page.locator(filesViewOptionButton).click()
1614+
await page.locator(flatListToggleButton).click()
1615+
// close the files view option
1616+
await page.locator(filesViewOptionButton).click()
1617+
}
1618+
1619+
export const getAllFiles = async (page: Page): Promise<string[]> => {
1620+
await page.locator(footerTextSelector).waitFor()
1621+
const fileLocators = await page.locator(fileNameSelector).all()
1622+
return await Promise.all(fileLocators.map((locator) => locator.textContent()))
1623+
}
1624+
16101625
export interface editResourcesArgs {
16111626
page: Page
16121627
name: string

tests/e2e/support/objects/app-files/resource/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ export class Resource {
223223
await po.showHiddenResources(this.#page)
224224
}
225225

226+
async toggleFlatList(): Promise<void> {
227+
await po.toggleFlatList(this.#page)
228+
}
229+
230+
async getAllFiles(): Promise<string[]> {
231+
return po.getAllFiles(this.#page)
232+
}
233+
226234
async editResource(args: Omit<po.editResourcesArgs, 'page'>): Promise<void> {
227235
await po.editResource({ ...args, page: this.#page })
228236
}

0 commit comments

Comments
 (0)