From f6d8d52044f2320b8e58b919821ae7180c81a5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 29 Aug 2023 21:36:10 +0200 Subject: [PATCH] fix: Avoid further cypress command chaining MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/MenuBar.spec.js | 2 ++ cypress/e2e/nodes/FrontMatter.spec.js | 26 ++++++++++++-------------- cypress/e2e/nodes/Links.spec.js | 3 +++ cypress/support/commands.js | 3 ++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cypress/e2e/MenuBar.spec.js b/cypress/e2e/MenuBar.spec.js index 7f7eebf8c1b..be5118d025f 100644 --- a/cypress/e2e/MenuBar.spec.js +++ b/cypress/e2e/MenuBar.spec.js @@ -42,6 +42,7 @@ describe('Test the rich text editor menu bar', function() { cy.getFile(fileName) .then($el => { cy.clearContent() + cy.getContent() .type(' Hello ') cy.getActionEntry('remain') .click() @@ -54,6 +55,7 @@ describe('Test the rich text editor menu bar', function() { cy.getFile(fileName) .then($el => { cy.clearContent() + cy.getContent() .type('Hello \nworld') cy.getActionEntry('remain') .click() diff --git a/cypress/e2e/nodes/FrontMatter.spec.js b/cypress/e2e/nodes/FrontMatter.spec.js index 2e857b6a23f..2b81629d625 100644 --- a/cypress/e2e/nodes/FrontMatter.spec.js +++ b/cypress/e2e/nodes/FrontMatter.spec.js @@ -42,24 +42,22 @@ describe('Front matter support', function() { }) 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').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').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() { diff --git a/cypress/e2e/nodes/Links.spec.js b/cypress/e2e/nodes/Links.spec.js index b14350e6da3..19ca07d10a1 100644 --- a/cypress/e2e/nodes/Links.spec.js +++ b/cypress/e2e/nodes/Links.spec.js @@ -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() @@ -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() @@ -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"]') diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 412d8982732..e25582f7e90 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -382,7 +382,8 @@ Cypress.Commands.add('getTOC', () => { Cypress.Commands.add('clearContent', () => { cy.getContent().scrollIntoView() cy.getContent().type('{selectAll}{backspace}') - return cy.getContent() + + cy.getContent() }) Cypress.Commands.add('openWorkspace', () => {