svgedit/cypress/integration/ui/clipboard.js

64 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-02-21 00:50:04 +00:00
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')
2021-05-12 23:00:09 +00:00
.type('{selectall}', { force: true })
2020-02-21 00:50:04 +00:00
.type(`<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
<g class="layer">
<title>Layer 1</title>
<circle cx="100" cy="100" r="50" fill="#FF0000" id="testCircle" stroke="#000000" stroke-width="5"/>
</g>
2021-05-12 23:00:09 +00:00
</svg>`, { force: true, parseSpecialCharSequences: false });
2020-02-21 00:50:04 +00:00
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();
2021-05-12 23:00:09 +00:00
cy.get('#cmenu_canvas a[href="#copy"]').click({ force: true });
2020-02-21 00:50:04 +00:00
// Paste.
// Scrollbars fail to recenter in Cypress test. Works fine in reality.
// Thus forcing click is needed since workspace is mostly offscreen.
2021-05-12 23:00:09 +00:00
cy.get('#svgroot').rightclick({ force: true });
cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true });
2020-02-21 00:50:04 +00:00
cy.get('#testCircle').should('exist');
cy.get('#svg_1').should('exist');
cy.get('#svg_2').should('not.exist');
// Cut.
cy.get('#testCircle').click().rightclick();
2021-05-12 23:00:09 +00:00
cy.get('#cmenu_canvas a[href="#cut"]').click({ force: true });
2020-02-21 00:50:04 +00:00
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.
2021-05-12 23:00:09 +00:00
cy.get('#svgroot').rightclick({ force: true });
cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true });
2020-02-21 00:50:04 +00:00
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();
2021-05-12 23:00:09 +00:00
cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true });
2020-02-21 00:50:04 +00:00
cy.get('#svg_1').click().rightclick();
2021-05-12 23:00:09 +00:00
cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true });
2020-02-21 00:50:04 +00:00
cy.get('#svg_1').should('not.exist');
cy.get('#svg_2').should('not.exist');
});
});