summaryrefslogtreecommitdiffstats
path: root/cypress
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-02-22 18:36:12 +0100
committerskjnldsv <skjnldsv@protonmail.com>2024-02-22 19:10:09 +0100
commit5b757c33d8577bdf635be77312f357c58850470a (patch)
tree27caf78f94af4e7f26bae43e5a7652dfcd883bab /cypress
parent16b818bd1e686e73bb18dc984c9665f595fedac1 (diff)
downloadnextcloud-server-5b757c33d8577bdf635be77312f357c58850470a.tar.gz
nextcloud-server-5b757c33d8577bdf635be77312f357c58850470a.zip
fix(cypress): files_versions flakyness
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'cypress')
-rw-r--r--cypress/e2e/files_versions/filesVersionsUtils.ts39
-rw-r--r--cypress/e2e/files_versions/version_restoration.cy.ts4
2 files changed, 22 insertions, 21 deletions
diff --git a/cypress/e2e/files_versions/filesVersionsUtils.ts b/cypress/e2e/files_versions/filesVersionsUtils.ts
index 789bfc97d4e..ffaa96f9518 100644
--- a/cypress/e2e/files_versions/filesVersionsUtils.ts
+++ b/cypress/e2e/files_versions/filesVersionsUtils.ts
@@ -20,10 +20,10 @@
*
*/
-import path from "path"
-import type { User } from "@nextcloud/cypress"
+import type { User } from '@nextcloud/cypress'
+import path from 'path'
-export function uploadThreeVersions(user: User, fileName: string) {
+export const uploadThreeVersions = (user: User, fileName: string) => {
// A new version will not be created if the changes occur
// within less than one second of each other.
// eslint-disable-next-line cypress/no-unnecessary-waiting
@@ -35,23 +35,22 @@ export function uploadThreeVersions(user: User, fileName: string) {
cy.login(user)
}
-export function openVersionsPanel(fileName: string) {
- cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"]`).within(() => {
- cy.get('[data-cy-files-list-row-actions] .action-item__menutoggle')
- .click()
- })
-
- cy.get('.action-item__popper')
- .get('[data-cy-files-list-row-action="details"]')
- .click()
+export const openVersionsPanel = (fileName: string) =>{
+ // Detect the versions list fetch
+ cy.intercept('PROPFIND', '**/dav/versions/*/versions/**').as('getVersions')
- cy.get('#app-sidebar-vue')
- .get('[aria-controls="tab-version_vue"]')
- .click()
+ // Open the versions tab
+ cy.window().then(win => {
+ win.OCA.Files.Sidebar.setActiveTab('version_vue')
+ win.OCA.Files.Sidebar.open(`/${fileName}`)
+ })
+ // Wait for the versions list to be fetched
+ cy.wait('@getVersions')
+ cy.get('#tab-version_vue').should('be.visible', { timeout: 10000 })
}
-export function openVersionMenu(index: number) {
+export const openVersionMenu = (index: number) => {
cy.get('#tab-version_vue').within(() => {
cy.get('[data-files-versions-version]')
.eq(index).within(() => {
@@ -61,19 +60,19 @@ export function openVersionMenu(index: number) {
})
}
-export function clickPopperAction(actionName: string) {
+export const clickPopperAction = (actionName: string) => {
cy.get('.v-popper__popper').filter(':visible')
.contains(actionName)
.click()
}
-export function nameVersion(index: number, name: string) {
+export const nameVersion = (index: number, name: string) => {
openVersionMenu(index)
clickPopperAction('Name this version')
cy.get(':focused').type(`${name}{enter}`)
}
-export function assertVersionContent(filename: string, index: number, expectedContent: string) {
+export const assertVersionContent = (filename: string, index: number, expectedContent: string) => {
const downloadsFolder = Cypress.config('downloadsFolder')
openVersionMenu(index)
@@ -82,4 +81,4 @@ export function assertVersionContent(filename: string, index: number, expectedCo
return cy.readFile(path.join(downloadsFolder, filename))
.then((versionContent) => expect(versionContent).to.equal(expectedContent))
.then(() => cy.exec(`rm ${downloadsFolder}/${filename}`))
-} \ No newline at end of file
+}
diff --git a/cypress/e2e/files_versions/version_restoration.cy.ts b/cypress/e2e/files_versions/version_restoration.cy.ts
index 115d30caa82..fe6b798299a 100644
--- a/cypress/e2e/files_versions/version_restoration.cy.ts
+++ b/cypress/e2e/files_versions/version_restoration.cy.ts
@@ -22,9 +22,11 @@
import { assertVersionContent, clickPopperAction, openVersionMenu, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
-function restoreVersion(index: number) {
+const restoreVersion = (index: number) => {
+ cy.intercept('MOVE', '**/dav/versions/*/versions/**').as('restoreVersion')
openVersionMenu(index)
clickPopperAction('Restore version')
+ cy.wait('@restoreVersion')
}
describe('Versions restoration', () => {