diff --git a/cypress/e2e/attachments.spec.js b/cypress/e2e/attachments.spec.js index 86dffe7e57e..6515b576455 100644 --- a/cypress/e2e/attachments.spec.js +++ b/cypress/e2e/attachments.spec.js @@ -164,10 +164,8 @@ describe('Test all attachment insertion methods', () => { }) it('See test files in the list and display hidden files', () => { - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) - .should('contain', 'test.md') - cy.get('.files-fileList tr[data-file="github.png"]', { timeout: 10000 }) - .should('contain', 'github.png') + cy.getFile('test.md') + cy.getFile('github.png') cy.showHiddenFiles() }) @@ -288,18 +286,17 @@ describe('Test all attachment insertion methods', () => { it('test if attachment files are in the attachment folder', () => { // check we stored the attachment names/ids - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) - .should('have.attr', 'data-id') + cy.getFile('test.md') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { const files = attachmentFileNameToId[documentId] cy.expect(Object.keys(files)).to.have.lengthOf(5) cy.openFolder('.attachments.' + documentId) - cy.screenshot() for (const name in files) { - cy.get(`.files-fileList tr[data-file="${name}"]`, { timeout: 10000 }) + cy.getFile(name) .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .should('eq', String(files[name])) } }) @@ -310,17 +307,16 @@ describe('Test all attachment insertion methods', () => { cy.reloadFileList() cy.moveFile('test.md', 'subFolder/test.md') cy.openFolder('subFolder') - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) + cy.getFile('test.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { const files = attachmentFileNameToId[documentId] cy.openFolder('.attachments.' + documentId) - cy.screenshot() for (const name in files) { - cy.get(`.files-fileList tr[data-file="${name}"]`, { timeout: 10000 }) + cy.getFile(name) .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .should('eq', String(files[name])) } }) @@ -330,18 +326,17 @@ describe('Test all attachment insertion methods', () => { cy.copyFile('subFolder/test.md', 'testCopied.md') cy.reloadFileList() - cy.get('.files-fileList tr[data-file="testCopied.md"]', { timeout: 10000 }) + cy.getFile('testCopied.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { const files = attachmentFileNameToId[documentId] cy.openFolder('.attachments.' + documentId) - cy.screenshot() for (const name in files) { - cy.get(`.files-fileList tr[data-file="${name}"]`, { timeout: 10000 }) + cy.getFile(name) .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') // these are new copied attachment files // so they should not have the same IDs than the ones created when uploading the files .should('not.eq', String(files[name])) @@ -350,13 +345,13 @@ describe('Test all attachment insertion methods', () => { }) it('test if attachment folder is deleted after having deleted a markdown file', () => { - cy.get('.files-fileList tr[data-file="testCopied.md"]', { timeout: 10000 }) + cy.getFile('testCopied.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { cy.deleteFile('testCopied.md') cy.reloadFileList() - cy.get(`.files-fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) + cy.getFile('.attachments.' + documentId) .should('not.exist') }) // change the current user for next tests @@ -365,45 +360,45 @@ describe('Test all attachment insertion methods', () => { it('[share] check everything behaves correctly on the share target user side', () => { // check the file list - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) + cy.get('test.md') .should('contain', 'test.md') - cy.get('files-fileList tr[data-file="github.png"]').should('not.exist') + cy.get('github.png') + .should('not.exist') cy.showHiddenFiles() // check the attachment folder is not there - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) + cy.get('test.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { - cy.get(`.files-fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) + cy.getFile('.attachments.' + documentId) .should('not.exist') }) // move the file and check the attachment folder is still not there cy.moveFile('test.md', 'testMoved.md') cy.reloadFileList() - cy.get('.files-fileList tr[data-file="testMoved.md"]', { timeout: 10000 }) + cy.getFile('testMoved.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { - cy.get(`.files-fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) + cy.getFile('.attachments.' + documentId) .should('not.exist') }) // copy the file and check the attachment folder was copied cy.copyFile('testMoved.md', 'testCopied.md') cy.reloadFileList() - cy.get('.files-fileList tr[data-file="testCopied.md"]', { timeout: 10000 }) + cy.getFile('testCopied.md') .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') .then((documentId) => { const files = attachmentFileNameToId[documentId] cy.openFolder('.attachments.' + documentId) - cy.screenshot() for (const name in files) { - cy.get(`.files-fileList tr[data-file="${name}"]`, { timeout: 10000 }) + cy.getFile(name) .should('exist') - .should('have.attr', 'data-id') + .should('have.attr', 'data-cy-files-list-row-fileid') // these are new copied attachment files // so they should not have the same IDs than the ones created when uploading the files .should('not.eq', String(files[name])) diff --git a/cypress/e2e/sections.spec.js b/cypress/e2e/sections.spec.js index fcb59c36c98..e4c4f48321a 100644 --- a/cypress/e2e/sections.spec.js +++ b/cypress/e2e/sections.spec.js @@ -3,10 +3,6 @@ import { randUser } from '../utils/index.js' const user = randUser() const fileName = 'empty.md' -const refresh = () => cy.get('.files-controls .crumb:not(.hidden) a') - .last() - .click({ force: true }) - const clickOutline = () => { cy.getActionEntry('headings') .click() @@ -110,7 +106,7 @@ describe('Content Sections', () => { cy.openFile(fileName, { force: true }) cy.getContent() .type('# T1 \n## T2 \n### T3 \n#### T4 \n##### T5 \n###### T6\n') - cy.then(refresh) + cy.closeFile() .then(() => cy.openFile(fileName, { force: true })) .then(clickOutline) diff --git a/cypress/e2e/viewer.spec.js b/cypress/e2e/viewer.spec.js index 020f39cd42d..649b4315b3a 100644 --- a/cypress/e2e/viewer.spec.js +++ b/cypress/e2e/viewer.spec.js @@ -37,7 +37,7 @@ describe('Open test.md in viewer', function() { it('See test.md in the list', function() { cy.getFile('test.md') - .should('contain', 'test.md') + .should('be.visible') }) it('Open the viewer on file click', function() { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 701c3f8b671..6f0c2f0b284 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -284,9 +284,8 @@ Cypress.Commands.add('propfindFolder', (path, depth = 0) => { }) }) -Cypress.Commands.add('reloadFileList', () => cy.window() - .then(win => win.OCA?.Files?.App?.fileList?.reload()), -) +// FIXME: proper file list reload only once that is possible with the vue files app +Cypress.Commands.add('reloadFileList', () => cy.reload()) Cypress.Commands.add('openFolder', (name) => { const url = `**/${encodeURI(name)}` @@ -315,7 +314,7 @@ Cypress.Commands.add('getFile', fileName => { Cypress.Commands.add('deleteFile', fileName => { cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] .files-list__row-actions butotn`).click() - cy.get(`.files-list__row-action-delete button`).click() + cy.get('.files-list__row-action-delete button').click() cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"]`).should('not.exist') }) @@ -412,7 +411,7 @@ Cypress.Commands.add('createDescription', () => { cy.intercept({ method: 'PUT', url }) .as('addDescription') - cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="Readme.md"]`).should('not.exist') + cy.get('[data-cy-files-list] tr[data-cy-files-list-row-name="Readme.md"]').should('not.exist') cy.get('.files-controls').first().within(() => { cy.get('.button.new').click() cy.get('.newFileMenu a.menuitem[data-action="rich-workspace-init"]').click()