diff --git a/web/tests/e2e/environment/constants.ts b/web/tests/e2e/environment/constants.ts index aef2451b3f0..63bd16b1dd0 100644 --- a/web/tests/e2e/environment/constants.ts +++ b/web/tests/e2e/environment/constants.ts @@ -40,6 +40,7 @@ export const searchFilter = { export const resourcePage = { searchList: 'search list', filesList: 'files list', + searchResultsList: 'search results list', shares: 'Shares', trashbin: 'trashbin' } as const diff --git a/web/tests/e2e/specs/app-provider/secureView.spec.ts b/web/tests/e2e/specs/app-provider/secureView.spec.ts index 2ab775613b3..4511ea5f82f 100644 --- a/web/tests/e2e/specs/app-provider/secureView.spec.ts +++ b/web/tests/e2e/specs/app-provider/secureView.spec.ts @@ -3,7 +3,7 @@ import { test } from '../../environment/test' import * as api from '../../steps/api/api' import * as ui from '../../steps/ui/index' -import { searchScope, application, fileAction } from '../../environment/constants' +import { searchScope, application, fileAction, resourcePage } from '../../environment/constants' test.describe('Secure view', { tag: '@predefined-users' }, () => { test.beforeEach(async () => { @@ -362,7 +362,7 @@ test.describe('Secure view', { tag: '@predefined-users' }, () => { // | secure.pdf | // | secureDocument.odt | await ui.userShouldSeeResources({ - listType: 'files list', + listType: resourcePage.searchResultsList, stepUser: 'Brian', resources: ['secureFile.txt', 'securePhoto.jpeg', 'secure.pdf', 'secureDocument.odt'] }) diff --git a/web/tests/e2e/specs/app-provider/wopiReadOnly.spec.ts b/web/tests/e2e/specs/app-provider/wopiReadOnly.spec.ts index 6e9c2ff59a4..0229be1857d 100644 --- a/web/tests/e2e/specs/app-provider/wopiReadOnly.spec.ts +++ b/web/tests/e2e/specs/app-provider/wopiReadOnly.spec.ts @@ -40,13 +40,6 @@ test.describe('WOPI CheckFileInfo: ReadOnly', { tag: '@predefined-users' }, () = stepUser: 'Alice', resources: [{ name: suite.file, type: suite.type, content: 'owner edited content' }] }) - await ui.userClosesFileViewer({ stepUser: 'Alice' }) - await ui.resourceShouldNotBeLockedForUser({ stepUser: 'Alice', resource: suite.file }) - await ui.userOpensResourceInViewer({ - stepUser: 'Alice', - resource: suite.file, - viewer: suite.viewer - }) await ui.userShouldSeeContentInEditor({ stepUser: 'Alice', expectedContent: 'owner edited content', diff --git a/web/tests/e2e/specs/app-provider/wopiVersionAndLastModifiedTime.spec.ts b/web/tests/e2e/specs/app-provider/wopiVersionAndLastModifiedTime.spec.ts index 1f017c43cea..a8fd95da03c 100644 --- a/web/tests/e2e/specs/app-provider/wopiVersionAndLastModifiedTime.spec.ts +++ b/web/tests/e2e/specs/app-provider/wopiVersionAndLastModifiedTime.spec.ts @@ -57,20 +57,12 @@ test.describe( stepUser: 'Alice', resources: [{ name: suite.file, type: suite.type, content: 'edited content v2' }] }) - await ui.userClosesFileViewer({ stepUser: 'Alice' }) - await ui.resourceShouldNotBeLockedForUser({ stepUser: 'Alice', resource: suite.file }) - await ui.userOpensResourceInViewer({ - stepUser: 'Alice', - resource: suite.file, - viewer: suite.viewer - }) await ui.userShouldSeeContentInEditor({ stepUser: 'Alice', expectedContent: 'edited content v2', editor: suite.name }) await ui.userClosesFileViewer({ stepUser: 'Alice' }) - await ui.resourceShouldNotBeLockedForUser({ stepUser: 'Alice', resource: suite.file }) await ui.userLogsIn({ stepUser: 'Brian' }) await ui.userNavigatesToSharedWithMePage({ stepUser: 'Brian' }) diff --git a/web/tests/e2e/steps/ui/resources.ts b/web/tests/e2e/steps/ui/resources.ts index c8759c8b9e2..b087283f8b6 100644 --- a/web/tests/e2e/steps/ui/resources.ts +++ b/web/tests/e2e/steps/ui/resources.ts @@ -232,6 +232,7 @@ export async function userShouldSeeResources({ listType: | typeof resourcePage.searchList | typeof resourcePage.filesList + | typeof resourcePage.searchResultsList | typeof resourcePage.shares | typeof resourcePage.trashbin stepUser: string @@ -241,9 +242,11 @@ export async function userShouldSeeResources({ const { page } = world.actorsEnvironment.getActor({ key: stepUser }) const resourceObject = new objects.applicationFiles.Resource({ page }) - // search list waits longer for tika full-text indexing; other lists only need UI render time + // both search-derived lists wait longer for tika full-text indexing and re-issue the search + // each poll; other lists only need UI render time and read the DOM as-is const isSearchList = listType === resourcePage.searchList - const timeout = isSearchList ? 30000 : 10000 + const isSearchResultsList = listType === resourcePage.searchResultsList + const timeout = isSearchList || isSearchResultsList ? 30000 : 10000 for (const resource of resources) { await expect @@ -251,10 +254,16 @@ export async function userShouldSeeResources({ async () => { // the global search dropdown is a one-shot query, so for the search list we // re-issue the search each poll to pick up resources that finish indexing after - // the initial query instead of repeatedly reading a stale result list - const actualList = isSearchList - ? await resourceObject.reSearchAndGetDisplayedResources() - : await resourceObject.getDisplayedResources({ keyword: listType }) + // files list showing search results (after pressing Enter) has the same problem, so + // it re-issues the search too (via reload) rather than reading the plain files list + let actualList: string[] + if (isSearchList) { + actualList = await resourceObject.reSearchAndGetDisplayedResources() + } else if (isSearchResultsList) { + actualList = await resourceObject.reSearchAndGetDisplayedResourcesFromFilesList() + } else { + actualList = await resourceObject.getDisplayedResources({ keyword: listType }) + } return actualList.includes(resource) }, { diff --git a/web/tests/e2e/support/objects/app-files/resource/actions.ts b/web/tests/e2e/support/objects/app-files/resource/actions.ts index 603ffb0f94a..3404c3c46db 100644 --- a/web/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/web/tests/e2e/support/objects/app-files/resource/actions.ts @@ -1991,6 +1991,19 @@ export const reSearchAndGetDisplayedResourcesFromSearch = async (page: Page): Pr return getDisplayedResourcesFromSearch(page) } +// The full-page files list rendered after pressing Enter on a global search is populated from +// the same one-shot backend query as the dropdown, so it's subject to the same tika indexing +// lag - but nothing here spontaneously re-fetches, so simply waiting/polling longer can never +// pick up a resource that wasn't indexed yet when the query ran. reload() re-issues the same +// search against the current (search-results) URL, the same technique searchResourceGlobalSearch +// already relies on to let indexing catch up before a search is even run. +export const reSearchAndGetDisplayedResourcesFromFilesList = async ( + page: Page +): Promise => { + await page.reload() + return getDisplayedResourcesFromFilesList(page) +} + export const getDisplayedResourcesFromFilesList = async (page: Page): Promise => { // wait for tika indexing await new Promise((resolve) => setTimeout(resolve, 1000)) diff --git a/web/tests/e2e/support/objects/app-files/resource/index.ts b/web/tests/e2e/support/objects/app-files/resource/index.ts index 8f2122b7ff8..e869881bbde 100644 --- a/web/tests/e2e/support/objects/app-files/resource/index.ts +++ b/web/tests/e2e/support/objects/app-files/resource/index.ts @@ -195,6 +195,12 @@ export class Resource { return po.reSearchAndGetDisplayedResourcesFromSearch(this.#page) } + // same as reSearchAndGetDisplayedResources, but for global-search results rendered into the + // full-page files list (after pressing Enter) rather than the search dropdown + reSearchAndGetDisplayedResourcesFromFilesList(): Promise { + return po.reSearchAndGetDisplayedResourcesFromFilesList(this.#page) + } + getDisplayedResources(args: Omit): Promise { switch (args.keyword) { case resourcePage.filesList: diff --git a/web/tests/e2e/support/objects/app-files/resource/webOffice.ts b/web/tests/e2e/support/objects/app-files/resource/webOffice.ts index 17179dd26d2..349b18b03c0 100644 --- a/web/tests/e2e/support/objects/app-files/resource/webOffice.ts +++ b/web/tests/e2e/support/objects/app-files/resource/webOffice.ts @@ -55,6 +55,10 @@ export const focusOnlyOfficeEditor = async (page: Page): Promise => { } export const getOfficeDocumentContent = async (page: Page): Promise => { + // navigator.clipboard calls throw "Document is not focused" unless this page's tab is the + // OS-focused one - with multiple actors (e.g. Alice + Brian) each owning their own page/tab, + // the one we're about to read from isn't necessarily the foregrounded one. + await page.bringToFront() // clear the clipboard await page.evaluate("navigator.clipboard.writeText('')") // copying and getting the value with keyboard requires some time @@ -81,11 +85,27 @@ export const fillCollaboraDocumentContent = async (page: Page, content: string): export const fillOnlyOfficeDocumentContent = async (page: Page, content: string): Promise => { const editorMainFrame = page.frameLocator(externalEditorIframe) const innerIframe = editorMainFrame.frameLocator(onlyOfficeInnerFrameSelector) - await innerIframe.locator(onlyofficeDocTextAreaSelector).focus() - await page.keyboard.press('ControlOrMeta+A') - await innerIframe.locator(onlyofficeDocTextAreaSelector).fill(content) + const textAreaLocator = innerIframe.locator(onlyofficeDocTextAreaSelector) const saveButtonDisabledLocator = innerIframe.locator(onlyOfficeSaveButtonSelector) - await expect(saveButtonDisabledLocator).toHaveAttribute('disabled', 'disabled') + + // right after the document opens, the hidden text area can already be focusable even though + // OnlyOffice hasn't finished initializing internally yet, so Ctrl+A/paste can be a silent + // no-op that leaves the document content unchanged - verify it actually landed and retry if + // it didn't, instead of trusting a single attempt. + let actualContent = '' + for (let attempt = 1; attempt <= 5; attempt++) { + await textAreaLocator.focus() + await page.keyboard.press('ControlOrMeta+A') + await textAreaLocator.fill(content) + await expect(saveButtonDisabledLocator).toHaveAttribute('disabled', 'disabled') + + actualContent = (await getOfficeDocumentContent(page)).trim() + if (actualContent === content.trim()) { + return + } + await page.waitForTimeout(1000) + } + expect(actualContent).toBe(content.trim()) } export const canEditCollaboraDocument = async (page: Page): Promise => {