Skip to content

Commit

Permalink
fixup! more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Aug 18, 2023
1 parent 247deb6 commit 5e6f7a9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 46 deletions.
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: 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
2 changes: 1 addition & 1 deletion cypress/e2e/viewer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 4 additions & 5 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 @@ -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')
})

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

0 comments on commit 5e6f7a9

Please sign in to comment.