From b1ceb3c9119a555eb2aeea1298867df2a5d15c7a Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Thu, 20 Feb 2020 16:50:04 -0800 Subject: [PATCH] Add Clipboard unit tests --- cypress/integration/ui/clipboard.js | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 cypress/integration/ui/clipboard.js diff --git a/cypress/integration/ui/clipboard.js b/cypress/integration/ui/clipboard.js new file mode 100644 index 00000000..a9ba05e9 --- /dev/null +++ b/cypress/integration/ui/clipboard.js @@ -0,0 +1,63 @@ +import { + visitAndApproveStorage +} from '../../support/ui-test-helper.js'; + +describe('UI - Clipboard', function () { + beforeEach(() => { + visitAndApproveStorage(); + }); + + it('Editor - Copy and paste', () => { + cy.get('#tool_source').click(); + + cy.get('#svg_source_textarea') + .type('{selectall}') + .type(` + + Layer 1 + + + `, {parseSpecialCharSequences: false}); + cy.get('#tool_source_save').click(); + cy.get('#testCircle').should('exist'); + cy.get('#svg_1').should('not.exist'); + cy.get('#svg_2').should('not.exist'); + + // Copy. + cy.get('#testCircle').click().rightclick(); + cy.get('#cmenu_canvas a[href="#copy"]').click(); + + // Paste. + // Scrollbars fail to recenter in Cypress test. Works fine in reality. + // Thus forcing click is needed since workspace is mostly offscreen. + cy.get('#svgroot').rightclick({force: true}); + cy.get('#cmenu_canvas a[href="#paste"]').click(); + cy.get('#testCircle').should('exist'); + cy.get('#svg_1').should('exist'); + cy.get('#svg_2').should('not.exist'); + + // Cut. + cy.get('#testCircle').click().rightclick(); + cy.get('#cmenu_canvas a[href="#cut"]').click(); + cy.get('#testCircle').should('not.exist'); + cy.get('#svg_1').should('exist'); + cy.get('#svg_2').should('not.exist'); + + // Paste. + // Scrollbars fail to recenter in Cypress test. Works fine in reality. + // Thus forcing click is needed since workspace is mostly offscreen. + cy.get('#svgroot').rightclick({force: true}); + cy.get('#cmenu_canvas a[href="#paste"]').click(); + cy.get('#testCircle').should('not.exist'); + cy.get('#svg_1').should('exist'); + cy.get('#svg_2').should('exist'); + + // Delete. + cy.get('#svg_2').click().rightclick(); + cy.get('#cmenu_canvas a[href="#delete"]').click(); + cy.get('#svg_1').click().rightclick(); + cy.get('#cmenu_canvas a[href="#delete"]').click(); + cy.get('#svg_1').should('not.exist'); + cy.get('#svg_2').should('not.exist'); + }); +});