diff --git a/.drone.star b/.drone.star index c8e3d74dd5b..cedbf40dc92 100644 --- a/.drone.star +++ b/.drone.star @@ -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" diff --git a/tests/e2e/cucumber/features/app-provider/officeSuites.feature b/tests/e2e/cucumber/features/app-provider/officeSuites.feature index 0790ec599a8..fa8af8a889a 100644 --- a/tests/e2e/cucumber/features/app-provider/officeSuites.feature +++ b/tests/e2e/cucumber/features/app-provider/officeSuites.feature @@ -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 diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index de33b1d9dbd..8adbebac30c 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -376,7 +376,7 @@ Then( ) When( - '{string} opens folder {string}', + '{string} opens file/folder {string}', async function (this: World, stepUser: string, resource: string): Promise { const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const resourceObject = new objects.applicationFiles.Resource({ page }) @@ -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 { + 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 { + 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) { diff --git a/tests/e2e/filesForUpload/Template.dotx b/tests/e2e/filesForUpload/Template.dotx new file mode 100644 index 00000000000..937452507d8 Binary files /dev/null and b/tests/e2e/filesForUpload/Template.dotx differ diff --git a/tests/e2e/filesForUpload/Template.ott b/tests/e2e/filesForUpload/Template.ott new file mode 100644 index 00000000000..3445aaa1d95 Binary files /dev/null and b/tests/e2e/filesForUpload/Template.ott differ diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 0f4bc725ea2..372cf30db7d 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -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' @@ -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, @@ -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 => { + 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 => { + 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, diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index bcf4935cb63..74a6dd52c2d 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -364,4 +364,12 @@ export class Resource { async checkEmptyActivity({ resource }: { resource: string }): Promise { await po.checkEmptyActivity({ page: this.#page, resource }) } + + async openTemplateFile(resource: string, actionName: string): Promise { + await po.openTemplateFile({ page: this.#page, resource, webOffice: actionName }) + } + + async createFileFromTemplate(resource: string, webOffice: string, via: string): Promise { + await po.createFileFromTemplate({ page: this.#page, resource, webOffice, via }) + } }