diff --git a/cypress/integration/ui/__snapshots__/scenario2.js.snap b/cypress/integration/ui/__snapshots__/scenario2.js.snap new file mode 100644 index 00000000..241be924 --- /dev/null +++ b/cypress/integration/ui/__snapshots__/scenario2.js.snap @@ -0,0 +1,717 @@ +exports[`use all parts of svg-edit > check tool_source_set #0`] = ` + + Layer 1 + +`; + +exports[`use all parts of svg-edit > check tool_circle #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_fhellipse #0`] = ` + + + Layer 1 + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse #0`] = ` + + + Layer 1 + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_circle_change_fill_color #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_circle_change_opacity #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_change_rotation #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_change_blur #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_change_cx_cy_coordinate #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_change_rx_ry_radius #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_bring_to_back #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_bring_to_front #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_ellipse_clone #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; diff --git a/cypress/integration/ui/__snapshots__/scenario3.js.snap b/cypress/integration/ui/__snapshots__/scenario3.js.snap new file mode 100644 index 00000000..597286a4 --- /dev/null +++ b/cypress/integration/ui/__snapshots__/scenario3.js.snap @@ -0,0 +1,158 @@ +exports[`use all parts of svg-edit > check tool_source_set #0`] = ` + + Layer 1 + +`; + +exports[`use all parts of svg-edit > check tool_path #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_path_change_node_xy #0`] = ` + + + Layer 1 + + + +`; + +exports[`use all parts of svg-edit > check tool_path_change_seg_type #0`] = ` + + + Layer 1 + + + +`; + +exports[`use all parts of svg-edit > check tool_path_change_clone_node #0`] = ` + + + Layer 1 + + + +`; + +exports[`use all parts of svg-edit > check tool_path_openclose #0`] = ` + + + Layer 1 + + + +`; diff --git a/cypress/integration/ui/scenario2.js b/cypress/integration/ui/scenario2.js new file mode 100644 index 00000000..c16a71be --- /dev/null +++ b/cypress/integration/ui/scenario2.js @@ -0,0 +1,124 @@ +import { + visitAndApproveStorage +} from '../../support/ui-test-helper.js'; + +const testSnapshot = () => { + cy.get('#svgcontent').cleanSnapshot(); +}; + +describe('use all parts of svg-edit', function () { + before(() => { + visitAndApproveStorage(); + }); + + it('check tool_source_set', function () { + cy.get('#tool_source').click({ force: true }); + cy.get('#svg_source_textarea') + .type('{selectall}', { force: true }) + .type(` + + Layer 1 + + `, { force: true, parseSpecialCharSequences: false }); + cy.get('#tool_source_save').click({ force: true }); + testSnapshot(); + }); + it('check tool_circle', function () { + cy.get('#tool_circle') + .click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 150, 150, { force: true }) + .trigger('mousemove', 250, 200, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_fhellipse', function () { + cy.get('#tool_fhellipse') + .click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 200, 80, { force: true }) + .trigger('mousemove', 320, 80, { force: true }) + .trigger('mousemove', 320, 180, { force: true }) + .trigger('mousemove', 200, 180, { force: true }) + .trigger('mousemove', 200, 80, { force: true }) + .trigger('mouseup', 200, 80, { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse', function () { + cy.get('#tool_ellipse').click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 75, 150, { force: true }) + .trigger('mousemove', 130, 175, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_circle_change_fill_color', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#js-se-palette').find('.square').eq(8) + .click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_circle_change_opacity', function () { + cy.get('#svg_2').click({ force: true }); + for(let n = 0; n < 10; n ++){ + cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_change_rotation', function () { + cy.get('#svg_3').click({ force: true }); + for(let n = 0; n < 5; n ++){ + cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_change_blur', function () { + cy.get('#svg_3').click({ force: true }); + for(let n = 0; n < 10; n ++){ + cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_change_cx_cy_coordinate', function () { + cy.get('#svg_3').click({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#ellipse_cx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + for(let n = 0; n < 25; n ++){ + cy.get('#ellipse_cy').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_change_rx_ry_radius', function () { + cy.get('#svg_3').click({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#ellipse_rx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + for(let n = 0; n < 25; n ++){ + cy.get('#ellipse_ry').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_bring_to_back', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#tool_move_bottom').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_bring_to_front', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#tool_move_top').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_ellipse_clone', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#tool_clone').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); +}); diff --git a/cypress/integration/ui/scenario3.js b/cypress/integration/ui/scenario3.js new file mode 100644 index 00000000..ca548f87 --- /dev/null +++ b/cypress/integration/ui/scenario3.js @@ -0,0 +1,100 @@ +import { + visitAndApproveStorage +} from '../../support/ui-test-helper.js'; + +const testSnapshot = () => { + cy.get('#svgcontent').cleanSnapshot(); +}; + +describe('use all parts of svg-edit', function () { + before(() => { + visitAndApproveStorage(); + }); + + it('check tool_source_set', function () { + cy.get('#tool_source').click({ force: true }); + cy.get('#svg_source_textarea') + .type('{selectall}', { force: true }) + .type(` + + Layer 1 + + `, { force: true, parseSpecialCharSequences: false }); + cy.get('#tool_source_save').click({ force: true }); + testSnapshot(); + }); + it('check tool_path', function () { + cy.get('#tool_path') + .click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 50, 50, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 100, 50, { force: true }) + .trigger('mousedown', 100, 50, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 75, 150, { force: true }) + .trigger('mousedown', 75, 150, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 0, 0, { force: true }) + .trigger('mousedown', 0, 0, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_path_change_node_xy', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#svg_1').dblclick({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#path_node_x').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + for(let n = 0; n < 25; n ++){ + cy.get('#path_node_y').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_path_change_seg_type', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#svg_1').dblclick({ force: true }); + cy.get('#seg_type').select('6').should('have.value', '6'); + cy.get('#ctrlpointgrip_3c1') + .trigger('mousedown', { force: true }) + .trigger('mousemove', 130, 175, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_path_change_clone_node', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#svg_1').dblclick({ force: true }); + cy.get('#tool_node_clone').click({ force: true }); + cy.get('#pathpointgrip_4') + .trigger('mousedown', { force: true }) + .trigger('mousemove', 130, 175, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_path_openclose', function () { + cy.get('#tool_select').click({ force: true }); + cy.get('#svg_1').click({ force: true }); + cy.get('#svg_1').dblclick({ force: true }); + cy.get('#tool_openclose_path').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + /* it('check tool_path_add_subpath', function () { + cy.get('#tool_add_subpath').click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 0, 0, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 100, 50, { force: true }) + .trigger('mousedown', 100, 50, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 75, 150, { force: true }) + .trigger('mousedown', 75, 150, { force: true }) + .trigger('mouseup', { force: true }) + .trigger('mousemove', 0, 0, { force: true }) + .trigger('mousedown', 0, 0, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#tool_select').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); */ +}); diff --git a/src/editor/EditorStartup.js b/src/editor/EditorStartup.js index 90a4bd57..1476ee80 100644 --- a/src/editor/EditorStartup.js +++ b/src/editor/EditorStartup.js @@ -358,17 +358,18 @@ class EditorStartup { }; const liElems = this.$svgEditor.querySelectorAll('button, select, input:not(#text)'); + const self = this; Array.prototype.forEach.call(liElems, function(el){ el.addEventListener("focus", (e) => { inp = e.currentTarget; - this.uiContext = 'toolbars'; - this.workarea.addEventListener('mousedown', unfocus); + self.uiContext = 'toolbars'; + self.workarea.addEventListener('mousedown', unfocus); }); el.addEventListener("blur", () => { - this.uiContext = 'canvas'; - this.workarea.removeEventListener('mousedown', unfocus); + self.uiContext = 'canvas'; + self.workarea.removeEventListener('mousedown', unfocus); // Go back to selecting text if in textedit mode - if (this.svgCanvas.getMode() === 'textedit') { + if (self.svgCanvas.getMode() === 'textedit') { $id('text').focus(); } });