Skip to content

Commit

Permalink
file viewer editor close step addition
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Panta committed Jul 10, 2023
1 parent 162a772 commit b1a79b4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
12 changes: 12 additions & 0 deletions tests/e2e/cucumber/features/smoke/fullTextSearch.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ Feature: Search

When "Brian" enables the option to search in file content
And "Brian" searches "Cheers" using the global search bar
Then following resources should be displayed in the files list for user "Brian"
| resource |
| textfile.txt |
| testFolder/innerTextfile.txt |
| fileToShare.txt |
| fileWithTag.txt |
| withTag.txt |
| spaceFolder/spaceTextfile.txt |
When "Brian" opens the following file in texteditor
| resource |
| textfile.txt |
And "Brian" closes the file
Then following resources should be displayed in the files list for user "Brian"
| resource |
| textfile.txt |
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/cucumber/features/smoke/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ Feature: share
And "Brian" opens the following file in mediaviewer
| resource |
| testavatar.jpeg |
And "Brian" closes the file
And "Brian" opens the following file in pdfviewer
| resource |
| simple.pdf |
And "Brian" closes the file
And "Alice" removes following sharee
| resource | recipient |
| shareToBrian.txt | Brian |
Expand Down
13 changes: 10 additions & 3 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ When(
)

When(
/^"([^"].*)" opens the following file(?:s)? in (mediaviewer|pdfviewer)$/,
/^"([^"].*)" opens the following file(?:s)? in (mediaviewer|pdfviewer|texteditor)$/,
async function (this: World, stepUser: string, actionType: string, stepTable: DataTable) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })

for (const info of stepTable.hashes()) {
await resourceObject.openFileInViewer({
await resourceObject.openFile({
name: info.resource,
actionType: actionType as 'mediaviewer' | 'pdfviewer'
actionType: actionType as 'mediaviewer' | 'pdfviewer' | 'texteditor'
})
}
}
Expand Down Expand Up @@ -638,3 +638,10 @@ When(
await resourceObject.uploadLargeNumberOfResources({ resources: files })
}
)

When('{string} closes the file', async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })

await resourceObject.closeFile()
})
14 changes: 8 additions & 6 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const checkBoxForTrashbin = `//*[@data-test-resource-path="%s"]//ancestor::tr//i
export const fileRow =
'//ancestor::*[(contains(@class, "oc-tile-card") or contains(@class, "oc-tbody-tr"))]'
export const resourceNameSelector =
':is(#files-space-table, .oc-tiles-item, #files-shared-with-me-accepted-section) [data-test-resource-name="%s"]'
':is(#files-space-table, .oc-tiles-item, #files-shared-with-me-accepted-section, .files-table) [data-test-resource-name="%s"]'
const breadcrumbResourceNameSelector =
'//span[contains(@class, "oc-breadcrumb-item-text") and text()="%s"]'
const addNewResourceButton = `#new-file-menu-btn`
Expand Down Expand Up @@ -1110,13 +1110,13 @@ export const removeTagsFromResource = async (args: resourceTagsArgs): Promise<vo
await sidebar.close({ page })
}

export interface openFileInViewerArgs {
export interface openFileArgs {
page: Page
name: string
actionType: 'mediaviewer' | 'pdfviewer'
actionType: 'mediaviewer' | 'pdfviewer' | 'texteditor'
}

export const openFileInViewer = async (args: openFileInViewerArgs): Promise<void> => {
export const openFile = async (args: openFileArgs): Promise<void> => {
const { page, name, actionType } = args

if (actionType === 'mediaviewer') {
Expand All @@ -1140,8 +1140,6 @@ export const openFileInViewer = async (args: openFileInViewerArgs): Promise<void
page.locator(util.format(resourceNameSelector, name)).click()
])
}

await editor.close(page)
}

export const checkThatFileVersionIsNotAvailable = async (
Expand Down Expand Up @@ -1224,3 +1222,7 @@ export const countNumberOfResourcesInThePage = ({ page }): Promise<number> => {
export const expectPageNumberNotToBeVisible = async ({ page }): Promise<void> => {
await expect(page.locator(filesPaginationNavSelector)).not.toBeVisible()
}

export const closeFile = async ({ page }): Promise<void> => {
await editor.close(page)
}
8 changes: 6 additions & 2 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class Resource {
await po.editResources({ ...args, page: this.#page })
}

async openFileInViewer(args: Omit<po.openFileInViewerArgs, 'page'>): Promise<void> {
await po.openFileInViewer({ ...args, page: this.#page })
async openFile(args: Omit<po.openFileArgs, 'page'>): Promise<void> {
await po.openFile({ ...args, page: this.#page })
}

async addTags(args: Omit<po.resourceTagsArgs, 'page'>): Promise<void> {
Expand Down Expand Up @@ -256,4 +256,8 @@ export class Resource {
async expectPageNumberNotToBeVisible(): Promise<void> {
await po.expectPageNumberNotToBeVisible({ page: this.#page })
}

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

0 comments on commit b1a79b4

Please sign in to comment.