From 23c74ebe392e8154be4597addf4dd6ca565855bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 18 Aug 2023 10:52:43 +0200 Subject: [PATCH] more renaming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/attachments.spec.js | 65 +++++++++++++---------------- cypress/e2e/files.spec.js | 6 +-- cypress/e2e/mobile.spec.js | 4 +- cypress/e2e/nodes/ImageView.spec.js | 10 ++--- cypress/e2e/sections.spec.js | 6 +-- cypress/e2e/viewer.spec.js | 4 +- cypress/e2e/workspace.spec.js | 30 ++++--------- cypress/support/commands.js | 13 +++--- 8 files changed, 54 insertions(+), 84 deletions(-) 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/files.spec.js b/cypress/e2e/files.spec.js index 370c75c30a3..a65227ea465 100644 --- a/cypress/e2e/files.spec.js +++ b/cypress/e2e/files.spec.js @@ -36,7 +36,7 @@ describe('Text and server mimetypes', () => { it('handle plaintext in a pre tag', () => { cy.uploadFile('empty.md', 'text/plain', 'textfile.txt') cy.visit('/apps/files') - cy.get('#app-content-files table tr').should('contain', 'textfile.txt') + cy.getFile('textfile.txt') cy.openFile('textfile.txt') cy.getContent().find('pre').should('exist') }) @@ -44,7 +44,7 @@ describe('Text and server mimetypes', () => { it('handle asciidoc as plaintext for now', () => { cy.uploadFile('test.adoc', 'text/asciidoc', 'hello.adoc') cy.visit('/apps/files') - cy.get('#app-content-files table tr').should('contain', 'hello.adoc') + cy.getFile('hello.adoc') cy.openFile('hello.adoc') cy.getContent().find('pre').should('contain', 'Hello world') }) @@ -52,7 +52,7 @@ describe('Text and server mimetypes', () => { it('handle markdown with richtext editor', () => { cy.uploadFile('test.md', 'text/markdown', 'markdown.md') cy.visit('/apps/files') - cy.get('#app-content-files table tr').should('contain', 'markdown.md') + cy.getFile('markdown.md') cy.openFile('markdown.md') cy.getContent().find('h2').should('contain', 'Hello world') }) diff --git a/cypress/e2e/mobile.spec.js b/cypress/e2e/mobile.spec.js index 8ea715c9ad5..57f6dcb34c1 100644 --- a/cypress/e2e/mobile.spec.js +++ b/cypress/e2e/mobile.spec.js @@ -50,9 +50,7 @@ describe('Mobile actions', { cy.uploadFile('test.md', 'text/markdown', `${encodeURIComponent(folderName)}/text.md`) cy.visit(`apps/files?dir=/${encodeURIComponent(folderName)}`) - cy.get('.files-controls .crumb:not(.hidden) a') - .last() - .click({ force: true }) + cy.reload() cy.openFile('text.md', { force: true }) }) diff --git a/cypress/e2e/nodes/ImageView.spec.js b/cypress/e2e/nodes/ImageView.spec.js index eab983f4ec6..c945239c72f 100644 --- a/cypress/e2e/nodes/ImageView.spec.js +++ b/cypress/e2e/nodes/ImageView.spec.js @@ -2,13 +2,9 @@ import { randUser } from '../../utils/index.js' const user = randUser() -const refresh = () => cy.get('.files-controls .crumb:not(.hidden) a') - .last() - .click({ force: true }) - const createMarkdown = (fileName, content) => { return cy.createFile(fileName, content, 'text/markdown') - .then(refresh) + .then(cy.reload) } describe('Image View', () => { @@ -85,8 +81,8 @@ describe('Image View', () => { }) it('with preview', () => { - cy.get('.files-fileList tr[data-file="github.png"]') - .should('have.attr', 'data-id') + cy.getFile('github.png') + .should('have.attr', 'data-cy-files-list-row-fileid') .then(imageId => { const fileName = `${Cypress.currentTest.title}.md` 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 0499cf0397d..649b4315b3a 100644 --- a/cypress/e2e/viewer.spec.js +++ b/cypress/e2e/viewer.spec.js @@ -36,8 +36,8 @@ describe('Open test.md in viewer', function() { }) it('See test.md in the list', function() { - cy.get('.files-fileList tr[data-file="test.md"]', { timeout: 10000 }) - .should('contain', 'test.md') + cy.getFile('test.md') + .should('be.visible') }) it('Open the viewer on file click', function() { diff --git a/cypress/e2e/workspace.spec.js b/cypress/e2e/workspace.spec.js index 0997dca6cfc..3fa86839d40 100644 --- a/cypress/e2e/workspace.spec.js +++ b/cypress/e2e/workspace.spec.js @@ -44,7 +44,7 @@ describe('Workspace', function() { cy.uploadFile('test.md', 'text/markdown', `${currentFolder}/README.md`) cy.createFolder(`${currentFolder}/subdirectory`) cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('contain', 'README.md') + cy.getFile('README.md').should('contain', 'README.md') cy.get('#rich-workspace .ProseMirror') .should('contain', 'Hello world') cy.openFolder('subdirectory') @@ -56,7 +56,7 @@ describe('Workspace', function() { it('Hides the workspace when switching to another view', function() { cy.uploadFile('test.md', 'text/markdown', `${currentFolder}/README.md`) cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('contain', 'README.md') + cy.getFile('README.md').should('contain', 'README.md') cy.get('#rich-workspace .ProseMirror') .should('contain', 'Hello world') cy.get('a[href*="/apps/files/recent"]') @@ -66,19 +66,7 @@ describe('Workspace', function() { }) it('adds a Readme.md', function() { - const url = '**/remote.php/dav/files/**' - cy.intercept({ method: 'PUT', url }) - .as('addDescription') - - cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('not.contain', 'Readme.md') - - cy.get('.files-controls').first().within(() => { - cy.get('.button.new').click() - cy.get('.newFileMenu a.menuitem[data-action="rich-workspace-init"]').click() - cy.wait('@addDescription') - }) - + cy.createDescription() openSidebar('Readme.md') cy.get('#rich-workspace .text-editor .text-editor__wrapper') .should('be.visible') @@ -133,7 +121,7 @@ describe('Workspace', function() { it('takes README.md into account', function() { cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/README.md`) cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('contain', 'README.md') + cy.getFile('README.md').should('contain', 'README.md') cy.get('#rich-workspace .ProseMirror') .should('contain', 'Hello world') }) @@ -250,7 +238,7 @@ describe('Workspace', function() { cy.modifyUser(user, 'language', 'de_DE') cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/Anleitung.md`) cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('contain', 'Anleitung.md') + cy.getFile('Anleitung.md').should('contain', 'Anleitung.md') cy.get('#rich-workspace .ProseMirror') .should('contain', 'Hello world') }) @@ -259,7 +247,7 @@ describe('Workspace', function() { cy.modifyUser(user, 'language', 'fr') cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/Anleitung.md`) cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`) - cy.get('.files-fileList').should('contain', 'Anleitung.md') + cy.getFile('Anleitung.md').should('contain', 'Anleitung.md') }) }) @@ -303,10 +291,8 @@ describe('Workspace', function() { }) const openSidebar = filename => { - cy.get(`.files-fileList tr[data-file="${filename}"]`) - .should('contain', filename) - cy.get(`.files-fileList tr[data-file="${filename}"] .icon-more`).click() - cy.get(`.files-fileList tr[data-file="${filename}"] .icon-details`).click() + cy.getFile(filename).should('contain', filename) + cy.getFile(filename).find('.files-list__row-mtime').click() cy.get('.app-sidebar-header').should('contain', filename) } diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 16907181806..6fd06744ca0 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)}` @@ -314,9 +313,9 @@ Cypress.Commands.add('getFile', fileName => { }) Cypress.Commands.add('deleteFile', fileName => { - cy.get(`.files-fileList tr[data-file="${fileName}"] a.name .action-menu`).click() - cy.get(`.files-fileList tr[data-file="${fileName}"] a.name + .popovermenu .action-delete`).click() - cy.get(`.files-fileList tr[data-file="${fileName}"]`).should('not.exist') + cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] .files-list__row-actions 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') }) Cypress.Commands.add('getModal', () => { @@ -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()