在过去的几个月里,我一直在为 SO 驱动的 SE 教育的最后阶段开发一个工作流建模器。我一直在使用mxGraph和 vanilla javascript,并尝试使用 Cypress 设置一些基本的 E2E 测试。
我在(我假设)触发事件侦听器时遇到了一些问题。有些按钮确实响应柏树点击/触发,而有些按钮则不响应。我的应用程序中的所有按钮都没有 onClick 操作或任何其他包含模型或控制器方法的属性。相反,所有按钮和键都有处理程序和侦听器,由 mxGraph-editor 实用程序类创建。
我尝试在 mxGraph 的公共示例上使用相同的 E2E 测试重新创建一些操作(请参阅柏树代码)。拖动对象(从菜单到画布(#1)和从画布到画布(#4))和选择对象(#2)很遗憾不起作用。
双击一个对象并修改文本(#3)确实有效……但我迷路了。我尝试了所有不同的强制、等待、点击和触发方式,但都无济于事。
describe('mxGraph "ports" example', function () {
it('Start ports example', function () {
cy.visit('https://jgraph.github.io/mxgraph/javascript/examples/ports.html')
cy.wait(500)
})
// Example #1 : FAIL
it('#1 Create new object by dragging', function () {
cy.get('div[id="sidebarContainer"]').find('img[title="Drag this to the diagram to create a new vertex"]').first()
.trigger('mousedown', { force: true})
.trigger('mousemove', { clientX: 250, clientY: 250, force: true})
.trigger('mouseup', {force: true})
cy.get('div[id="graphContainer"]').find('svg').trigger('drop', { force: true })
cy.wait(500)
})
})
describe('mxGraph "user object" example', function () {
it('Start userobject example', function () {
cy.visit('https://jgraph.github.io/mxgraph/javascript/examples/userobject.html')
cy.wait(500)
})
// Example #2 : FAIL
it('#2 Single click on object (green highlight should appear)', function () {
cy.get('rect').first().click({ force: true })
cy.wait(500)
})
// Example #3 : PASS
it('#3 Double click & edit object (Text should be modified)', function () {
cy.get('rect').first().dblclick({ force: true })
cy.wait(500)
cy.get('div [class="mxCellEditor mxPlainTextEditor"]').first().type('text modified')
cy.wait(500)
})
任何帮助是极大的赞赏。提前致谢!
偶然的你
相关分类