richdocuments icon indicating copy to clipboard operation
richdocuments copied to clipboard

Flaky cypress tests

Open juliusknorr opened this issue 9 months ago • 2 comments

integration.spec.js -> Save as

[4](https://github.com/nextcloud/richdocuments/actions/runs/22179490025/job/64136754974?pr=5406#step:19:195)
  1) Nextcloud integration
       Save as:
     AssertionError: Timed out retrying after 10000ms: Expected to find element: `.breadcrumb__crumbs a`, but never found it.
      at Context.eval (webpack://richdocuments/./cypress/e2e/integration.spec.js:102:11)

juliusknorr avatar Feb 19 '26 15:02 juliusknorr

@/Users/mavenai/Desktop/Singaw Sity Labs/Singaw Sity Codex/Hunter and Gatherers/runs/2026-05-30_nextcloud_richdocuments_5409/ISSUE_COMMENT_5409.md

TheDerbiedOne avatar May 30 '26 23:05 TheDerbiedOne

nextcloud/richdocuments #5409 — follow-up with the actual patch

Issue: https://github.com/nextcloud/richdocuments/issues/5409

My previous comment mistakenly pasted a local file path instead of the actual content — sorry about that. Here is the intended report + patch.

I took a look at the flaky “Save as” Cypress failure. The flake looks consistent with the Files list (and/or the new file row) not being fully present yet after the viewer closes + the exported file appears asynchronously.

Proposed low-risk stabilizers:
1) Make `cy.openFile(...)` wait for `[data-cy-files-list]` to be visible and use a longer default timeout.
2) In `integration.spec.js` “Save as”, wait for the exported file row to exist before calling `cy.openFile(exportFilename)`.

Patch (applies cleanly on current main as of ed617575d3e3…):
```diff
diff --git a/cypress/e2e/integration.spec.js b/cypress/e2e/integration.spec.js
index 93f95dc..b439744 100644
--- a/cypress/e2e/integration.spec.js
+++ b/cypress/e2e/integration.spec.js
@@ -100,6 +100,10 @@ describe('Nextcloud integration', function() {
 			cy.waitForViewerClose()
 		})
 
+		cy.get('[data-cy-files-list]', { timeout: 30_000 }).should('be.visible')
+		cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${exportFilename}"]`, { timeout: 30_000 })
+			.should('exist')
+
 		cy.openFile(exportFilename)
 	})
 
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index b2a95dc..ef31484 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -180,8 +180,14 @@ Cypress.Commands.add('shareLink', (user, path, shareData = {}) => {
 	})
 })
 
-Cypress.Commands.add('openFile', fileName => {
-	cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`).click()
+Cypress.Commands.add('openFile', (fileName, options = {}) => {
+	const timeout = options.timeout ?? 30_000
+
+	cy.get('[data-cy-files-list]', { timeout }).should('be.visible')
+	cy.get(
+		`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`,
+		{ timeout },
+	).click()
 })
 
 Cypress.Commands.add('nextcloudEnableApp', (appId) => {

TheDerbiedOne avatar May 31 '26 18:05 TheDerbiedOne