parent
444986ad23
commit
af1f86eaa2
@ -0,0 +1,104 @@
|
||||
import Editor, { ElementType } from '../../../src/editor'
|
||||
|
||||
describe('菜单-搜索', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visit('http://localhost:3000/canvas-editor/')
|
||||
|
||||
cy.get('canvas').first().as('canvas').should('have.length', 1)
|
||||
})
|
||||
|
||||
const searchText = 'canvas-editor'
|
||||
const replaceText = 'replace'
|
||||
const type: ElementType = <ElementType>'table'
|
||||
|
||||
it('搜索', () => {
|
||||
cy.getEditor().then((editor: Editor) => {
|
||||
editor.listener.saved = function (payload) {
|
||||
const data = payload.data
|
||||
|
||||
// 普通文本
|
||||
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)
|
||||
}
|
||||
|
||||
editor.command.executeSelectAll()
|
||||
|
||||
editor.command.executeBackspace()
|
||||
|
||||
editor.command.executeInsertElementList([
|
||||
{
|
||||
value: searchText
|
||||
},
|
||||
{
|
||||
value: "\n",
|
||||
type,
|
||||
trList: [
|
||||
{
|
||||
height: 42,
|
||||
tdList: [
|
||||
{
|
||||
colspan: 1,
|
||||
rowspan: 1,
|
||||
value: [
|
||||
{
|
||||
value: searchText
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
colspan: 1,
|
||||
rowspan: 1,
|
||||
value: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
height: 42,
|
||||
tdList: [
|
||||
{
|
||||
colspan: 1,
|
||||
rowspan: 1,
|
||||
value: []
|
||||
},
|
||||
{
|
||||
colspan: 1,
|
||||
rowspan: 1,
|
||||
value: [
|
||||
{
|
||||
value: searchText
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
colgroup: [
|
||||
{
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
width: 200
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
cy.get('.menu-item__search').click()
|
||||
|
||||
cy.get('.menu-item__search__collapse input').eq(0).type(searchText)
|
||||
|
||||
cy.get('.menu-item__search__collapse__replace').as('replace')
|
||||
|
||||
cy.get('@replace').find('input').type(replaceText)
|
||||
|
||||
cy.get('@replace').find('button').click()
|
||||
|
||||
cy.get('@canvas').type('{ctrl}s')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
Loading…
Reference in new issue