feat:add image test case

pr675
Hufe921 4 years ago
parent 6de0ee8e64
commit 3896b86b5d

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

@ -0,0 +1,28 @@
import Editor from '../../../src/editor'
describe('菜单-图片', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/canvas-editor/')
cy.get('canvas').first().as('canvas').should('have.length', 1)
})
it('图片', () => {
cy.getEditor().then((editor: Editor) => {
editor.listener.saved = function (payload) {
const data = payload.data
expect(data[0].type).to.eq('image')
}
editor.command.executeSelectAll()
editor.command.executeBackspace()
cy.get('#image').attachFile('test.png')
cy.get('@canvas').type('{ctrl}s')
})
})
})

@ -1,3 +1,5 @@
import 'cypress-file-upload'
Cypress.Commands.add('getEditor', () => { Cypress.Commands.add('getEditor', () => {
return cy.window().its('editor') return cy.window().its('editor')
}) })

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": ["es2015", "dom", "esnext"], "lib": ["es2015", "dom", "esnext"],
"types": ["cypress"], "types": ["cypress", "cypress-file-upload"],
"isolatedModules": false, "isolatedModules": false,
"allowJs": true, "allowJs": true,
"noEmit": true, "noEmit": true,

@ -12,6 +12,7 @@
"@types/node": "^16.11.12", "@types/node": "^16.11.12",
"@types/prismjs": "^1.26.0", "@types/prismjs": "^1.26.0",
"cypress": "^9.5.1", "cypress": "^9.5.1",
"cypress-file-upload": "^5.0.8",
"typescript": "^4.3.2", "typescript": "^4.3.2",
"vite": "^2.4.2" "vite": "^2.4.2"
}, },

@ -313,6 +313,11 @@ cross-spawn@^7.0.0:
shebang-command "^2.0.0" shebang-command "^2.0.0"
which "^2.0.1" which "^2.0.1"
cypress-file-upload@^5.0.8:
version "5.0.8"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==
cypress@^9.5.1: cypress@^9.5.1:
version "9.5.1" version "9.5.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.5.1.tgz#51162f3688cedf5ffce311b914ef49a7c1ece076" resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.5.1.tgz#51162f3688cedf5ffce311b914ef49a7c1ece076"

Loading…
Cancel
Save