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 25, 2024
1 parent 4ade5be commit a7b1d94
Show file tree
Hide file tree
Showing 7 changed files with 108 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
39 changes: 39 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,42 @@ 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

When "Alice" opens file "Template.ott"
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 (1).docx |
| Template (1).odt |

When "Alice" opens file "Template.ott" via "Collabora" using the context menu
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
29 changes: 28 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,33 @@ When(
}
)

When(
'{string} creates a file from template file {string} via {string} using the sidebar panel',
async function (this: World, stepUser: string, file: string, webOffice: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.createFileFromTemplateFromSidebarPanel(file, webOffice)
}
)

When(
'{string} creates a file from template file {string} via {string} using the context menu',
async function (this: World, stepUser: string, file: string, webOffice: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
await resourceObject.createFileFromTemplate(file, `Create from template via ${webOffice}`)
}
)

When(
'{string} opens 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.createFileFromTemplate(file, `Open in ${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.
33 changes: 32 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,19 @@ export const createSpaceFromFolder = async ({
return (await response.json()) as Space
}

export const createDocumentFromTemplate = async ({
page,
resource,
actionName
}: {
page: Page
resource: string
actionName: string
}): Promise<void> => {
await page.locator(util.format(resourceNameSelector, resource)).click({ button: 'right' })
await page.locator(util.format(contextmenuAction, actionName)).click()
}

export const createSpaceFromSelection = async ({
page,
resources,
Expand Down Expand Up @@ -1777,6 +1791,23 @@ export const previewMediaFromSidebarPanel = async ({
await page.locator(util.format(sideBarActionButton, 'Preview')).first().click()
}

export const createFileFromTemplate = async ({
page,
resource,
webOffice
}: {
page: Page
resource: string
webOffice: string
}): Promise<void> => {
await sidebar.open({ page, resource })
await sidebar.openPanel({ page, name: 'actions' })
await page
.locator(util.format(sideBarActionButton, `Create from template via ${webOffice}`))
.first()
.click()
}

export const checkThatFileVersionIsNotAvailable = async (
args: resourceVersionArgs
): Promise<void> => {
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 createFileFromTemplateFromSidebarPanel(resource: string, webOffice: string): Promise<void> {
await po.createFileFromTemplate({ page: this.#page, resource, webOffice })
}

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

0 comments on commit a7b1d94

Please sign in to comment.