From a7d348642b2da1ea9324b85a3dc2b94fd42f0a0f Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 26 Aug 2024 00:54:57 +0200 Subject: [PATCH 1/2] test: Adjust Cypress tests Signed-off-by: Ferdinand Thiessen --- cypress.config.ts | 3 +-- cypress/e2e/filesUtils.ts | 15 ++++++++----- cypress/e2e/sidebar.cy.ts | 14 +++++++----- cypress/e2e/sidebarUtils.ts | 45 +++++++++++++++++++++---------------- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index 205b06965..dee310b02 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -17,9 +17,8 @@ export default defineConfig({ viewportWidth: 1280, viewportHeight: 720, - // Tries again 2 more times on failure retries: { - runMode: 2, + runMode: 5, // do not retry in `cypress open` openMode: 0, }, diff --git a/cypress/e2e/filesUtils.ts b/cypress/e2e/filesUtils.ts index 92b9f74fa..7edb83d81 100644 --- a/cypress/e2e/filesUtils.ts +++ b/cypress/e2e/filesUtils.ts @@ -4,8 +4,7 @@ */ export function renameFile(fileName: string, newName: string) { - toggleMenuAction(fileName) - cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="rename"]`).click() + toggleMenuAction(fileName, 'rename') cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename input`).clear() cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename input`).type(`${newName}.txt`) cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename`).submit() @@ -28,8 +27,7 @@ export function createFolder (dirName: string) { } export function moveFile (fileName: string, dirName: string) { - toggleMenuAction(fileName) - cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="move-copy"]`).click() + toggleMenuAction(fileName, 'move-copy') cy.get('.file-picker').within(() => { cy.get(`[data-filename="${dirName}"]`).click() cy.contains(`Move to ${dirName}`).click() @@ -41,14 +39,19 @@ export function getFileListRow(filename: string) { return cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${CSS.escape(filename)}"]`) } -export function toggleMenuAction(filename: string) { +export function toggleMenuAction(filename: string, action: 'details'|'favorite'|'move-copy'|'rename') { getFileListRow(filename) .find('[data-cy-files-list-row-actions]') .should('be.visible') + + getFileListRow(filename) + .find('[data-cy-files-list-row-actions]') .findByRole('button', { name: 'Actions' }) .should('be.visible') .click() - cy.get('[data-cy-files-list-row-action]') + cy.get(`[data-cy-files-list-row-action="${CSS.escape(action)}"]`) .should('be.visible') + .findByRole('menuitem') + .click() } diff --git a/cypress/e2e/sidebar.cy.ts b/cypress/e2e/sidebar.cy.ts index 163a7c28c..74c47ce6b 100644 --- a/cypress/e2e/sidebar.cy.ts +++ b/cypress/e2e/sidebar.cy.ts @@ -4,7 +4,7 @@ */ import { createFolder, getFileListRow, goToDir, moveFile, renameFile } from './filesUtils' -import { addComment, addTag, addToFavorites, createPublicShare, removeFromFavorites, showActivityTab } from './sidebarUtils' +import { addComment, addTag, createPublicShare, toggleFavorite, showActivityTab, closeSidebar } from './sidebarUtils' describe('Check activity listing in the sidebar', { testIsolation: true }, () => { beforeEach(function() { @@ -24,19 +24,22 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () => }) it('Has favorite activity', () => { - addToFavorites('welcome.txt') + toggleFavorite('welcome.txt') showActivityTab('welcome.txt') cy.get('.activity-entry').first().should('contains.text', 'Added to favorites') - removeFromFavorites('welcome.txt') + cy.visit('/apps/files') + getFileListRow('welcome.txt').should('be.visible') + + toggleFavorite('welcome.txt') showActivityTab('welcome.txt') cy.get('.activity-entry').first().should('contains.text', 'Removed from favorites') }) it('Has share activity', () => { createPublicShare('welcome.txt') - cy.get('body').contains('Link share created').should('exist') - cy.get('.toast-close').click({ multiple: true }) + cy.visit('/apps/files') + showActivityTab('welcome.txt') cy.get('.activity-entry').first().should('contains.text', 'Shared as public link') }) @@ -61,6 +64,7 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () => it('Has tag activity', () => { addTag('welcome.txt', 'my_tag') + cy.visit('/apps/files') showActivityTab('welcome.txt') cy.get('.activity-entry').first().should('contains.text', 'Added system tag') diff --git a/cypress/e2e/sidebarUtils.ts b/cypress/e2e/sidebarUtils.ts index 5badc7db4..4b98604e5 100644 --- a/cypress/e2e/sidebarUtils.ts +++ b/cypress/e2e/sidebarUtils.ts @@ -7,15 +7,11 @@ import { toggleMenuAction } from './filesUtils' function showSidebarForFile(fileName: string) { closeSidebar() - toggleMenuAction(fileName) - cy.get('[data-cy-files-list-row-action="details"]') - .should('be.visible') - .findByRole('menuitem') - .click() + toggleMenuAction(fileName, 'details') cy.get('#app-sidebar-vue').should('be.visible') } -function closeSidebar() { +export function closeSidebar() { cy.get('body') .then(($body) => { if ($body.find('.app-sidebar__close').length !== 0) { @@ -27,18 +23,21 @@ function closeSidebar() { export function showActivityTab(fileName: string) { showSidebarForFile(fileName) - cy.get('#app-sidebar-vue').contains('Activity').click() -} + cy.get('#app-sidebar-vue') + .findByRole('tab', { name: 'Activity' }) + .click() -export function addToFavorites(fileName: string) { - toggleMenuAction(fileName) - cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Add to favorites').click() - cy.get('.toast-close').click() + cy.get('#app-sidebar-vue') + .findByRole('tabpanel', { name: 'Activity' }) + .should('be.visible') } -export function removeFromFavorites(fileName: string) { - toggleMenuAction(fileName) - cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Remove from favorites').click() +export function toggleFavorite(fileName: string) { + cy.intercept('POST', '**/index.php/apps/files/api/v1/files/*').as('setTags') + + toggleMenuAction(fileName, 'favorite') + cy.wait('@setTags') + cy.get('.toast-close').click() } @@ -49,11 +48,19 @@ export function removeFromFavorites(fileName: string) { */ export function createPublicShare(fileName: string) { showSidebarForFile(fileName) - cy.get('#app-sidebar-vue').contains('Sharing').click() + cy.get('#app-sidebar-vue') + .findByRole('tab', { name: 'Sharing' }) + .click() + + cy.intercept('POST', '**/ocs/v2.php/apps/files_sharing/api/v1/shares').as('createShare') - cy.get('#app-sidebar-vue #tab-sharing').should('be.visible') - cy.get('#app-sidebar-vue button.new-share-link').click({ force: true }) - cy.get('#app-sidebar-vue .sharing-entry__copy').should('be.visible') + cy.get('#app-sidebar-vue') + .findByRole('tabpanel', { name: 'Sharing' }) + .should('be.visible') + .findByRole('button', { name: "Create a new share link" }) + .click({ force: true }) + + cy.wait('@createShare') closeSidebar() } From ca0780b84da8aba6a6a06efc6ac442fae72e1572 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:28:22 +0000 Subject: [PATCH 2/2] Upgrade: Bump fast-xml-parser from 4.3.6 to 4.4.1 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 4.3.6 to 4.4.1. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v4.3.6...v4.4.1) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: nextcloud-command --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9642b946..9c7ef105c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7314,9 +7314,9 @@ "peer": true }, "node_modules/fast-xml-parser": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.6.tgz", - "integrity": "sha512-M2SovcRxD4+vC493Uc2GZVcZaj66CCJhWurC4viynVSTvrpErCShNcDz1lAho6n9REQKvL/ll4A4/fw6Y9z8nw==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", "funding": [ { "type": "github", @@ -20789,9 +20789,9 @@ "peer": true }, "fast-xml-parser": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.6.tgz", - "integrity": "sha512-M2SovcRxD4+vC493Uc2GZVcZaj66CCJhWurC4viynVSTvrpErCShNcDz1lAho6n9REQKvL/ll4A4/fw6Y9z8nw==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", "requires": { "strnum": "^1.0.5" }