[test-only][full-ci] Test: fix flaky e2e-app-provider (#12934)
ci: fix flaky e2e-app-provider
This commit is contained in:
8 files changed
+61
-27
No files matched your search
@@ -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
|
||||
|
||||
@@ -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']
|
||||
})
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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' })
|
||||
|
||||
@@ -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)
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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<string[]> => {
|
||||
await page.reload()
|
||||
return getDisplayedResourcesFromFilesList(page)
|
||||
}
|
||||
|
||||
export const getDisplayedResourcesFromFilesList = async (page: Page): Promise<string[]> => {
|
||||
// wait for tika indexing
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||
|
||||
@@ -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<string[]> {
|
||||
return po.reSearchAndGetDisplayedResourcesFromFilesList(this.#page)
|
||||
}
|
||||
|
||||
getDisplayedResources(args: Omit<po.getDisplayedResourcesArgs, 'page'>): Promise<string[]> {
|
||||
switch (args.keyword) {
|
||||
case resourcePage.filesList:
|
||||
|
||||
@@ -55,6 +55,10 @@ export const focusOnlyOfficeEditor = async (page: Page): Promise<void> => {
|
||||
}
|
||||
|
||||
export const getOfficeDocumentContent = async (page: Page): Promise<string> => {
|
||||
// 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<void> => {
|
||||
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<boolean> => {
|
||||
|
||||
Reference in new issue
Block a user