Skip to content

Commit

Permalink
added step for changing language for anonymous user
Browse files Browse the repository at this point in the history
url stability. open file through Collabora (#10420)
  • Loading branch information
S-Panta committed Feb 22, 2024
1 parent c05720d commit ddb8c0f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 29 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
17 changes: 9 additions & 8 deletions tests/e2e/cucumber/steps/ui/accountMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,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)
}
'{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
36 changes: 23 additions & 13 deletions tests/e2e/support/objects/account/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +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()
const { page } = args
return page.locator(accountPageTitle).textContent()
}
6 changes: 3 additions & 3 deletions tests/e2e/support/objects/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +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 })
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 ddb8c0f

Please sign in to comment.