From 441600da00bd7272a493f30aa16a90001c8a65a7 Mon Sep 17 00:00:00 2001 From: Sabin Date: Thu, 22 Feb 2024 12:59:05 +0545 Subject: [PATCH] backport from master to stable --- .../smoke/app-provider/officeSuites.feature | 7 ++++ .../features/smoke/languageChange.feature | 21 ---------- tests/e2e/cucumber/steps/ui/accountMenu.ts | 14 ++++++- tests/e2e/cucumber/steps/ui/navigateByUrl.ts | 16 ++++++++ tests/e2e/support/objects/account/actions.ts | 38 +++++++++++++------ tests/e2e/support/objects/account/index.ts | 10 +++-- .../objects/app-files/resource/actions.ts | 12 ++++-- .../support/objects/url-navigation/actions.ts | 8 +++- 8 files changed, 85 insertions(+), 41 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature b/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature index c9eac15d084..2f2e6f6a5d8 100644 --- a/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature +++ b/tests/e2e/cucumber/features/smoke/app-provider/officeSuites.feature @@ -19,6 +19,10 @@ 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 | | 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" And "Alice" logs out And "Anonymous" opens the public link "Link" And "Anonymous" unlocks the public link with password "%public%" @@ -32,6 +36,9 @@ 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/languageChange.feature b/tests/e2e/cucumber/features/smoke/languageChange.feature index 4b86d2c0644..22061c3372b 100644 --- a/tests/e2e/cucumber/features/smoke/languageChange.feature +++ b/tests/e2e/cucumber/features/smoke/languageChange.feature @@ -28,24 +28,3 @@ Feature: language settings | message | | Brian Murphy hat check_message mit Ihnen geteilt | And "Alice" logs out - - - Scenario: anonymous user language change - When "Alice" logs in - And "Alice" creates the following folder in personal space using API - | name | - | folderPublic | - And "Alice" uploads the following local file into personal space using API - | localFile | to | - | filesForUpload/lorem.txt | lorem.txt | - - And "Alice" opens the "files" app - And "Alice" creates a public link creates a public link of following resource using the sidebar panel - | resource | password | - | folderPublic | %public% | - And "Alice" logs out - When "Anonymous" opens the public link "Link" - And "Anonymous" unlocks the public link with password "%public%" - And "Anonymous" opens the user menu - And "Anonymous" changes the language to "Deutsch - German" - Then "Anonymous" should see the following account page title "Konto" diff --git a/tests/e2e/cucumber/steps/ui/accountMenu.ts b/tests/e2e/cucumber/steps/ui/accountMenu.ts index 5c5314623ac..5d8e5975836 100644 --- a/tests/e2e/cucumber/steps/ui/accountMenu.ts +++ b/tests/e2e/cucumber/steps/ui/accountMenu.ts @@ -27,6 +27,7 @@ Then( When('{string} opens the user menu', async function (this: World, stepUser: string): Promise { const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const accountObject = new objects.account.Account({ page }) + await accountObject.openAccountPage() }) @@ -54,7 +55,18 @@ When( async function (this: World, stepUser: string, language: string): Promise { const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const accountObject = new objects.account.Account({ page }) - const expectedLanguage = await accountObject.changeLanguage(language) + const isAnonymousUser = stepUser === 'Anonymous' + const expectedLanguage = await accountObject.changeLanguage(language, isAnonymousUser) expect(expectedLanguage).toBe(language) } ) + +Then( + '{string} should see the following account page title {string}', + async function (this: World, stepUser: string, title: string): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const accountObject = new objects.account.Account({ page }) + const pageTitle = await accountObject.getTitle() + expect(pageTitle).toEqual(title) + } +) diff --git a/tests/e2e/cucumber/steps/ui/navigateByUrl.ts b/tests/e2e/cucumber/steps/ui/navigateByUrl.ts index 78a6c012c26..f99232059e1 100644 --- a/tests/e2e/cucumber/steps/ui/navigateByUrl.ts +++ b/tests/e2e/cucumber/steps/ui/navigateByUrl.ts @@ -28,6 +28,22 @@ When( } ) +When( + /^"([^"]*)" opens the file "([^"]*)" of space "([^"]*)" in (collabora|OnlyOffice) through the URL$/, + async function ( + this: World, + stepUser: string, + resource: string, + space: string, + editorName: 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 }) + } +) + When( '{string} opens space {string} through the URL', async function (this: World, stepUser: string, space: string): Promise { diff --git a/tests/e2e/support/objects/account/actions.ts b/tests/e2e/support/objects/account/actions.ts index 379ce0895d5..e279272cf04 100644 --- a/tests/e2e/support/objects/account/actions.ts +++ b/tests/e2e/support/objects/account/actions.ts @@ -10,6 +10,7 @@ const downloadExportButton = '[data-testid="download-export-btn"]' const languageInput = '[data-testid="language"] .vs__search' const languageValueDropDown = `.vs__dropdown-menu :text-is("%s")` const languageValue = '[data-testid="language"] .vs__selected' +const accountPageTitle = '#account-page-title' export const getQuotaValue = async (args: { page: Page }): Promise => { const { page } = args @@ -79,18 +80,33 @@ export const downloadGdprExport = async (args: { page: Page }): Promise return download.suggestedFilename() } -export const changeLanguage = async (args: { page: Page; language: string }): Promise => { - const { page, language } = args +export const changeLanguage = async (args: { + page: Page + language: string + isAnonymousUser: boolean +}): Promise => { + const { page, language, isAnonymousUser } = args await page.locator(languageInput).waitFor() + await page.locator(languageInput).click() await page.locator(languageInput).pressSequentially(language) - await Promise.all([ - page.waitForResponse( - (res) => - res.url().includes('graph/v1.0/me') && - res.request().method() === 'PATCH' && - res.status() === 200 - ), - page.locator(util.format(languageValueDropDown, language)).press('Enter') - ]) + const promises = [] + if (!isAnonymousUser) { + promises.push( + page.waitForResponse( + (res) => + res.url().includes('graph/v1.0/me') && + res.request().method() === 'PATCH' && + res.status() === 200 + ) + ) + } + promises.push(page.locator(util.format(languageValueDropDown, language)).press('Enter')) + await Promise.all(promises) + return (await page.locator(languageValue).textContent()).trim() } + +export const getTitle = (args: { page: Page }): Promise => { + const { page } = args + return page.locator(accountPageTitle).textContent() +} diff --git a/tests/e2e/support/objects/account/index.ts b/tests/e2e/support/objects/account/index.ts index 4d1a4cfe11e..406bfb67f24 100644 --- a/tests/e2e/support/objects/account/index.ts +++ b/tests/e2e/support/objects/account/index.ts @@ -17,7 +17,7 @@ export class Account { } async openAccountPage(): Promise { - await po.openAccountPage({ page: this.#page }) + await po.openAccountPage({ page: this.#page}) } async requestGdprExport(): Promise { @@ -28,7 +28,11 @@ export class Account { return po.downloadGdprExport({ page: this.#page }) } - changeLanguage(language): Promise { - return po.changeLanguage({ page: this.#page, language }) + changeLanguage(language, isAnonymousUser = false): Promise { + return po.changeLanguage({ page: this.#page, language, isAnonymousUser }) + } + + getTitle(): Promise { + return po.getTitle({ page: this.#page }) } } diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 61e324b8034..836123dd12c 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -356,12 +356,18 @@ export const openAndGetContentOfDocument = async ({ editorToOpen: string }): Promise => { await page.waitForLoadState() - await page.waitForURL('**/external/public/**') + await page.waitForURL('**/external/**') const editorMainFrame = page.frameLocator(externalEditorIframe) switch (editorToOpen) { case 'Collabora': - await editorMainFrame.locator(collaboraWelcomeModalIframe).waitFor() - await page.keyboard.press('Escape') + try { + await editorMainFrame + .locator(collaboraWelcomeModalIframe) + .waitFor({ timeout: config.minTimeout * 1000 }) + await page.keyboard.press('Escape') + } catch (e) { + console.log('No welcome modal found. Continue...') + } await editorMainFrame.locator(collaboraCanvasEditorSelector).click() break case 'OnlyOffice': diff --git a/tests/e2e/support/objects/url-navigation/actions.ts b/tests/e2e/support/objects/url-navigation/actions.ts index 5e14c0ae97a..bd779d89bb0 100644 --- a/tests/e2e/support/objects/url-navigation/actions.ts +++ b/tests/e2e/support/objects/url-navigation/actions.ts @@ -17,6 +17,7 @@ export interface openResourceViaUrlArgs { resource?: string user: User space?: string + editorName?: string } export const navigateToDetailsPanelOfResource = async ( @@ -29,9 +30,12 @@ export const navigateToDetailsPanelOfResource = async ( } export const openResourceViaUrl = async (args: openResourceViaUrlArgs) => { - const { page, resource, user, space } = args + const { page, resource, user, space, editorName } = args const fileId = await getTheFileIdOfSpaceFile(user, space, resource) - const fullUrl = `${config.backendUrl}/f/${fileId}` + + const fullUrl = editorName + ? `${config.backendUrl}/external/open-with-web/?appName=${editorName}&fileId=${fileId}` + : `${config.backendUrl}/f/${fileId}` await page.goto(fullUrl) }