From 436d1de2845599e5767833648ffc836647d7e292 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sat, 18 Mar 2023 12:25:20 +0800 Subject: [PATCH] test:update get editor value --- cypress/integration/control/checkbox.spec.ts | 4 +- cypress/integration/control/select.spec.ts | 4 +- cypress/integration/control/text.spec.ts | 4 +- cypress/integration/editor.spec.ts | 4 +- cypress/integration/menus/block.spec.ts | 4 +- cypress/integration/menus/checkbox.spec.ts | 4 +- cypress/integration/menus/codeblock.spec.ts | 4 +- cypress/integration/menus/date.spec.ts | 4 +- cypress/integration/menus/format.spec.ts | 4 +- cypress/integration/menus/hyperlink.spec.ts | 4 +- cypress/integration/menus/image.spec.ts | 4 +- cypress/integration/menus/latex.spec.ts | 4 +- cypress/integration/menus/painter.spec.ts | 4 +- cypress/integration/menus/row.spec.ts | 16 ++----- cypress/integration/menus/search.spec.ts | 4 +- cypress/integration/menus/separator.spec.ts | 4 +- cypress/integration/menus/table.spec.ts | 4 +- cypress/integration/menus/text.spec.ts | 44 +++++--------------- cypress/integration/menus/undoRedo.spec.ts | 8 ++-- 19 files changed, 37 insertions(+), 95 deletions(-) diff --git a/cypress/integration/control/checkbox.spec.ts b/cypress/integration/control/checkbox.spec.ts index 636331f..85bfe0a 100644 --- a/cypress/integration/control/checkbox.spec.ts +++ b/cypress/integration/control/checkbox.spec.ts @@ -34,9 +34,7 @@ describe('控件-复选框', () => { } }]) - const payload = editor.command.getValue() - - const data = payload.data[0] + const data = editor.command.getValue().data.main[0] expect(data.control!.code).to.be.eq('98175') }) diff --git a/cypress/integration/control/select.spec.ts b/cypress/integration/control/select.spec.ts index 5044b1f..7cae816 100644 --- a/cypress/integration/control/select.spec.ts +++ b/cypress/integration/control/select.spec.ts @@ -41,9 +41,7 @@ describe('控件-列举型', () => { .eq(0) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data[0] + const data = editor.command.getValue().data.main[0] expect(data.control!.value![0].value).to.be.eq(text) diff --git a/cypress/integration/control/text.spec.ts b/cypress/integration/control/text.spec.ts index 16706c5..c958e04 100644 --- a/cypress/integration/control/text.spec.ts +++ b/cypress/integration/control/text.spec.ts @@ -33,9 +33,7 @@ describe('控件-文本型', () => { cy.get('.ce-inputarea') .type(text) .then(() => { - const payload = editor.command.getValue() - - const data = payload.data[0] + const data = editor.command.getValue().data.main[0] expect(data.control!.value![0].value).to.be.eq(text) }) diff --git a/cypress/integration/editor.spec.ts b/cypress/integration/editor.spec.ts index 11609c1..5efca61 100644 --- a/cypress/integration/editor.spec.ts +++ b/cypress/integration/editor.spec.ts @@ -19,9 +19,9 @@ describe('基础功能', () => { cy.get('@canvas') .type(text) .then(() => { - const payload = editor.command.getValue() + const data = editor.command.getValue().data.main - expect(payload.data[0].value).to.eq(text) + expect(data[0].value).to.eq(text) }) }) }) diff --git a/cypress/integration/menus/block.spec.ts b/cypress/integration/menus/block.spec.ts index 56c3c0c..901cd7a 100644 --- a/cypress/integration/menus/block.spec.ts +++ b/cypress/integration/menus/block.spec.ts @@ -28,9 +28,7 @@ describe('菜单-内容块', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('block') diff --git a/cypress/integration/menus/checkbox.spec.ts b/cypress/integration/menus/checkbox.spec.ts index 6a5ed07..94d873f 100644 --- a/cypress/integration/menus/checkbox.spec.ts +++ b/cypress/integration/menus/checkbox.spec.ts @@ -24,9 +24,7 @@ describe('菜单-复选框', () => { } }]) - const payload = editor.command.getValue() - - const data = payload.data[0] + const data = editor.command.getValue().data.main[0] expect(data.checkbox?.value).to.eq(true) }) diff --git a/cypress/integration/menus/codeblock.spec.ts b/cypress/integration/menus/codeblock.spec.ts index fdc325b..900beac 100644 --- a/cypress/integration/menus/codeblock.spec.ts +++ b/cypress/integration/menus/codeblock.spec.ts @@ -24,9 +24,7 @@ describe('菜单-代码块', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data[2] + const data = editor.command.getValue().data.main[2] expect(data.value).to.eq('log') diff --git a/cypress/integration/menus/date.spec.ts b/cypress/integration/menus/date.spec.ts index f8ed076..9bd959c 100644 --- a/cypress/integration/menus/date.spec.ts +++ b/cypress/integration/menus/date.spec.ts @@ -20,9 +20,7 @@ describe('菜单-日期选择器', () => { .first() .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('date') }) diff --git a/cypress/integration/menus/format.spec.ts b/cypress/integration/menus/format.spec.ts index cbfb561..d64544c 100644 --- a/cypress/integration/menus/format.spec.ts +++ b/cypress/integration/menus/format.spec.ts @@ -28,9 +28,7 @@ describe('菜单-清除格式', () => { cy.get('.menu-item__format') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].italic).to.eq(false) diff --git a/cypress/integration/menus/hyperlink.spec.ts b/cypress/integration/menus/hyperlink.spec.ts index 98d1d19..abad25c 100644 --- a/cypress/integration/menus/hyperlink.spec.ts +++ b/cypress/integration/menus/hyperlink.spec.ts @@ -27,9 +27,7 @@ describe('菜单-超链接', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('hyperlink') diff --git a/cypress/integration/menus/image.spec.ts b/cypress/integration/menus/image.spec.ts index d8961f4..e0e6795 100644 --- a/cypress/integration/menus/image.spec.ts +++ b/cypress/integration/menus/image.spec.ts @@ -17,8 +17,8 @@ describe('菜单-图片', () => { cy.get('#image').attachFile('test.png') cy.wait(200).then(() => { - const payload = editor.command.getValue() - const data = payload.data + const data = editor.command.getValue().data.main + expect(data[0].type).to.eq('image') }) }) diff --git a/cypress/integration/menus/latex.spec.ts b/cypress/integration/menus/latex.spec.ts index 1237ce2..064a6b1 100644 --- a/cypress/integration/menus/latex.spec.ts +++ b/cypress/integration/menus/latex.spec.ts @@ -24,9 +24,7 @@ describe('菜单-LaTeX', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('latex') diff --git a/cypress/integration/menus/painter.spec.ts b/cypress/integration/menus/painter.spec.ts index fd5071a..13f4b86 100644 --- a/cypress/integration/menus/painter.spec.ts +++ b/cypress/integration/menus/painter.spec.ts @@ -36,9 +36,7 @@ describe('菜单-格式刷', () => { editor.command.executeApplyPainterStyle() - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data.length).to.eq(1) diff --git a/cypress/integration/menus/row.spec.ts b/cypress/integration/menus/row.spec.ts index 771ac6a..d100ab1 100644 --- a/cypress/integration/menus/row.spec.ts +++ b/cypress/integration/menus/row.spec.ts @@ -23,9 +23,7 @@ describe('菜单-行处理', () => { cy.get('.menu-item__left') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].rowFlex).to.eq('left') }) @@ -45,9 +43,7 @@ describe('菜单-行处理', () => { cy.get('.menu-item__center') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].rowFlex).to.eq('center') }) @@ -67,9 +63,7 @@ describe('菜单-行处理', () => { cy.get('.menu-item__right') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].rowFlex).to.eq('right') }) @@ -93,9 +87,7 @@ describe('菜单-行处理', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].rowMargin).to.eq(1.25) }) diff --git a/cypress/integration/menus/search.spec.ts b/cypress/integration/menus/search.spec.ts index cbeacd3..4805322 100644 --- a/cypress/integration/menus/search.spec.ts +++ b/cypress/integration/menus/search.spec.ts @@ -93,9 +93,7 @@ describe('菜单-搜索', () => { .find('button') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main // 普通文本 expect(data[0].value).to.be.eq(replaceText) diff --git a/cypress/integration/menus/separator.spec.ts b/cypress/integration/menus/separator.spec.ts index 334e68f..91ba5c4 100644 --- a/cypress/integration/menus/separator.spec.ts +++ b/cypress/integration/menus/separator.spec.ts @@ -20,9 +20,7 @@ describe('菜单-分割线', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('separator') diff --git a/cypress/integration/menus/table.spec.ts b/cypress/integration/menus/table.spec.ts index 54325e7..6c5aec6 100644 --- a/cypress/integration/menus/table.spec.ts +++ b/cypress/integration/menus/table.spec.ts @@ -16,9 +16,7 @@ describe('菜单-表格', () => { editor.command.executeInsertTable(8, 8) - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('table') diff --git a/cypress/integration/menus/text.spec.ts b/cypress/integration/menus/text.spec.ts index f8890ef..12aa394 100644 --- a/cypress/integration/menus/text.spec.ts +++ b/cypress/integration/menus/text.spec.ts @@ -30,9 +30,7 @@ describe('菜单-文本处理', () => { .eq(1) .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].font).to.eq('宋体') }) @@ -54,9 +52,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__size-add') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].size).to.eq(18) }) @@ -78,9 +74,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__size-minus') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].size).to.eq(14) }) @@ -102,9 +96,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__bold') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].bold).to.eq(true) }) @@ -126,9 +118,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__italic') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].italic).to.eq(true) }) @@ -150,9 +140,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__underline') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].underline).to.eq(true) }) @@ -174,9 +162,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__strikeout') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].strikeout).to.eq(true) }) @@ -198,9 +184,7 @@ describe('菜单-文本处理', () => { cy.get('.menu-item__superscript') .click() .then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('superscript') }) @@ -220,9 +204,7 @@ describe('菜单-文本处理', () => { editor.command.executeSetRange(0, textLength) cy.get('.menu-item__subscript').click().then(() => { - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].type).to.eq('subscript') }) @@ -243,9 +225,7 @@ describe('菜单-文本处理', () => { editor.command.executeColor('red') - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].color).to.eq('red') }) @@ -265,9 +245,7 @@ describe('菜单-文本处理', () => { editor.command.executeHighlight('red') - const payload = editor.command.getValue() - - const data = payload.data + const data = editor.command.getValue().data.main expect(data[0].highlight).to.eq('red') }) diff --git a/cypress/integration/menus/undoRedo.spec.ts b/cypress/integration/menus/undoRedo.spec.ts index c9fa2df..63b376d 100644 --- a/cypress/integration/menus/undoRedo.spec.ts +++ b/cypress/integration/menus/undoRedo.spec.ts @@ -21,9 +21,9 @@ describe('菜单-撤销&重做', () => { cy.get('.menu-item__undo') .click() .then(() => { - const payload = editor.command.getValue() + const data = editor.command.getValue().data.main - expect(payload.data[0].value).to.eq(text) + expect(data[0].value).to.eq(text) }) }) }) @@ -41,9 +41,9 @@ describe('菜单-撤销&重做', () => { cy.get('.menu-item__redo') .click() .then(() => { - const payload = editor.command.getValue() + const data = editor.command.getValue().data.main - expect(payload.data[0].value).to.eq(`${text}1`) + expect(data[0].value).to.eq(`${text}1`) }) }) })