From cc2bbde8e109324f72c1921cfc5adc7769f16bad Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Thu, 26 Aug 2021 16:44:00 +0530 Subject: [PATCH 1/4] #623 rect, square and fhrect cypress test cases added --- .../ui/__snapshots__/scenario4.js.snap | 965 ++++++++++++++++++ cypress/integration/ui/scenario4.js | 144 +++ 2 files changed, 1109 insertions(+) create mode 100644 cypress/integration/ui/__snapshots__/scenario4.js.snap create mode 100644 cypress/integration/ui/scenario4.js diff --git a/cypress/integration/ui/__snapshots__/scenario4.js.snap b/cypress/integration/ui/__snapshots__/scenario4.js.snap new file mode 100644 index 00000000..0716bc69 --- /dev/null +++ b/cypress/integration/ui/__snapshots__/scenario4.js.snap @@ -0,0 +1,965 @@ +exports[`use all parts of svg-edit > check tool_source_set #0`] = ` + + Layer 1 + +`; + +exports[`use all parts of svg-edit > check tool_rect #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_fhrect #0`] = ` + + + Layer 1 + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_square #0`] = ` + + + Layer 1 + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_change_fill_color #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_change_rotation #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_change_blur #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_change_opacity #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_fhrect_change_x_y_coordinate #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_fhrect_change_width_height #0`] = ` + + + Layer 1 + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_square_clone #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_square_bring_to_back #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_square_bring_to_front #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_square_change_corner_radius #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_change_to_path #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_rect_delete #0`] = ` + + + Layer 1 + + + + + + + + + +`; diff --git a/cypress/integration/ui/scenario4.js b/cypress/integration/ui/scenario4.js new file mode 100644 index 00000000..3553f4e2 --- /dev/null +++ b/cypress/integration/ui/scenario4.js @@ -0,0 +1,144 @@ +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_rect', function () { + cy.get('#tool_rect') + .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_fhrect', function () { + cy.get('#tool_fhrect') + .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_square', function () { + cy.get('#tool_square').click({ force: true }); + cy.get('#svgcontent') + .trigger('mousedown', 75, 150, { force: true }) + .trigger('mousemove', 125, 200, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_rect_change_fill_color', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#js-se-palette').find('.square').eq(8) + .click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_rect_change_rotation', function () { + cy.get('#svg_1').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_rect_change_blur', function () { + cy.get('#svg_1').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_rect_change_opacity', function () { + cy.get('#svg_1').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_fhrect_change_x_y_coordinate', function () { + cy.get('#svg_2').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_fhrect_change_width_height', function () { + cy.get('#svg_2').click({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#rect_width').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('#rect_height').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_square_clone', function () { + cy.get('#svg_3').click({ force: true }); + cy.get('#tool_clone').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_square_bring_to_back', function () { + cy.get('#svg_3').click({ force: true }); + cy.get('#tool_move_bottom').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_square_bring_to_front', function () { + cy.get('#svg_3').click({ force: true }); + cy.get('#tool_move_top').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_square_change_corner_radius', function () { + cy.get('#svg_4').click({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#rect_rx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_rect_change_to_path', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#tool_topath').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_rect_delete', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#tool_delete').click({ force: true }); + cy.get('#svg_3').click({ force: true }); + cy.get('#tool_delete').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); +}); From 2414f85f4a8dd3bc3831bf1bcf9fc7941b235ed8 Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Thu, 26 Aug 2021 17:43:33 +0530 Subject: [PATCH 2/4] #623 se-input changes event trigger issue fixed --- src/editor/components/seInput.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/editor/components/seInput.js b/src/editor/components/seInput.js index 4d386e5c..e19e1dbf 100644 --- a/src/editor/components/seInput.js +++ b/src/editor/components/seInput.js @@ -154,11 +154,16 @@ export class SEInput extends HTMLElement { * @returns {void} */ connectedCallback () { - this.addEventListener('change', (e) => { + this.$input.addEventListener('change', (e) => { e.preventDefault(); this.value = e.target.value; + this.dispatchEvent(this.$event); + }); + this.$input.addEventListener('keyup', (e) => { + e.preventDefault(); + this.value = e.target.value; + this.dispatchEvent(this.$event); }); - this.dispatchEvent(this.$event); } } // Register From 40d547ae0f5f6a2a1b8f197e9ca6068c948245a1 Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Thu, 26 Aug 2021 19:19:45 +0530 Subject: [PATCH 3/4] #623 test cases added --- .../ui/__snapshots__/scenario4.js.snap | 40 +++++++------------ cypress/integration/ui/scenario4.js | 24 ++++++++++- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/cypress/integration/ui/__snapshots__/scenario4.js.snap b/cypress/integration/ui/__snapshots__/scenario4.js.snap index 0716bc69..57e732f8 100644 --- a/cypress/integration/ui/__snapshots__/scenario4.js.snap +++ b/cypress/integration/ui/__snapshots__/scenario4.js.snap @@ -440,15 +440,13 @@ exports[`use all parts of svg-edit > check tool_fhrect_change_x_y_coordinate #0` fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="120" height="100" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_fhrect_change_width_height #0`] fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="145" height="125" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_square_clone #0`] = ` fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="145" height="125" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_square_bring_to_back #0`] = ` fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="145" height="125" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_square_bring_to_front #0`] = ` fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="145" height="125" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_square_change_corner_radius #0`] fill="#FF0000" stroke="#000000" stroke-width="5" - x="350" - y="230" + x="375" + y="255" width="145" height="125" id="svg_2" fill-opacity="1" stroke-opacity="1" - cx="25" - cy="25" > check tool_rect_change_to_path #0`] = ` stroke="#000000" stroke-width="5" opacity="0.5" - d="M350,230 L495,230 L495,355 L350,355 L350,230 Z" + d="M375,255 L520,255 L520,380 L375,380 L375,255 Z" id="svg_2" fill-opacity="1" stroke-opacity="1" @@ -936,7 +924,7 @@ exports[`use all parts of svg-edit > check tool_rect_delete #0`] = ` stroke="#000000" stroke-width="5" opacity="0.5" - d="M350,230 L495,230 L495,355 L350,355 L350,230 Z" + d="M375,255 L520,255 L520,380 L375,380 L375,255 Z" id="svg_2" fill-opacity="1" stroke-opacity="1" diff --git a/cypress/integration/ui/scenario4.js b/cypress/integration/ui/scenario4.js index 3553f4e2..36b52d98 100644 --- a/cypress/integration/ui/scenario4.js +++ b/cypress/integration/ui/scenario4.js @@ -85,11 +85,11 @@ describe('use all parts of svg-edit', function () { it('check tool_fhrect_change_x_y_coordinate', function () { cy.get('#svg_2').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) + cy.get('#selected_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('#ellipse_cy').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) + cy.get('#selected_y').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0) .click({ force: true }); } cy.get('#svgcontent').toMatchSnapshot(); @@ -141,4 +141,24 @@ describe('use all parts of svg-edit', function () { cy.get('#tool_delete').click({ force: true }); cy.get('#svgcontent').toMatchSnapshot(); }); + it('check tool_rect_change_class', function () { + cy.get('#svg_2').click({ force: true }); + cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0) + .type('svg_2_class{enter}', { force: true }); + cy.get('#svg_2') + .should('satisfy', ($el) => { + const classList = Array.from($el[0].classList); + return classList.includes('svg_2_class'); + }); + }); + it('check tool_rect_change_id', function () { + cy.get('#svg_2').click({ force: true }).click({ force: true }); + cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0) + .type('_id{enter}', { force: true }); + cy.get('#svg_2_id') + .should('satisfy', ($el) => { + const classList = Array.from($el[0].classList); + return classList.includes('svg_2_class'); + }); + }); }); From d07153865ebad827603ff07c6568807aa57e09b5 Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Thu, 26 Aug 2021 22:09:50 +0530 Subject: [PATCH 4/4] #623 line tool test cases added --- .../ui/__snapshots__/scenario5.js.snap | 312 ++++++++++++++++++ cypress/integration/ui/scenario5.js | 117 +++++++ 2 files changed, 429 insertions(+) create mode 100644 cypress/integration/ui/__snapshots__/scenario5.js.snap create mode 100644 cypress/integration/ui/scenario5.js diff --git a/cypress/integration/ui/__snapshots__/scenario5.js.snap b/cypress/integration/ui/__snapshots__/scenario5.js.snap new file mode 100644 index 00000000..947b63a5 --- /dev/null +++ b/cypress/integration/ui/__snapshots__/scenario5.js.snap @@ -0,0 +1,312 @@ +exports[`use all parts of svg-edit > check tool_source_set #0`] = ` + + Layer 1 + +`; + +exports[`use all parts of svg-edit > check tool_line #0`] = ` + + + Layer 1 + + + + + +`; + +exports[`use all parts of svg-edit > check tool_line_change_rotation #0`] = ` + + + Layer 1 + + + +`; + +exports[`use all parts of svg-edit > check tool_line_change_blur #0`] = ` + + + Layer 1 + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_line_change_opacity #0`] = ` + + + Layer 1 + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_line_delete #0`] = ` + + + Layer 1 + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_line_clone #0`] = ` + + + Layer 1 + + + + + + + + + + + + + +`; + +exports[`use all parts of svg-edit > check tool_fhrect_change_x_y_coordinate #0`] = ` + + + Layer 1 + + + + + + + + + + + +`; diff --git a/cypress/integration/ui/scenario5.js b/cypress/integration/ui/scenario5.js new file mode 100644 index 00000000..4fd22c95 --- /dev/null +++ b/cypress/integration/ui/scenario5.js @@ -0,0 +1,117 @@ +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_line', function () { + cy.get('#tool_line') + .click({ force: true }); + cy.get('#svgcontent') + .trigger('mousemove', 200, 200, { force: true }) + .trigger('mousedown', 200, 200, { force: true }) + .trigger('mousemove', 250, 250, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_line_change_class', function () { + cy.get('#svg_1').click({ force: true }); + cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0) + .type('svg_1_class{enter}', { force: true }); + cy.get('#svg_1') + .should('satisfy', ($el) => { + const classList = Array.from($el[0].classList); + return classList.includes('svg_1_class'); + }); + }); + it('check tool_line_change_id', function () { + cy.get('#svg_1').click({ force: true }).click({ force: true }); + cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0) + .type('_id{enter}', { force: true }); + cy.get('#svg_1_id') + .should('satisfy', ($el) => { + const classList = Array.from($el[0].classList); + return classList.includes('svg_1_class'); + }); + }); + it('check tool_line_change_rotation', function () { + cy.get('#svg_1_id').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_line_change_blur', function () { + cy.get('#svg_1_id').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_line_change_opacity', function () { + cy.get('#svg_1_id').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_line_delete', function () { + cy.get('#svg_1_id').click({ force: true }); + cy.get('#tool_delete').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_line_clone', function () { + cy.get('#tool_line') + .click({ force: true }); + cy.get('#svgcontent') + .trigger('mousemove', 200, 200, { force: true }) + .trigger('mousedown', 200, 200, { force: true }) + .trigger('mousemove', 250, 250, { force: true }) + .trigger('mouseup', { force: true }); + cy.get('#svg_2').click({ force: true }); + cy.get('#tool_clone').click({ force: true }); + cy.get('#svgcontent').toMatchSnapshot(); + }); + it('check tool_fhrect_change_x_y_coordinate', function () { + cy.get('#svg_2').click({ force: true }); + for(let n = 0; n < 25; n ++){ + cy.get('#line_x1').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('#line_y1').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0) + .click({ force: true }); + } + for(let n = 0; n < 25; n ++){ + cy.get('#line_x2').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('#line_y2').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0) + .click({ force: true }); + } + cy.get('#svgcontent').toMatchSnapshot(); + }); +});