From b87c9497dc98fdc82ae24e8274cc2461a0d50cca Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Wed, 16 Mar 2022 19:56:23 +0800 Subject: [PATCH] feat:add hyperlink test case --- cypress/integration/menus/hyperlink.spec.ts | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cypress/integration/menus/hyperlink.spec.ts diff --git a/cypress/integration/menus/hyperlink.spec.ts b/cypress/integration/menus/hyperlink.spec.ts new file mode 100644 index 0000000..362144f --- /dev/null +++ b/cypress/integration/menus/hyperlink.spec.ts @@ -0,0 +1,42 @@ +import Editor from '../../../src/editor' + +describe('菜单-超链接', () => { + + beforeEach(() => { + cy.visit('http://localhost:3000/canvas-editor/') + + cy.get('canvas').first().as('canvas').should('have.length', 1) + }) + + const text = 'canvas-editor' + const url = 'https://hufe.club/canvas-editor' + + it('超链接', () => { + cy.getEditor().then((editor: Editor) => { + editor.listener.saved = function (payload) { + const data = payload.data + + expect(data[0].type).to.eq('hyperlink') + + expect(data[0].url).to.eq(url) + + expect(data[0]?.valueList?.[0].value).to.eq(text) + } + + editor.command.executeSelectAll() + + editor.command.executeBackspace() + + cy.get('.menu-item__hyperlink').click() + + cy.get('.dialog-option__item [name="name"]').type(text) + + cy.get('.dialog-option__item [name="url"]').type(url) + + cy.get('.dialog-menu button').eq(1).click() + + cy.get('@canvas').type('{ctrl}s') + }) + }) + +})