- Docs: Update testing info; update CHANGES

- `editorconfig`: Use 4 spaces for Markdown
- npm: Rename and group various development scripts
master
Brett Zamir 2020-02-20 12:31:06 +08:00
parent 2fa2bfac1e
commit 08bf6f63b8
6 changed files with 220 additions and 44 deletions

View File

@ -14,3 +14,6 @@ trim_trailing_whitespace = true
; [app/public/css/**.styl] ; [app/public/css/**.styl]
; indent_style = tab ; indent_style = tab
; indent_size = 2 ; indent_size = 2
[*.md]
indent_size = 4

View File

@ -29,6 +29,13 @@
- Fix: Redirect paths for imagelib redirect checks - Fix: Redirect paths for imagelib redirect checks
- Fix: Ensure `setupCurPrefs` is run (including when `source` or - Fix: Ensure `setupCurPrefs` is run (including when `source` or
`url` is set within the URL) `url` is set within the URL)
- Fix: Pressing 'Ctrl+A' causes js error when canvas is empty (@cuixiping)
- Fix: Path element cannot be exported to PDF; export path with
holes to PDF; export path element to PDF, support more path
commands; #269 (@cuixiping)
- Fix: remove "null" attributes in svg source #76 (@cuixiping)
- Fix: A bug of `convertPath` function when converting H and V to
relative (@cuixiping)
- Optimization: Remove unused `jquery-ui-1.8.custom.min.js` file - Optimization: Remove unused `jquery-ui-1.8.custom.min.js` file
- Optimization: Remove old build/tools closure/yuicompressor code - Optimization: Remove old build/tools closure/yuicompressor code
- Optimization: Remove unmaintained chrome-app, firefox-extension, - Optimization: Remove unmaintained chrome-app, firefox-extension,
@ -43,6 +50,7 @@
dev. packages are being bundled (added by `npm run copy`) for determining dev. packages are being bundled (added by `npm run copy`) for determining
summary of all licenses including bundled). summary of all licenses including bundled).
- Docs: Reprioritize `docs` in commit lists (prioritize user-facing) - Docs: Reprioritize `docs` in commit lists (prioritize user-facing)
- Docs: Update Pavol's email address (@prusnak)
- Refactoring: Switch from `$.param.querystring` to `URL` - Refactoring: Switch from `$.param.querystring` to `URL`
- Refactoring: Ensure file-global jsdoc tags are at beginning of file - Refactoring: Ensure file-global jsdoc tags are at beginning of file
- Refactoring: Move `build-html` to `build` directory - Refactoring: Move `build-html` to `build` directory
@ -61,7 +69,7 @@
approving storage approving storage
- Testing: Produce mochawesome report - Testing: Produce mochawesome report
- Testing: Cypress with multiple reporters in case we need - Testing: Cypress with multiple reporters in case we need
- Build: Update underscore copy - Build: Update underscore and core-js-bundle copies
- npm: Add `underscore` to copy script - npm: Add `underscore` to copy script
- npm: Make `copy`, `compress-images`, `start-embedded`, `build-docs-remove` - npm: Make `copy`, `compress-images`, `start-embedded`, `build-docs-remove`
scripts cross-platform; add `start-allow-origin` script scripts cross-platform; add `start-allow-origin` script
@ -72,7 +80,7 @@
building docs and instrumenting) building docs and instrumenting)
- npm: Update scripts to reflect removal of `all_tests.html`; - npm: Update scripts to reflect removal of `all_tests.html`;
remove `browser-test` script remove `browser-test` script
- npm: Rename `test-prep` to `prep` - npm: Rename `test-prep` to `prep` and other misc. script naming changes
- npm: Update `package-lock.json` - npm: Update `package-lock.json`
- npm: Update devDeps, peerDeps - npm: Update devDeps, peerDeps

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">125/127</text><text class="high" x="46" y="14">125/127</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">126/127</text><text class="high" x="46" y="14">126/127</text></g></svg>

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 823 B

View File

@ -21,3 +21,4 @@
- `Testing:` - `Testing:`
- `Build: ` - `Build: `
- `npm` - Updates to dependencies, npm version, etc. - `npm` - Updates to dependencies, npm version, etc.
1. See [`Testing.md`](./Testing.md) for other information helpful for contributing.

View File

@ -1,11 +1,153 @@
# Testing # Testing
1. Ensure tests are passing via `npm test`. This will lint and build ## Building docs
files and run `/test/all_tests.html`.
1. Spot check extensions (until we have tests). The following URL includes all: This may be useful during testing. Build through `npm run build-docs`.
http://localhost:8000/editor/svg-editor-es.html?extensions=ext-arrows.js,ext-closepath.js,ext-connector.js,ext-eyedropper.js,ext-foreignobject.js,ext-grid.js,ext-helloworld.js,ext-imagelib.js,ext-markers.js,ext-mathjax.js,ext-overview_window.js,ext-panning.js,ext-php_savefile.js,ext-polygon.js,ext-server_moinsave.js,ext-server_opensave.js,ext-shapes.js,ext-star.js,ext-storage.js,ext-webappfind.js,ext-xdomain-messaging.js To start a server and open already built docs, use `npm run open-docs` (or
`npm run open-docs-no-start` if you already have a `start` process
running in another terminal tab).
1. Ensure both the ES6 Modules HTML file (`svg-editor-es.html`) and Or to build *and* open the docs, use `npm run build-and-open-docs` (or
regular file (`svg-editor.html`) are working. `npm run build-and-open-docs-no-start` if you already have a `start` process
running in another terminal tab).
## Scripts for running after dependency changes
1. Copying files. Some `devDependencies` are incorporated into the svgedit
repository (and npm package) so that Github or npm hosting services
can run (without needing to take the much heavier step of bundling all of
`node_modules`).
1. `npm run copy`
1. Checking licenses - If updating a dependency or devDependency,
the project's aggregate license information might change. To get
this information updated, run:
1. `npm run license-badges` (Which runs the following commands)
1. `npm run license-badge` (Only build the license badge containing
info on this project's license(s) and those of any `dependencies`,
and the `devDependencies` which are being bundled into the
repository/npm package.)
1. `npm run license-badge-dev` (Only build the license badge for this
project's `devDependencies`. This is probably not of great concern
unless a project is restrictive in terms of usage--i.e., if a
dependency is not what is typically considered "open" source.)
(Note that the test and coverage badges are generated automatically during
testing to ensure they are up to date, so you should not need to call those
scripts directly.)
## Miscellaneous scripts
1. `npm run compress-images` - Compressing images is not part of other
preparation routines, as it is time-consuming and should not need
to be done frequently.
1. `npm run remark` - For linting Markdown. Not of high enough priority
currently to put into an automated routine.
1. `npm run eslint` and `npm run eslint-fix` - For linting (or fixing)
linting errors. The non-fix version will be run automatically during
testing.
1. `npm run prep` - Run during `npm test` but may be useful to run
`npm run prep` as needed if normally testing through
`npm run test-only` which doesn't do the preparation. Composed of:
1. `npm run prep-no-core-rollup`
1. `npm run eslint` (see above)
1. `npm run build-html` - Copies ESM HTML pages, replacing references
to ESM scripts to compiled/rolled up scripts.
1. `npm run build-by-config` - Runs the Rollup routines for
compiling just the ESM-based config files (since the user
config files are responsible for importing svgedit, one must
compile these to get a non-ESM build, but with the advantage
of avoiding globals and extra script tags).
1. `npm run rollup` - Runs the rollup routine for compiling the ESM-based
svgedit source files.
## Opening SVG editor from command line
It can be helpful to experiment with an editor by opening it from the command
line, even when automated tests already exist for a type of editor.
1. Opening the ESM editor with only the default extensions:
1. `npm run open` OR
1. `npm run open-no-start` if you already have a `start`
process running in another terminal tab.
1. Opening the ESM editor with all extensions (no automated tests currently):
1. `npm run open-all-ext` OR
1. `npm run open-all-ext-no-start` if you already have a `start`
process running in another terminal tab.
1. Opening an embedded (ESM) editor (no automated tests currently) (Note
that there is currently no build process for creating a non-ESM
embedded editor).
1. `npm run open-embedded` (This runs the normal `start` and also
`start-allow-origin` for running a separate server on a different
origin (a different port) so the embedded API can be tested
across origins.) OR
1. `npm run open-embedded-no-start` if you already have a `start`
process running in another terminal tab.
1. Opening an editor which is already pre-compiled (rolled up) and safe
for older non-ESM browsers (or for better performance in ESM browsers
as well, due to its use of fewer HTTP requests). This is the version
most likely to be used in production environments. However, this is
less convenient during normal debugging, as it requires that the
lengthier `prep` script be run first (these scripts do not do so
for you in case you are directly working on the compiled files,
though this is not recommended).
1. `npm run open-compiled` OR
1. `npm run open-compiled-no-start` if you already have a `start`
process running in another terminal tab.
## Reading/Opening test coverage reports
For testing coverage reports (see "Testing"), you can open the HTML-based
reports that are generated during the testing process (or when running
`npm run instrument` directly) from the command line into your
browser by the following commands:
1. Reading reports from the command line
1. `npm run report` (with some line numbers but not all lines as
with the HTML report) OR
1. `npm run report-summary` (no line numbers--only a summary)
1. Opening HTML-based test coverage report (indicating coverage status
for all lines)
1. `npm run open-cov` OR
1. `npm run open-cov-no-start` if you already have a `start`
process running in another terminal tab.
## Testing
For ensuring tests are passing (and optionally checking coverage).
You will most likely just need to use the top-level routines, but
the components are explained here for reference.
1. `npm test`. Headless testing comprised of:
1. `npm run instrument` - You can call this alone if you don't
actually wish to test but wish to get the files instrumented.
Should normally not be needed alone.
1. `npm run test-no-cov` - You can run this alone if you have already
run `npm run instrument` upon making changes. Should normally
not be run alone.
1. `npm run prep` (see above)
1. `npm run test-only` - Includes a separate `report` step or
otherwise the tests will not show the results visibly on the
command line. This may be useful if you've instrumented and
run preparation steps after any code modifications, but just
need to re-run tests (e.g., if one did not complete them for
some reason). See also `test-no-cov-no-core-rollup`.
1. `npm run test-only-no-report` - Should not be needed alone.
1. `npm start` - Starts the server
1. `npm run cypress:run` - Runs Cypress tests (`cypress run`).
`cypress:run` is made of subroutines which also merge
Mocha results (since Cypress produces separate files)
and updates the testing and coverage badges.
1. `npm run report` (see above)
1. `npm run test-no-core-rollup` - This applies the same headless testing
steps as `npm test` minus the time-consuming `npm run rollup`. This
script may be useful if you are only modifying config files but not
svgedit core.
1. `instrument` (see above)
1. `npm run test-no-cov-no-core-rollup`. As with `test-no-cov` but no
`npm run rollup` routine (part of `prep`).
1. `open-tests` (also as `cypress:open`)
1. `npm start`
1. `cypress:open-no-start`. Runs `cypress open`, the headed mode. Useful
for testing single files with hot reloading.

View File

@ -13,52 +13,74 @@
"node": ">=8.5.0" "node": ">=8.5.0"
}, },
"scripts": { "scripts": {
"prepublishOnly": "npm run prep", "start-allow-origin": "static -p 8001 -H '{\"Access-Control-Allow-Origin\": \"*\"}'",
"open-allext-no-start": "open-cli http://localhost:8000/editor/svg-editor-es.html?extensions=ext-arrows.js,ext-closepath.js,ext-foreignobject.js,ext-helloworld.js,ext-mathjax.js,ext-php_savefile.js,ext-server_moinsave.js,ext-server_opensave.js,ext-webappfind.js,ext-xdomain-messaging.js", "start-embedded": "run-p start start-allow-origin",
"open-allext": "run-p start open-allext-no-start", "start": "echo \"Open file, e.g., to http://localhost:8000/editor/svg-editor-es.html\" && static -p 8000",
"open-no-start": "open-cli http://localhost:8000/editor/svg-editor-es.html",
"open": "run-p start open-no-start", "open-docs-no-start": "open-cli http://localhost:8000/docs/jsdoc/",
"open-docs": "run-p start open-docs-no-start",
"build-docs-remove": "rimraf \"docs/jsdoc/*\"", "build-docs-remove": "rimraf \"docs/jsdoc/*\"",
"build-docs-create": "jsdoc --pedantic -c docs/jsdoc-config.js editor", "build-docs-create": "jsdoc --pedantic -c docs/jsdoc-config.js editor",
"build-docs": "run-s -c build-docs-remove build-docs-create", "build-docs": "run-s -c build-docs-remove build-docs-create",
"open-docs-no-start": "open-cli http://localhost:8000/docs/jsdoc/", "build-and-open-docs-no-start": "run-s build-docs open-docs-no-start",
"open-docs": "run-p start open-docs-no-start", "build-and-open-docs": "run-s build-docs open-docs",
"build-html": "npx babel-node --plugins @babel/plugin-transform-modules-commonjs build/build-html.js",
"compress-images": "imageoptim \"editor/extensions/*.png\" \"editor/spinbtn/*.png\" \"editor/jgraduate/images/*.{png,gif}\" \"editor/images/*.png\"", "open-embedded-no-start": "open-cli http://localhost:8000/editor/embedapi.html",
"copy": "copyfiles -f node_modules/load-stylesheets/dist/index-es.js editor/external/load-stylesheets && copyfiles -f node_modules/jamilih/dist/jml-es.js editor/external/jamilih && copyfiles -f node_modules/query-result/esm/index.js editor/external/query-result/esm && copyfiles -f node_modules/qr-manipulation/dist/index-es.js editor/external/qr-manipulation/dist && copyfiles -f node_modules/stackblur-canvas/dist/stackblur-es.js editor/external/stackblur-canvas/dist && copyfiles -f node_modules/regenerator-runtime/runtime.js editor/external/regenerator-runtime && copyfiles -f \"node_modules/core-js-bundle//minified*\" editor/external/core-js-bundle && copyfiles -f \"node_modules/underscore/underscore-*\" editor/jspdf && copyfiles -f \"node_modules/deparam/dist/deparam.esm.js\" editor/external/deparam", "open-embedded": "run-p start-embedded open-embedded-no-start",
"remark": "remark -q -f .", "open-all-ext-no-start": "open-cli http://localhost:8000/editor/svg-editor-es.html?extensions=ext-arrows.js,ext-closepath.js,ext-foreignobject.js,ext-helloworld.js,ext-mathjax.js,ext-php_savefile.js,ext-server_moinsave.js,ext-server_opensave.js,ext-webappfind.js,ext-xdomain-messaging.js",
"eslint-fix": "eslint --fix --ext js,md,html .", "open-all-ext": "run-p start open-all-ext-no-start",
"eslint": "eslint --ext js,md,html .", "open-compiled-no-start": "open-cli http://localhost:8000/editor/svg-editor.html",
"rollup": "rollup -c", "open-compiled": "run-p start open-compiled-no-start",
"start-allow-origin": "static -p 8001 -H '{\"Access-Control-Allow-Origin\": \"*\"}'", "open-no-start": "open-cli http://localhost:8000/editor/svg-editor-es.html",
"start-embedded": "echo \"Open file to http://localhost:8000/editor/embedapi.html\" && run-p start start-allow-origin", "open": "run-p start open-no-start",
"start": "echo \"Open file, e.g., to http://localhost:8000/editor/svg-editor-es.html\" && static -p 8000",
"cypress:open": "cypress open", "open-cov-no-start": "open-cli http://localhost:8000/coverage/",
"cypress:merge": "mochawesome-merge \"cypress/results/mochaw*.json\" > mochawesome.json && marge mochawesome.json && mbg --file ./mochawesome.json --badge_output badges/tests-badge.svg", "open-cov": "run-p start open-cov-no-start",
"cypress:run-only": "rimraf \"cypress/results/mochaw*.json\" && rimraf \".nyc_output/*\" && cypress run",
"cypress:run-no-badge": "run-s -c cypress:run-only cypress:merge",
"cypress:run": "run-s -c cypress:run-no-badge coverage-badge",
"open-report-no-start": "open-cli http://localhost:8000/coverage/",
"open-report": "run-p start open-report-no-start",
"start-open-report": "run-p start open-report",
"instrument:replace-html": "frs-replace \"../svgedit-config-es.js\" \"svgedit-config-es.js\" -i instrumented/svg-editor-es.html -o instrumented/svg-editor-es.html", "instrument:replace-html": "frs-replace \"../svgedit-config-es.js\" \"svgedit-config-es.js\" -i instrumented/svg-editor-es.html -o instrumented/svg-editor-es.html",
"instrument:replace-js": "frs-replace \"editor/svg-editor.js\" \"svg-editor.js\" -i svgedit-config-es.js -o instrumented/svgedit-config-es.js", "instrument:replace-js": "frs-replace \"editor/svg-editor.js\" \"svg-editor.js\" -i svgedit-config-es.js -o instrumented/svgedit-config-es.js",
"instrument:copy-excluded": "node cypress/support/copy.js", "instrument:copy-excluded": "node cypress/support/copy.js",
"copy-instrumented": "copyfiles -e \"**/*.js\" -u 1 \"editor/**/*\" instrumented && npm run instrument:replace-html && npm run instrument:replace-js && npm run instrument:copy-excluded", "copy-instrumented": "copyfiles -e \"**/*.js\" -u 1 \"editor/**/*\" instrumented && npm run instrument:replace-html && npm run instrument:replace-js && npm run instrument:copy-excluded",
"instrument": "rimraf instrumented && npx nyc instrument editor instrumented && npm run copy-instrumented", "instrument": "rimraf instrumented && nyc instrument editor instrumented && npm run copy-instrumented",
"report": "nyc report",
"report-summary": "nyc report --reporter=text-summary",
"license-badge": "license-badger --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg", "license-badge": "license-badger --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
"license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg", "license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg",
"license-badges": "run-p license-badge license-badge-dev",
"coverage-badge": "coveradge badges/coverage-badge", "coverage-badge": "coveradge badges/coverage-badge",
"open-cov": "run-p --race start cypress:open",
"open-tests": "run-p start cypress:open", "compress-images": "imageoptim \"editor/extensions/*.png\" \"editor/spinbtn/*.png\" \"editor/jgraduate/images/*.{png,gif}\" \"editor/images/*.png\"",
"report": "npx nyc report", "copy": "copyfiles -f node_modules/load-stylesheets/dist/index-es.js editor/external/load-stylesheets && copyfiles -f node_modules/jamilih/dist/jml-es.js editor/external/jamilih && copyfiles -f node_modules/query-result/esm/index.js editor/external/query-result/esm && copyfiles -f node_modules/qr-manipulation/dist/index-es.js editor/external/qr-manipulation/dist && copyfiles -f node_modules/stackblur-canvas/dist/stackblur-es.js editor/external/stackblur-canvas/dist && copyfiles -f node_modules/regenerator-runtime/runtime.js editor/external/regenerator-runtime && copyfiles -f \"node_modules/core-js-bundle//minified*\" editor/external/core-js-bundle && copyfiles -f \"node_modules/underscore/underscore-*\" editor/jspdf && copyfiles -f \"node_modules/deparam/dist/deparam.esm.js\" editor/external/deparam",
"report-summary": "npx nyc report --reporter=text-summary", "remark": "remark -q -f .",
"build-html": "babel-node --plugins @babel/plugin-transform-modules-commonjs build/build-html.js",
"eslint-fix": "eslint --fix --ext js,md,html .",
"eslint": "eslint --ext js,md,html .",
"rollup": "rollup -c",
"build-by-config": "rollup -c rollup-config.config.js", "build-by-config": "rollup -c rollup-config.config.js",
"test-cov-open": "run-p --race start cypress:run", "prep-no-core-rollup": "run-s eslint build-html build-by-config",
"test-cov": "run-s -c instrument test-cov-open report-summary", "prep": "run-s prep-no-core-rollup rollup",
"test-no-build": "run-s eslint build-html build-by-config && npm test", "prepublishOnly": "npm run prep",
"prep": "run-s eslint build-html rollup build-by-config",
"test": "run-p start cypress:run" "cypress:open-no-start": "cypress open",
"cypress:open": "run-p start cypress:open-no-start",
"open-tests": "npm run cypress:open",
"cypress:merge": "mochawesome-merge \"cypress/results/mochaw*.json\" > mochawesome.json && marge mochawesome.json && mbg --file ./mochawesome.json --badge_output badges/tests-badge.svg",
"cypress:run-only": "rimraf \"cypress/results/mochaw*.json\" && rimraf \".nyc_output/*\" && cypress run",
"cypress:run-no-badge": "run-s -c cypress:run-only cypress:merge",
"cypress:run": "run-s -c cypress:run-no-badge coverage-badge",
"test-only-no-report": "run-p start cypress:run",
"test-only": "run-s -c test-only-no-report report",
"test-no-cov-no-core-rollup": "run-s prep-no-core-rollup test-only",
"test-no-cov": "run-s prep test-only",
"test-no-core-rollup": "run-s instrument test-no-cov-no-core-rollup",
"test": "run-s instrument test-no-cov"
}, },
"nyc": { "nyc": {
"exclude": [ "exclude": [