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 22, 2024
1 parent 1c75970 commit 92ade6b
Show file tree
Hide file tree
Showing 7 changed files with 79 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
46 changes: 46 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,49 @@ 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 a office documents from 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" using the sidebar panel via "OnlyOffice"
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" using the sidebar panel via "Collabora"
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.dotx |
| Template.odt |
| Template.docx |

When "Alice" creates a file from template file "Template.ott" using the sidebar panel via "Collabora"
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.dotx |
| Template.odt |
| Template.docx |
| Template (1).odt |

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 (2).odt |

And "Alice" logs out
11 changes: 10 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,15 @@ When(
}
)

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

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.
19 changes: 18 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 Down Expand Up @@ -1777,6 +1777,23 @@ export const previewMediaFromSidebarPanel = async ({
await page.locator(util.format(sideBarActionButton, 'Preview')).first().click()
}

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

export const checkThatFileVersionIsNotAvailable = async (
args: resourceVersionArgs
): Promise<void> => {
Expand Down
4 changes: 4 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,8 @@ export class Resource {
async checkEmptyActivity({ resource }: { resource: string }): Promise<void> {
await po.checkEmptyActivity({ page: this.#page, resource })
}

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

0 comments on commit 92ade6b

Please sign in to comment.