Skip to content

Commit

Permalink
backport from master to stable
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Panta committed Feb 26, 2024
1 parent b21f3bb commit 441600d
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand All @@ -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%"
Expand Down
21 changes: 0 additions & 21 deletions tests/e2e/cucumber/features/smoke/languageChange.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 13 additions & 1 deletion tests/e2e/cucumber/steps/ui/accountMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Then(
When('{string} opens the user menu', async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })

await accountObject.openAccountPage()
})

Expand Down Expand Up @@ -54,7 +55,18 @@ When(
async function (this: World, stepUser: string, language: string): Promise<void> {
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<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
const pageTitle = await accountObject.getTitle()
expect(pageTitle).toEqual(title)
}
)
16 changes: 16 additions & 0 deletions tests/e2e/cucumber/steps/ui/navigateByUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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<void> {
Expand Down
38 changes: 27 additions & 11 deletions tests/e2e/support/objects/account/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
const { page } = args
Expand Down Expand Up @@ -79,18 +80,33 @@ export const downloadGdprExport = async (args: { page: Page }): Promise<string>
return download.suggestedFilename()
}

export const changeLanguage = async (args: { page: Page; language: string }): Promise<string> => {
const { page, language } = args
export const changeLanguage = async (args: {
page: Page
language: string
isAnonymousUser: boolean
}): Promise<string> => {
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<string> => {
const { page } = args
return page.locator(accountPageTitle).textContent()
}
10 changes: 7 additions & 3 deletions tests/e2e/support/objects/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Account {
}

async openAccountPage(): Promise<void> {
await po.openAccountPage({ page: this.#page })
await po.openAccountPage({ page: this.#page})
}

async requestGdprExport(): Promise<void> {
Expand All @@ -28,7 +28,11 @@ export class Account {
return po.downloadGdprExport({ page: this.#page })
}

changeLanguage(language): Promise<string> {
return po.changeLanguage({ page: this.#page, language })
changeLanguage(language, isAnonymousUser = false): Promise<string> {
return po.changeLanguage({ page: this.#page, language, isAnonymousUser })
}

getTitle(): Promise<string> {
return po.getTitle({ page: this.#page })
}
}
12 changes: 9 additions & 3 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,18 @@ export const openAndGetContentOfDocument = async ({
editorToOpen: string
}): Promise<string> => {
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':
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/support/objects/url-navigation/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface openResourceViaUrlArgs {
resource?: string
user: User
space?: string
editorName?: string
}

export const navigateToDetailsPanelOfResource = async (
Expand All @@ -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)
}

Expand Down

0 comments on commit 441600d

Please sign in to comment.