From 5d0bfb72c16ad35b72c8fa7682800e823f80bd67 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Tue, 6 Feb 2024 11:01:24 +0100 Subject: [PATCH] [full-ci]check file opening for mobile apps (#10442) * check file openning * fix --- .../smoke/app-provider/officeSuites.feature | 9 +---- .../smoke/app-provider/urlJourneys.feature | 34 +++++++++++++++++++ tests/e2e/cucumber/steps/ui/navigateByUrl.ts | 7 ++-- tests/e2e/support/api/external/index.ts | 1 + tests/e2e/support/api/external/openWithWeb.ts | 22 ++++++++++++ .../support/objects/url-navigation/actions.ts | 18 +++++++--- 6 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 tests/e2e/cucumber/features/smoke/app-provider/urlJourneys.feature create mode 100644 tests/e2e/support/api/external/index.ts create mode 100644 tests/e2e/support/api/external/openWithWeb.ts diff --git a/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature b/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature index 2f2e6f6a5d8..fc5d776f0bb 100644 --- a/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature +++ b/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature @@ -18,11 +18,7 @@ Feature: Integrate with online office suites like Collabora and OnlyOffice | OpenDocument.odt | OpenDocument | OpenDocument Content | And "Alice" creates a public link creates a public link of following resource using the sidebar panel | resource | role | password | - | OpenDocument.odt | Can edit | %public% | - - # Check that the file can be opened in collabora using the url. https://github.com/owncloud/web/issues/9897 - When "Alice" opens the file "OpenDocument.odt" of space "personal" in collabora through the URL - Then "Alice" should see the content "OpenDocument Content" in editor "Collabora" + | OpenDocument.odt | Can edit | %public% | And "Alice" logs out And "Anonymous" opens the public link "Link" And "Anonymous" unlocks the public link with password "%public%" @@ -36,9 +32,6 @@ Feature: Integrate with online office suites like Collabora and OnlyOffice And "Alice" creates a public link creates a public link of following resource using the sidebar panel | resource | role | password | | MicrosoftWord.docx | Can edit | %public% | - - # Check that the file can be opened in collabora using the url. https://github.com/owncloud/web/issues/9897 - When "Alice" opens the file "MicrosoftWord.docx" of space "personal" in OnlyOffice through the URL And "Alice" logs out And "Anonymous" opens the public link "Link" And "Anonymous" unlocks the public link with password "%public%" diff --git a/tests/e2e/cucumber/features/smoke/app-provider/urlJourneys.feature b/tests/e2e/cucumber/features/smoke/app-provider/urlJourneys.feature new file mode 100644 index 00000000000..1a171283daf --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/app-provider/urlJourneys.feature @@ -0,0 +1,34 @@ +Feature: url stability for mobile and desktop client + As a user + I want to work on different docs, sheets, slides etc.., using online office suites like Collabora or OnlyOffice + To make sure that the file can be opened from the mobile and desktop client + # To run this feature we need to run the external app-provider service along with wopi, OnlyOffice, Collabora services + # This is a minimal test for the integration of ocis with different online office suites like Collabora and OnlyOffice + # Check that the file can be opened in collabora or onlyoffice using the url. https://github.com/owncloud/web/issues/9897 + + + Scenario: open office suite files with Collabora and onlyOffice + Given "Admin" creates following users using API + | id | + | Alice | + And "Alice" logs in + And "Alice" creates the following files into personal space using API + | pathToFile | content | + | OpenDocument.odt | OpenDocument Content | + And "Alice" creates the following resources + | resource | type | content | + | MicrosoftWord.docx | Microsoft Word | Microsoft Word Content | + And "Alice" opens the "files" app + + # desktop feature + When "Alice" opens the file "OpenDocument.odt" of space "personal" in Collabora through the URL for desktop client + Then "Alice" should see the content "OpenDocument Content" in editor "Collabora" + When "Alice" opens the file "MicrosoftWord.docx" of space "personal" in OnlyOffice through the URL for desktop client + Then "Alice" should see the content "Microsoft Word Content" in editor "OnlyOffice" + + # mobile feature + When "Alice" opens the file "OpenDocument.odt" of space "personal" in Collabora through the URL for mobile client + Then "Alice" should see the content "OpenDocument Content" in editor "Collabora" + When "Alice" opens the file "MicrosoftWord.docx" of space "personal" in OnlyOffice through the URL for mobile client + Then "Alice" should see the content "Microsoft Word Content" in editor "OnlyOffice" + And "Alice" logs out diff --git a/tests/e2e/cucumber/steps/ui/navigateByUrl.ts b/tests/e2e/cucumber/steps/ui/navigateByUrl.ts index f99232059e1..84a06a5cdd1 100644 --- a/tests/e2e/cucumber/steps/ui/navigateByUrl.ts +++ b/tests/e2e/cucumber/steps/ui/navigateByUrl.ts @@ -29,18 +29,19 @@ When( ) When( - /^"([^"]*)" opens the file "([^"]*)" of space "([^"]*)" in (collabora|OnlyOffice) through the URL$/, + /^"([^"]*)" opens the file "([^"]*)" of space "([^"]*)" in (Collabora|OnlyOffice) through the URL for (mobile|desktop) client$/, async function ( this: World, stepUser: string, resource: string, space: string, - editorName: string + editorName: string, + client: string ): Promise { const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const user = this.usersEnvironment.getUser({ key: stepUser }) const urlNavObject = new objects.urlNavigation.URLNavigation({ page }) - await urlNavObject.openResourceViaUrl({ resource, user, space, editorName }) + await urlNavObject.openResourceViaUrl({ resource, user, space, editorName, client }) } ) diff --git a/tests/e2e/support/api/external/index.ts b/tests/e2e/support/api/external/index.ts new file mode 100644 index 00000000000..af4cc1b6c4c --- /dev/null +++ b/tests/e2e/support/api/external/index.ts @@ -0,0 +1 @@ +export * from './openWithWeb' diff --git a/tests/e2e/support/api/external/openWithWeb.ts b/tests/e2e/support/api/external/openWithWeb.ts new file mode 100644 index 00000000000..6fb87aaa293 --- /dev/null +++ b/tests/e2e/support/api/external/openWithWeb.ts @@ -0,0 +1,22 @@ +import join from 'join-path' +import { checkResponseStatus, request } from '../http' +import { User } from '../../types' + +export const getOpenWithWebUrl = async ({ + user, + fileId, + editorName +}: { + user: User + fileId: string + editorName: string +}): Promise => { + const response = await request({ + method: 'POST', + path: join('app', 'open-with-web', `?file_id=${fileId}`, `&app_name=${editorName}`), + user: user + }) + checkResponseStatus(response, 'Failed while getting url') + const respBody = await response.json() + return respBody.uri +} diff --git a/tests/e2e/support/objects/url-navigation/actions.ts b/tests/e2e/support/objects/url-navigation/actions.ts index 93c37747ce9..6ae5cdaac07 100644 --- a/tests/e2e/support/objects/url-navigation/actions.ts +++ b/tests/e2e/support/objects/url-navigation/actions.ts @@ -3,6 +3,7 @@ import { config } from '../../../config' import { getIdOfFileInsideSpace } from '../../api/davSpaces' import { User } from '../../types' import { getSpaceIdBySpaceName } from '../../api/graph' +import { getOpenWithWebUrl } from '../../api/external' export interface navigateToDetailsPanelOfResourceArgs { page: Page @@ -18,6 +19,7 @@ export interface openResourceViaUrlArgs { user: User space?: string editorName?: string + client?: string } export const navigateToDetailsPanelOfResource = async ( @@ -30,12 +32,20 @@ export const navigateToDetailsPanelOfResource = async ( } export const openResourceViaUrl = async (args: openResourceViaUrlArgs) => { - const { page, resource, user, space, editorName } = args + const { page, resource, user, space, editorName, client = '' } = args const fileId = await getTheFileIdOfSpaceFile(user, space, resource) + let fullUrl - const fullUrl = editorName - ? `${config.backendUrl}/external/open-with-web/?appName=${editorName}&fileId=${fileId}` - : `${config.backendUrl}/f/${fileId}` + switch (client) { + case 'desktop': + fullUrl = `${config.backendUrl}/external/open-with-web/?appName=${editorName}&fileId=${fileId}` + break + case 'mobile': + fullUrl = await getOpenWithWebUrl({ user, fileId, editorName }) + break + default: + fullUrl = `${config.backendUrl}/f/${fileId}` + } await page.goto(fullUrl) }