svgedit/cypress/integration/ui/scenario.js

109 lines
3.4 KiB
JavaScript
Raw Normal View History

2020-09-12 23:32:13 +00:00
import {
visitAndApproveStorage
} from '../../support/ui-test-helper.js';
const testSnapshot = () => {
2020-10-16 21:59:30 +00:00
cy.get('#svgcontent').cleanSnapshot();
};
2020-09-12 23:32:13 +00:00
describe('use various parts of svg-edit', function () {
before(() => {
visitAndApproveStorage();
});
it('check tool_source', function () {
2021-05-12 23:00:09 +00:00
cy.get('#tool_source').click({ force: true });
2020-09-12 23:32:13 +00:00
cy.get('#svg_source_textarea')
2021-05-12 23:00:09 +00:00
.type('{selectall}', { force: true })
2020-09-12 23:32:13 +00:00
.type(`<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<g class="layer">
<title>Layer 1</title>
<rect id="rect" fill="#FF0000" height="70" stroke="#000000" stroke-width="5" width="94" x="69.5" y="51.5"/>
</g>
2021-05-12 23:00:09 +00:00
</svg>`, { force: true, parseSpecialCharSequences: false });
cy.get('#tool_source_save').click({ force: true });
testSnapshot();
2020-09-12 23:32:13 +00:00
});
it('check tool_fhpath', function () {
cy.get('#tool_fhpath')
2021-05-12 23:00:09 +00:00
.click({ force: true });
cy.get('#rect')
2021-05-12 23:00:09 +00:00
.trigger('mousemove', 200, 200, { force: true })
.trigger('mousedown', 200, 200, { force: true })
.trigger('mousemove', 20, 20, { force: true })
.trigger('mouseup', { force: true });
2020-09-12 23:32:13 +00:00
cy.get('#svgcontent').toMatchSnapshot();
});
it('check tool_text', function () {
cy.get('#tool_text')
2021-05-12 23:00:09 +00:00
.click({ force: true });
cy.get('#rect')
2021-05-12 23:00:09 +00:00
.trigger('mousedown', 46, 35, { force: true })
.trigger('mouseup', { force: true });
2020-09-12 23:32:13 +00:00
// svgedit use the #text text field to capture the text
2021-05-12 23:00:09 +00:00
cy.get('#text').type('AB', { force: true });
testSnapshot();
});
it('check tool_clone', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
cy.get('#tool_clone')
2021-05-12 23:00:09 +00:00
.click({ force: true });
testSnapshot();
});
it('check tool_italic', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
cy.get('#tool_italic')
2021-05-12 23:00:09 +00:00
.click({ force: true });
testSnapshot();
});
it('check tool_bold', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
cy.get('#tool_bold')
2021-05-12 23:00:09 +00:00
.click({ force: true });
testSnapshot();
2020-09-12 23:32:13 +00:00
});
2020-09-21 22:18:52 +00:00
it('check change color', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
2020-09-21 22:18:52 +00:00
cy.get('[data-rgb="#ffff00"]')
2021-05-12 23:00:09 +00:00
.click({ force: true });
2020-09-21 22:18:52 +00:00
testSnapshot();
});
2020-12-08 09:37:48 +00:00
it('check tool_text_anchor_start', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
2020-12-08 09:37:48 +00:00
cy.get('#tool_text_anchor_start')
2021-05-12 23:00:09 +00:00
.click({ force: true });
2020-12-08 09:37:48 +00:00
testSnapshot();
});
it('check tool_text_anchor_middle', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
2020-12-08 09:37:48 +00:00
cy.get('#tool_text_anchor_middle')
2021-05-12 23:00:09 +00:00
.click({ force: true });
2020-12-08 09:37:48 +00:00
testSnapshot();
});
it('check tool_text_anchor_end', function () {
2021-05-12 23:00:09 +00:00
cy.get('#svg_1').click({ force: true });
2020-12-08 09:37:48 +00:00
cy.get('#tool_text_anchor_end')
2021-05-12 23:00:09 +00:00
.click({ force: true });
2020-12-08 09:37:48 +00:00
testSnapshot();
});
it('check tool_star', function () {
cy.get('#tool_star')
2021-05-12 23:00:09 +00:00
.click({ force: true });
cy.get('#svgcontent')
2021-05-12 23:00:09 +00:00
.trigger('mousedown', 300, 150, { force: true })
.trigger('mousemove', 300, 250, { force: true })
.trigger('mouseup', { force: true });
2021-05-09 17:29:45 +00:00
testSnapshot();
});
it('check tool_polygon', function () {
cy.get('#tool_polygon')
2021-05-12 23:00:09 +00:00
.click({ force: true });
cy.get('#svgcontent')
2021-05-12 23:00:09 +00:00
.trigger('mousedown', 350, 250, { force: true })
.trigger('mousemove', 350, 370, { force: true })
.trigger('mouseup', { force: true });
2021-05-09 17:29:45 +00:00
testSnapshot();
});
2020-09-12 23:32:13 +00:00
});