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 19, 2023
1 parent ff2fd8e commit 9a60ead
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 42 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
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 9a60ead

Please sign in to comment.