chore: upgrade cypress version

This commit is contained in:
Hufe921
2023-11-29 20:07:59 +08:00
parent 6b30e3ca9d
commit ecd4ae9652
32 changed files with 382 additions and 241 deletions
@@ -1,7 +1,6 @@
import Editor, { ControlType, ElementType } from '../../../src/editor'
describe('控件-复选框', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -17,27 +16,31 @@ describe('控件-复选框', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
type: elementType,
value: '',
control: {
code: '98175',
type: controlType,
value: null,
valueSets: [{
value: '有',
code: '98175'
}, {
value: '无',
code: '98176'
}]
editor.command.executeInsertElementList([
{
type: elementType,
value: '',
control: {
code: '98175',
type: controlType,
value: null,
valueSets: [
{
value: '有',
code: '98175'
},
{
value: '无',
code: '98176'
}
]
}
}
}])
])
const data = editor.command.getValue().data.main[0]
expect(data.control!.code).to.be.eq('98175')
})
})
})
@@ -1,7 +1,6 @@
import Editor, { ControlType, ElementType } from '../../../src/editor'
describe('控件-列举型', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -18,22 +17,27 @@ describe('控件-列举型', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
type: elementType,
value: '',
control: {
type: controlType,
value: null,
placeholder: '列举型',
valueSets: [{
value: '有',
code: '98175'
}, {
value: '无',
code: '98176'
}]
editor.command.executeInsertElementList([
{
type: elementType,
value: '',
control: {
type: controlType,
value: null,
placeholder: '列举型',
valueSets: [
{
value: '有',
code: '98175'
},
{
value: '无',
code: '98176'
}
]
}
}
}])
])
cy.get('@canvas').type(`{leftArrow}`)
@@ -49,5 +53,4 @@ describe('控件-列举型', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor, { ControlType, ElementType } from '../../../src/editor'
describe('控件-文本型', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -18,15 +17,17 @@ describe('控件-文本型', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
type: elementType,
value: '',
control: {
type: controlType,
value: null,
placeholder: '文本型'
editor.command.executeInsertElementList([
{
type: elementType,
value: '',
control: {
type: controlType,
value: null,
placeholder: '文本型'
}
}
}])
])
cy.get('@canvas').type(`{leftArrow}`)
@@ -39,5 +40,4 @@ describe('控件-文本型', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../src/editor'
describe('基础功能', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -51,17 +50,18 @@ describe('基础功能', () => {
})
it('字数统计', () => {
cy.getEditor().then(async (editor: Editor) => {
cy.getEditor().then((editor: Editor) => {
editor.command.executeSelectAll()
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: 'canvas-editor 2022 编辑器'
}])
editor.command.executeInsertElementList([
{
value: 'canvas-editor 2022 编辑器'
}
])
cy.get('.word-count').contains('7')
})
})
})
@@ -9,7 +9,6 @@ describe('菜单-内容块', () => {
cy.get('canvas').first().as('canvas').should('have.length', 1)
})
it('内容块', () => {
cy.getEditor().then((editor: Editor) => {
editor.command.executeSelectAll()
@@ -36,5 +35,4 @@ describe('菜单-内容块', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor, { ElementType } from '../../../src/editor'
describe('菜单-复选框', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -16,18 +15,19 @@ describe('菜单-复选框', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
type,
value: '',
checkbox: {
value: true
editor.command.executeInsertElementList([
{
type,
value: '',
checkbox: {
value: true
}
}
}])
])
const data = editor.command.getValue().data.main[0]
expect(data.checkbox?.value).to.eq(true)
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-代码块', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -32,5 +31,4 @@ describe('菜单-代码块', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-日期选择器', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -26,5 +25,4 @@ describe('菜单-日期选择器', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-清除格式', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -17,11 +16,13 @@ describe('菜单-清除格式', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text,
bold: true,
italic: true
}])
editor.command.executeInsertElementList([
{
value: text,
bold: true,
italic: true
}
])
editor.command.executeSetRange(0, textLength)
@@ -36,5 +37,4 @@ describe('菜单-清除格式', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-超链接', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -37,5 +36,4 @@ describe('菜单-超链接', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-图片', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -23,5 +22,4 @@ describe('菜单-图片', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-LaTeX', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -32,5 +31,4 @@ describe('菜单-LaTeX', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-分页符', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -9,7 +8,6 @@ describe('菜单-分页符', () => {
})
it('分页符', () => {
cy.getEditor().then((editor: Editor) => {
editor.command.executeSelectAll()
@@ -19,7 +17,5 @@ describe('菜单-分页符', () => {
cy.get('canvas').should('have.length', 2)
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-格式刷', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -17,15 +16,19 @@ describe('菜单-格式刷', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text,
bold: true,
italic: true
}])
editor.command.executeInsertElementList([
{
value: text,
bold: true,
italic: true
}
])
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -46,5 +49,4 @@ describe('菜单-格式刷', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-打印', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -9,7 +8,6 @@ describe('菜单-打印', () => {
})
it('打印', () => {
cy.getEditor().then(async (editor: Editor) => {
const imageList2 = await editor.command.getImage()
expect(imageList2.length).to.eq(2)
@@ -23,7 +21,5 @@ describe('菜单-打印', () => {
expect(imageList1.length).to.eq(1)
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-行处理', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -16,9 +15,11 @@ describe('菜单-行处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
cy.get('.menu-item__left')
.click()
@@ -36,9 +37,11 @@ describe('菜单-行处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
cy.get('.menu-item__center')
.click()
@@ -56,9 +59,11 @@ describe('菜单-行处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
cy.get('.menu-item__right')
.click()
@@ -76,9 +81,11 @@ describe('菜单-行处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
cy.get('.menu-item__row-margin').as('rowMargin').click()
@@ -93,5 +100,4 @@ describe('菜单-行处理', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor, { ElementType } from '../../../src/editor'
describe('菜单-搜索', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -82,8 +81,10 @@ describe('菜单-搜索', () => {
// 搜索导航
cy.get('.menu-item__search__collapse .arrow-right').click()
cy.get('.menu-item__search__collapse__search .search-result')
.should('have.text', '1/3')
cy.get('.menu-item__search__collapse__search .search-result').should(
'have.text',
'1/3'
)
cy.get('.menu-item__search__collapse__replace').as('replace')
@@ -99,10 +100,13 @@ describe('菜单-搜索', () => {
expect(data[0].value).to.be.eq(replaceText)
// 表格内文本
expect(data[1].trList![0].tdList[0].value[0].value).to.be.eq(replaceText)
expect(data[1].trList![1].tdList[1].value[0].value).to.be.eq(replaceText)
expect(data[1].trList![0].tdList[0].value[0].value).to.be.eq(
replaceText
)
expect(data[1].trList![1].tdList[1].value[0].value).to.be.eq(
replaceText
)
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-分割线', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -30,5 +29,4 @@ describe('菜单-分割线', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-表格', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -23,5 +22,4 @@ describe('菜单-表格', () => {
expect(data[0].trList?.length).to.eq(8)
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-文本处理', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -17,9 +16,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -43,9 +44,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -69,9 +72,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -91,9 +96,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -113,9 +120,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -135,9 +144,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -157,9 +168,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -179,9 +192,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -201,9 +216,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -223,17 +240,21 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
cy.get('.menu-item__subscript').click().then(() => {
const data = editor.command.getValue().data.main
cy.get('.menu-item__subscript')
.click()
.then(() => {
const data = editor.command.getValue().data.main
expect(data[0].type).to.eq('subscript')
})
expect(data[0].type).to.eq('subscript')
})
})
})
@@ -243,9 +264,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -263,9 +286,11 @@ describe('菜单-文本处理', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
editor.command.executeSetRange(0, textLength)
@@ -276,5 +301,4 @@ describe('菜单-文本处理', () => {
expect(data[0].highlight).to.eq('red')
})
})
})
@@ -19,9 +19,11 @@ describe('菜单-标题', () => {
editor.command.executeBackspace()
editor.command.executeInsertElementList([{
value: text
}])
editor.command.executeInsertElementList([
{
value: text
}
])
cy.get('.menu-item__title').as('title').click()
@@ -38,5 +40,4 @@ describe('菜单-标题', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-撤销&重做', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -47,5 +46,4 @@ describe('菜单-撤销&重做', () => {
})
})
})
})
@@ -1,7 +1,6 @@
import Editor from '../../../src/editor'
describe('菜单-水印', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
@@ -58,5 +57,4 @@ describe('菜单-水印', () => {
})
})
})
})
+1 -1
View File
@@ -1,3 +1,3 @@
{
"name": "canvas-editor"
}
}
-3
View File
@@ -7,10 +7,7 @@ declare namespace Editor {
}
declare namespace Cypress {
interface Chainable {
getEditor(): Chainable<Editor>
}
}
-11
View File
@@ -1,11 +0,0 @@
/// <reference types="cypress" />
/**
* @type {Cypress.PluginConfig}
*/
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// codeCoverageTask(on, config)
return config
}
+1 -1
View File
@@ -2,4 +2,4 @@ import 'cypress-file-upload'
Cypress.Commands.add('getEditor', () => {
return cy.window().its('editor')
})
})