Skip to content

Commit

Permalink
adding test for creating office documents from template files
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajacharya2 committed Nov 28, 2024
1 parent 1d071ce commit 2eee305
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ALPINE_GIT = "alpine/git:latest"
APACHE_TIKA = "apache/tika:2.8.0.0"
COLLABORA_CODE = "collabora/code:24.04.5.1.1"
COLLABORA_CODE = "collabora/code:24.04.9.2.1"
CS3ORG_WOPI_SERVER = "cs3org/wopiserver:v10.3.0"
KEYCLOAK = "quay.io/keycloak/keycloak:25.0.0"
MINIO_MC = "minio/mc:RELEASE.2021-10-07T04-19-58Z"
Expand Down
35 changes: 35 additions & 0 deletions tests/e2e/cucumber/features/app-provider/officeSuites.feature
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,38 @@ Feature: Integrate with online office suites like Collabora and OnlyOffice
| usingFolderLink.odt |
Then "Alice" should see the content "OpenDocument Content" in editor "Collabora"
And "Alice" logs out


Scenario: create files from office templates
Given "Alice" uploads the following local file into personal space using API
| localFile | to |
| Template.dotx | Template.dotx |
| Template.ott | Template.ott |

When "Alice" creates a file from template file "Template.dotx" via "OnlyOffice" using the sidebar panel
Then "Alice" should see the content "As a user I want to create a document by clicking on a template file" in editor "OnlyOffice"
And "Alice" closes the file viewer

When "Alice" creates a file from template file "Template.ott" via "Collabora" using the context menu
Then "Alice" should see the content "As a user I want to create a document by clicking on a template file" in editor "Collabora"
And "Alice" closes the file viewer
And following resources should be displayed in the files list for user "Alice"
| resource |
| Template.odt |
| Template.docx |

When "Alice" opens file "Template.dotx"
Then "Alice" should see the content "As a user I want to create a document by clicking on a template file" in editor "OnlyOffice"
And "Alice" closes the file viewer
And following resources should be displayed in the files list for user "Alice"
| resource |
| Template (1).docx |

When "Alice" opens template file "Template.ott" via "Collabora" using the context menu
Then "Alice" should see the content "As a user I want to create a document by clicking on a template file" in editor "Collabora"
And "Alice" closes the file viewer
Then following resources should not be displayed in the files list for user "Alice"
| resource |
| Template (2).docx |

And "Alice" logs out
26 changes: 25 additions & 1 deletion tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ Then(
)

When(
'{string} opens folder {string}',
'{string} opens file/folder {string}',
async function (this: World, stepUser: string, resource: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
Expand Down Expand Up @@ -635,6 +635,30 @@ When(
}
)

When(
/^"([^"].*)" creates a file from template file "([^"].*)" via "([^"].*)" using the (sidebar panel|context menu)$/,
async function (
this: World,
stepUser: string,
file: string,
webOffice: string,
via: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.createFileFromTemplate(file, webOffice, via)
}
)

When(
'{string} opens template file {string} via {string} using the context menu',
async function (this: World, stepUser: any, file: any, webOffice: any): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.openTemplateFile(file, webOffice)
}
)

When(
'{string} creates space {string} from folder {string} using the context menu',
async function (this: World, stepUser: string, spaceName: string, folderName: string) {
Expand Down
Binary file added tests/e2e/filesForUpload/Template.dotx
Binary file not shown.
Binary file added tests/e2e/filesForUpload/Template.ott
Binary file not shown.
41 changes: 40 additions & 1 deletion tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const sideBarActions =

// online office locators
// Collabora
const collaboraDocPermissionModeSelector = '#PermissionMode'
const collaboraDocPermissionModeSelector = '#permissionmode-container'
const collaboraEditorSaveSelector = '.notebookbar-shortcuts-bar #save'
const collaboraDocTextAreaSelector = '#clipboard-area'
const collaboraWelcomeModalIframe = '.iframe-welcome-modal'
Expand All @@ -138,6 +138,7 @@ const fileIconWrapper = '#oc-file-details-sidebar .details-icon-wrapper'
const fileIconPreview = '#oc-file-details-sidebar .details-preview'
const activitySidebarPanel = 'sidebar-panel-activities'
const activitySidebarPanelBodyContent = '#sidebar-panel-activities .sidebar-panel__body-content'
const contextMenuAction = '//*[@id="oc-files-context-actions-context"]//span[text()="%s"]'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -226,6 +227,44 @@ export const createSpaceFromFolder = async ({
return (await response.json()) as Space
}

export const openTemplateFile = async ({
page,
resource,
webOffice
}: {
page: Page
resource: string
webOffice: string
}): Promise<void> => {
await page.locator(util.format(resourceNameSelector, resource)).click({ button: 'right' })
await page.locator(util.format(contextMenuAction, `Open in ${webOffice}`)).click()
}

export const createFileFromTemplate = async ({
page,
resource,
webOffice,
via
}: {
page: Page
resource: string
webOffice: string
via: string
}): Promise<void> => {
const menuItem = `Create from template via ${webOffice}`
if (via.startsWith('sidebar')) {
await sidebar.open({ page, resource })
await sidebar.openPanel({ page, name: 'actions' })
await page.locator(util.format(sideBarActionButton, menuItem)).click()
return
} else if (via.startsWith('context')) {
await page.locator(util.format(resourceNameSelector, resource)).click({ button: 'right' })
await page.locator(util.format(contextMenuAction, menuItem)).click()
return
}
throw new Error(`Invalid action '${via}' was provided`)
}

export const createSpaceFromSelection = async ({
page,
resources,
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,12 @@ export class Resource {
async checkEmptyActivity({ resource }: { resource: string }): Promise<void> {
await po.checkEmptyActivity({ page: this.#page, resource })
}

async openTemplateFile(resource: string, actionName: string): Promise<void> {
await po.openTemplateFile({ page: this.#page, resource, webOffice: actionName })
}

async createFileFromTemplate(resource: string, webOffice: string, via: string): Promise<void> {
await po.createFileFromTemplate({ page: this.#page, resource, webOffice, via })
}
}

0 comments on commit 2eee305

Please sign in to comment.