Skip to content

Commit

Permalink
fix(cypress): do not chain from actions
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Aug 20, 2023
1 parent 2e61141 commit 4601b0e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 45 deletions.
39 changes: 17 additions & 22 deletions cypress/e2e/MenuBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,33 @@ describe('Test the rich text editor menu bar', function() {
}

beforeEach(cy.clearContent)

it('empty file', () => {
cy.getFile(fileName)
.then($el => {
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '0 words, 0 chars')
})
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '0 words, 0 chars')
})

it('single word', () => {
cy.getFile(fileName)
.then($el => {
cy.clearContent()
.type(' Hello ')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '1 word, 9 chars')
})
cy.getContent()
.type(' Hello ')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '1 word, 9 chars')
})

it('multiple words', () => {
cy.getFile(fileName)
.then($el => {
cy.clearContent()
.type('Hello \nworld')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '2 words, 11 chars')
})
cy.getContent()
.type('Hello \nworld')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '2 words, 11 chars')
})
})
})
37 changes: 18 additions & 19 deletions cypress/e2e/nodes/FrontMatter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,32 @@ describe('Front matter support', function() {
})

it('Open file with front matter', function() {
cy.openFile('frontmatter.md').then(() => {
cy.getContent().find('pre.frontmatter').should(pre => {
expect(pre.length === 1)
expect(pre[0].text === 'some: value\nother: 1.2')
})
cy.openFile('frontmatter.md')
cy.getContent().find('pre.frontmatter').should(pre => {
expect(pre.length === 1)
expect(pre[0].text === 'some: value\nother: 1.2')
})
})

it('Add front matter', function() {
cy.openFile('empty.md').clearContent().then(() => {
cy.getContent().type('---')
cy.getContent().type('test')
cy.getContent().find('pre.frontmatter').should(pre => {
expect(pre.length === 1)
expect(pre[0].text === 'test')
})
cy.openFile('empty.md')
cy.clearContent()
cy.getContent().type('---')
cy.getContent().type('test')
cy.getContent().find('pre.frontmatter').should(pre => {
expect(pre.length === 1)
expect(pre[0].text === 'test')
})
})

it('Do not add multiple front matter', function() {
cy.openFile('empty.md').clearContent().then(() => {
cy.getContent().type('---test')
cy.getContent().type('{downArrow}')
cy.getContent().type('---test')
cy.getContent().find('pre.frontmatter').should(pre => expect(pre.length === 1))
cy.getContent().find('hr').should(hr => expect(hr.length === 1))
})
cy.openFile('empty.md')
cy.clearContent()
cy.getContent().type('---test')
cy.getContent().type('{downArrow}')
cy.getContent().type('---test')
cy.getContent().find('pre.frontmatter').should(pre => expect(pre.length === 1))
cy.getContent().find('hr').should(hr => expect(hr.length === 1))
})

it('Reopen front matter', function() {
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/nodes/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('test link marks', function() {

const link = `${Cypress.env('baseUrl')}/apps/files/file-name?fileId=${id}`
cy.clearContent()
cy.getContent()
.type(`${link}{enter}`)

cy.getContent()
Expand All @@ -68,6 +69,7 @@ describe('test link marks', function() {

const link = `${Cypress.env('baseUrl')}/file-name?fileId=${id}`
cy.clearContent()
cy.getContent()
.type(`${link}{enter}`)

cy.getContent()
Expand All @@ -82,6 +84,7 @@ describe('test link marks', function() {

it('without protocol', () => {
cy.clearContent()
cy.getContent()
.type('google.com{enter}')
cy.getContent()
.find('a[href*="google.com"]')
Expand Down Expand Up @@ -118,7 +121,6 @@ describe('test link marks', function() {
.should('have.been.calledWith', url)
}

beforeEach(cy.clearContent)
it('Link website without selection', () => {
cy.getFile(fileName)
.then($el => {
Expand Down Expand Up @@ -148,8 +150,6 @@ describe('test link marks', function() {
.click({ force: true })
}

beforeEach(() => cy.clearContent())

it('without text', () => {
cy.getFile(fileName)
.then($el => {
Expand Down
1 change: 0 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ Cypress.Commands.add('getTOC', () => {
Cypress.Commands.add('clearContent', () => {
cy.getContent().scrollIntoView()
cy.getContent().type('{selectAll}{backspace}')
return cy.getContent()
})

Cypress.Commands.add('openWorkspace', () => {
Expand Down

0 comments on commit 4601b0e

Please sign in to comment.