add a cypress scenario

master
jfh 2020-09-13 01:32:13 +02:00
parent d15ee0fc3a
commit a61cfdf553
7 changed files with 2471 additions and 7 deletions

View File

@ -5,6 +5,10 @@
"reporterOptions": {
"configFile": "mocha-multi-reporters.json"
},
"ignoreTestFiles": [
"**/__snapshots__/*",
"**/__image_snapshots__/*"
],
"defaultCommandTimeout": 10000,
"pageLoadTimeout": 120000
}

View File

@ -0,0 +1,123 @@
exports[`use various parts of svg-edit > check tool_fhpath #0`] = `
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
width="640"
height="480"
id="svgcontent"
overflow="visible"
x="640"
y="480"
viewBox="0 0 640 480"
fill="black"
fill-opacity="1"
stroke="none"
stroke-opacity="1"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<rect
id="rect"
fill="#FF0000"
height="70"
stroke="#000000"
stroke-width="5"
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
></rect>
</g>
</svg>
`;
exports[`use various parts of svg-edit > check tool_source #0`] = `
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
width="640"
height="480"
id="svgcontent"
overflow="visible"
x="640"
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<rect
id="rect"
fill="#FF0000"
height="70"
stroke="#000000"
stroke-width="5"
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
></rect>
</g>
</svg>
`;
exports[`use various parts of svg-edit > check tool_text #0`] = `
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
width="640"
height="480"
id="svgcontent"
overflow="visible"
x="640"
y="480"
viewBox="0 0 640 480"
fill="black"
fill-opacity="1"
stroke="none"
stroke-opacity="1"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<rect
id="rect"
fill="#FF0000"
height="70"
stroke="#000000"
stroke-width="5"
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
></rect>
<text
fill="#000000"
stroke-width="0"
style="pointer-events:inherit"
x="116"
y="86"
id="svg_1"
font-size="24"
font-family="serif"
text-anchor="middle"
xml:space="preserve"
></text>
<text
fill="#000000"
stroke-width="0"
style="pointer-events: inherit; cursor: move;"
x="116"
y="86"
id="svg_2"
font-size="24"
font-family="serif"
text-anchor="middle"
xml:space="preserve"
fill-opacity="1"
stroke="none"
stroke-opacity="1"
>
12
</text>
</g>
</svg>
`;

View File

@ -0,0 +1,43 @@
import {
visitAndApproveStorage
} from '../../support/ui-test-helper.js';
describe('use various parts of svg-edit', function () {
before(() => {
visitAndApproveStorage();
});
it('check tool_source', function () {
cy.get('#tool_source').click();
cy.get('#svg_source_textarea')
.type('{selectall}', {force: true})
.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>
</svg>`, {parseSpecialCharSequences: false});
cy.get('#tool_source_save').click();
cy.get('#svgcontent').toMatchSnapshot();
});
it('check tool_fhpath', function () {
cy.get('#tool_fhpath')
.click({force: true});
cy.get('#svgcontent')
.trigger('mousedown', 'center')
.trigger('mousemove', {clientX: 200, clientY: 200, bubbles: true, cancelable: true})
.trigger('mousemove', {clientX: 20, clientY: 20, bubbles: true, cancelable: true})
.trigger('mouseup', {force: true});
cy.get('#svgcontent').toMatchSnapshot();
});
it('check tool_text', function () {
cy.get('#tool_text')
.click({force: true});
cy.get('#svgcontent')
.trigger('mousedown', 'center');
// svgedit use the #text text field to capture the text
cy.get('#text').type('1234', {force: true});
cy.get('#svgcontent').toMatchSnapshot();
});
});

View File

@ -2,6 +2,7 @@
// the project's config changing)
import codeCoverageTask from '@cypress/code-coverage/task.js';
import {initPlugin} from 'cypress-plugin-snapshots/plugin.js';
export default (on, config) => {
// `on` is used to hook into various events Cypress emits
@ -12,5 +13,6 @@ export default (on, config) => {
// https://docs.cypress.io/guides/tooling/code-coverage.html#Install-the-plugin
codeCoverageTask(on, config);
initPlugin(on, config);
return config;
};

View File

@ -42,3 +42,10 @@ import '@cypress/code-coverage/support.js';
* @see https://www.npmjs.com/package/cypress-axe
*/
import 'cypress-axe';
/*****
* SNAPSHOTS
* @see https://www.npmjs.com/package/cypress-plugin-snapshots
*/
import 'cypress-plugin-snapshots/commands.js';

2296
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -169,6 +169,7 @@
"cypress": "^5.1.0",
"cypress-axe": "^0.8.1",
"cypress-multi-reporters": "^1.4.0",
"cypress-plugin-snapshots": "^1.4.4",
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
"es-dev-commonjs-transformer": "^0.2.0",
"es-dev-server": "^1.57.4",
@ -221,7 +222,9 @@
"rimraf": "^3.0.2",
"rollup": "2.26.11",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^7.0.2",
"stackblur-canvas": "^2.4.0",