Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more renaming
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and max-nextcloud committed Aug 27, 2023
commit 23c74ebe392e8154be4597addf4dd6ca565855bb
65 changes: 30 additions & 35 deletions cypress/e2e/attachments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down Expand Up @@ -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]))
}
})
Expand All @@ -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]))
}
})
Expand All @@ -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]))
Expand All @@ -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
Expand All @@ -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]))
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ 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')
})

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')
})

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')
})
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/mobile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
Expand Down
10 changes: 3 additions & 7 deletions cypress/e2e/nodes/ImageView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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`

Expand Down
6 changes: 1 addition & 5 deletions cypress/e2e/sections.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/viewer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
30 changes: 8 additions & 22 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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"]')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
})
Expand Down Expand Up @@ -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')
})
Expand All @@ -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')
})
})

Expand Down Expand Up @@ -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)
}

Expand Down
13 changes: 6 additions & 7 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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()
Expand Down