Browse Source

Tests now support coverage inside playwright. Next need to add coverage to the non-browser tests.

master
Zed A. Shaw 6 days ago
parent
commit
1ae2dc5129
  1. 2
      .eslintrc.json
  2. 2
      .gitignore
  3. 2
      client/bando/Components.svelte
  4. 37
      lib/testing.js
  5. 414
      package-lock.json
  6. 9
      package.json
  7. 3
      static/djenterator/ui_test.js
  8. 2
      tests/lib/ormish.js
  9. 2
      tests/models/media.js
  10. 2
      tests/models/payment.js
  11. 4
      tests/models/site.js
  12. 2
      tests/models/user.js
  13. 2
      tests/models/user_payment.js
  14. 65
      tests/ui/demos.js
  15. 6
      tests/ui/login.js
  16. 7
      tests/ui/payments.js
  17. 11
      tests/ui/register.js

2
.eslintrc.json

@ -125,7 +125,7 @@
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "error",
"no-empty-function": "off",
"no-eq-null": "off",
"no-eval": "error",
"no-extend-native": "error",

2
.gitignore

@ -19,3 +19,5 @@ rendered/Layout.svelte
rendered/pages/index.svelte
client/routes.js
client/config.js
coverage/
.nyc_output/

2
client/bando/Components.svelte

@ -203,7 +203,7 @@
</tabs>
<component data-testid="demo-{ selected.title }">
{#if show == "CODE"}
<Code src={ selected.code } format={ true } />
<Code src={ selected.code } />
{:else if show == "DOCS"}
{#await load_docs(selected) then docs }
{#if docs}

37
lib/testing.js

@ -2,9 +2,15 @@ import playwright from 'playwright';
import faker from 'faker';
import random from 'random';
import assert from "assert";
import v8toIstanbul from 'v8-to-istanbul';
import { v4 as uuid } from "uuid";
import fs from "fs";
import url from "url";
import path from "path";
const WAIT_TIME = 5000;
const HEADLESS = !process.env.PLAYVIEW;
const COVERAGE = process.env.COVERAGE !== undefined;
export const tid = (name) => `[data-testid="${name}"]`;
@ -29,11 +35,16 @@ export const form = async (page, fields, button_id) => {
export const playstart = async (url) => {
if(!HEADLESS) console.log("Running playwright in visible mode (not HEADLESS).");
if(COVERAGE) console.log("Coverage reports going to .nyc_output.");
const browser = await playwright['firefox'].launch({headless: HEADLESS});
const browser = await playwright['chromium'].launch({headless: HEADLESS});
const context = await browser.newContext();
const p = await context.newPage();
if(COVERAGE) {
await p.coverage.startJSCoverage();
}
p.on('console', async msgs => {
let output = [];
for(const msg of msgs.args()) {
@ -49,6 +60,30 @@ export const playstart = async (url) => {
return {browser, context, p};
}
export const playstop = async (browser, p) => {
if(COVERAGE) {
const coverage = await p.coverage.stopJSCoverage();
for (const entry of coverage) {
// parse the entry url
const pathname = url.parse(entry.url).pathname;
// convert to a path in public
const inpublic = path.join("./public", pathname);
// if the file exists then get it
if(fs.existsSync(inpublic)) {
const converter = new v8toIstanbul(inpublic,
0, { source: entry.source });
await converter.load();
converter.applyCoverage(entry.functions);
fs.writeFileSync(`.nyc_output/${uuid()}.json`, JSON.stringify(converter.toIstanbul()));
}
}
}
await browser.close();
}
export const wait = async (p, css_id) => {
await p.waitForSelector(css_id, { timeout: WAIT_TIME });
}

414
package-lock.json

@ -1094,6 +1094,11 @@
"@types/node": "*"
}
},
"@types/istanbul-lib-coverage": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz",
"integrity": "sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw=="
},
"@types/mdast": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.7.tgz",
@ -1160,6 +1165,12 @@
"resolved": "https://registry.npmjs.org/Validator/-/Validator-1.1.2.tgz",
"integrity": "sha512-A+NXj1N6LgWTkohexVJ98gYVQyTD0yi4e83Tf9ojkV9p7ll34IEfE2pL1zCRof6tU4buwE04cqaIEsXT2o7Ncw=="
},
"abab": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
"dev": true
},
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -1179,6 +1190,30 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.4.tgz",
"integrity": "sha512-Ibt84YwBDDA890eDiDCEqcbwvHlBvzzDkU2cGBBDDI1QWT12jTiXIOn2CIw5KK4i6N5Z2HUxwYjzriDyqaqqZg=="
},
"acorn-globals": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
"integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==",
"dev": true,
"requires": {
"acorn": "^7.1.1",
"acorn-walk": "^7.1.1"
},
"dependencies": {
"acorn": {
"version": "7.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true
},
"acorn-walk": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
"integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==",
"dev": true
}
}
},
"acorn-jsx": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
@ -2277,6 +2312,12 @@
"fill-range": "^7.0.1"
}
},
"browser-process-hrtime": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz",
"integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==",
"dev": true
},
"browser-sync": {
"version": "2.26.14",
"resolved": "https://registry.npmjs.org/browser-sync/-/browser-sync-2.26.14.tgz",
@ -3433,6 +3474,43 @@
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"code-red": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.1.7.tgz",
"integrity": "sha512-MM7ozxKYWNV8EXeFETD7oHehCMexT+1M5B6xHJQ3gGbmrmzXUuw/CIZ8EYuP13XAT/DK98ZMcFiMe3ZskSjMnQ==",
"dev": true,
"requires": {
"@types/estree": "^0.0.45",
"acorn": "^8.0.5",
"estree-walker": "^0.9.0",
"is-reference": "^2.0.0",
"periscopic": "^2.0.1",
"sourcemap-codec": "^1.4.8"
},
"dependencies": {
"@types/estree": {
"version": "0.0.45",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz",
"integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==",
"dev": true
},
"estree-walker": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.9.0.tgz",
"integrity": "sha512-12U47o7XHUX329+x3FzNVjCx3SHEzMF0nkDv7r/HnBzX/xNTKxajBk6gyygaxrAFtLj39219oMfbtxv4KpaOiA==",
"dev": true
},
"is-reference": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-2.0.0.tgz",
"integrity": "sha512-kgaeJVq59jasPrhlGK/K61muTjLxMOZf4oMwI4X94nDWqkqLxDWVWrecCSP5c6OR8JF7Yul0X7h59lB1ho0epQ==",
"dev": true,
"requires": {
"@types/estree": "*"
}
}
}
},
"codejar": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/codejar/-/codejar-3.4.0.tgz",
@ -3839,6 +3917,29 @@
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
"dev": true
},
"cssom": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz",
"integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==",
"dev": true
},
"cssstyle": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz",
"integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==",
"dev": true,
"requires": {
"cssom": "~0.3.6"
},
"dependencies": {
"cssom": {
"version": "0.3.8",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz",
"integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==",
"dev": true
}
}
},
"culvert": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/culvert/-/culvert-0.1.2.tgz",
@ -3861,6 +3962,20 @@
"uniq": "^1.0.0"
}
},
"dainte": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/dainte/-/dainte-0.1.5.tgz",
"integrity": "sha512-P+XW0xzRPavN18GWYZ5aUSyaLNt8QFu855Uq3CQUudj9V42ipXMzk4Y34ByMhVmOHAYmWkT0ww1JBP4t1cTeNg==",
"dev": true,
"requires": {
"@rollup/plugin-node-resolve": "^11.0.0",
"code-red": "^0.1.4",
"jsdom": "^16.4.0",
"rollup": "^2.34.1",
"rollup-plugin-svelte": "^7.0.0",
"svelte": "^3.0.0"
}
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
@ -3874,6 +3989,17 @@
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz",
"integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og=="
},
"data-urls": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz",
"integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==",
"dev": true,
"requires": {
"abab": "^2.0.3",
"whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.0.0"
}
},
"date-fns": {
"version": "2.22.1",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.22.1.tgz",
@ -3934,6 +4060,12 @@
}
}
},
"decimal.js": {
"version": "10.3.1",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz",
"integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==",
"dev": true
},
"decompress-response": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
@ -5680,6 +5812,15 @@
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw=="
},
"html-encoding-sniffer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
"integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==",
"dev": true,
"requires": {
"whatwg-encoding": "^1.0.5"
}
},
"html-minifier-terser": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz",
@ -6271,6 +6412,12 @@
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
},
"is-potential-custom-element-name": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
"dev": true
},
"is-promise": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
@ -6452,6 +6599,126 @@
"skip-regex": "^1.0.2"
}
},
"jsdom": {
"version": "16.7.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz",
"integrity": "sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw==",
"dev": true,
"requires": {
"abab": "^2.0.5",
"acorn": "^8.2.4",
"acorn-globals": "^6.0.0",
"cssom": "^0.4.4",
"cssstyle": "^2.3.0",
"data-urls": "^2.0.0",
"decimal.js": "^10.2.1",
"domexception": "^2.0.1",
"escodegen": "^2.0.0",
"form-data": "^3.0.0",
"html-encoding-sniffer": "^2.0.1",
"http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0",
"is-potential-custom-element-name": "^1.0.1",
"nwsapi": "^2.2.0",
"parse5": "6.0.1",
"saxes": "^5.0.1",
"symbol-tree": "^3.2.4",
"tough-cookie": "^4.0.0",
"w3c-hr-time": "^1.0.2",
"w3c-xmlserializer": "^2.0.0",
"webidl-conversions": "^6.1.0",
"whatwg-encoding": "^1.0.5",
"whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.5.0",
"ws": "^7.4.6",
"xml-name-validator": "^3.0.0"
},
"dependencies": {
"domexception": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz",
"integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==",
"dev": true,
"requires": {
"webidl-conversions": "^5.0.0"
},
"dependencies": {
"webidl-conversions": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz",
"integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==",
"dev": true
}
}
},
"escodegen": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz",
"integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==",
"dev": true,
"requires": {
"esprima": "^4.0.1",
"estraverse": "^5.2.0",
"esutils": "^2.0.2",
"optionator": "^0.8.1",
"source-map": "~0.6.1"
}
},
"estraverse": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
"integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
"dev": true
},
"form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"dev": true,
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"optional": true
},
"tough-cookie": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
"dev": true,
"requires": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
}
},
"webidl-conversions": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz",
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==",
"dev": true
},
"ws": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
"integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==",
"dev": true
}
}
},
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -7626,9 +7893,33 @@
"dev": true
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
"requires": {
"whatwg-url": "^5.0.0"
},
"dependencies": {
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
}
}
},
"node-gyp": {
"version": "3.8.0",
@ -7940,6 +8231,12 @@
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
},
"nwsapi": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz",
"integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==",
"dev": true
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@ -8471,6 +8768,16 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"periscopic": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-2.0.3.tgz",
"integrity": "sha512-FuCZe61mWxQOJAQFEfmt9FjzebRlcpFz8sFPbyaCKtdusPkMEbA9ey0eARnRav5zAhmXznhaQkKGFAPn7X9NUw==",
"dev": true,
"requires": {
"estree-walker": "^2.0.2",
"is-reference": "^1.1.4"
}
},
"pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
@ -10053,6 +10360,15 @@
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"saxes": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz",
"integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==",
"dev": true,
"requires": {
"xmlchars": "^2.2.0"
}
},
"section-matter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
@ -10727,8 +11043,7 @@
"source-map": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ=="
},
"source-map-support": {
"version": "0.5.19",
@ -11277,6 +11592,12 @@
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=",
"dev": true
},
"symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
"dev": true
},
"table": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz",
@ -11734,6 +12055,15 @@
"punycode": "^2.1.1"
}
},
"tr46": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-2.1.0.tgz",
"integrity": "sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==",
"dev": true,
"requires": {
"punycode": "^2.1.1"
}
},
"trim-newlines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz",
@ -12143,6 +12473,16 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"v8-to-istanbul": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.0.tgz",
"integrity": "sha512-/PRhfd8aTNp9Ggr62HPzXg2XasNFGy5PBt0Rp04du7/8GNNSgxFL6WBTkgMKSL9bFjH+8kKEG3f37FmxiTqUUA==",
"requires": {
"@types/istanbul-lib-coverage": "^2.0.1",
"convert-source-map": "^1.6.0",
"source-map": "^0.7.3"
}
},
"validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
@ -12232,6 +12572,24 @@
}
}
},
"w3c-hr-time": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",
"integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==",
"dev": true,
"requires": {
"browser-process-hrtime": "^1.0.0"
}
},
"w3c-xmlserializer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz",
"integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==",
"dev": true,
"requires": {
"xml-name-validator": "^3.0.0"
}
},
"wait-on": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/wait-on/-/wait-on-5.3.0.tgz",
@ -12364,6 +12722,40 @@
"resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz",
"integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q=="
},
"whatwg-encoding": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz",
"integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==",
"dev": true,
"requires": {
"iconv-lite": "0.4.24"
}
},
"whatwg-mimetype": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz",
"integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==",
"dev": true
},
"whatwg-url": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.7.0.tgz",
"integrity": "sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==",
"dev": true,
"requires": {
"lodash": "^4.7.0",
"tr46": "^2.1.0",
"webidl-conversions": "^6.1.0"
},
"dependencies": {
"webidl-conversions": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz",
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==",
"dev": true
}
}
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@ -12599,6 +12991,18 @@
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",
"integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q=="
},
"xml-name-validator": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
"integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==",
"dev": true
},
"xmlchars": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
"dev": true
},
"xmlhttprequest-ssl": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",

9
package.json

@ -30,7 +30,9 @@
"test": "npx ava tests/**/*.js",
"watch": "npm-watch test",
"7ty": "cd rendered && 7ty --watch pages,client,lib,../static,../posts",
"knex": "knex --knexfile=knexfile.cjs"
"knex": "knex --knexfile=knexfile.cjs",
"coverage:report": "nyc --exclude \"public/js/**/*.js\" report",
"coverage:html": "nyc --exclude \"public/js/**/*.js\" --reporter=lcov report"
},
"devDependencies": {
"@jackfranklin/rollup-plugin-markdown": "^0.3.0",
@ -42,6 +44,7 @@
"browser-sync": "^2.26.14",
"codejar": "^3.4.0",
"colorthief": "^2.3.2",
"dainte": "^0.1.5",
"eslint": "^7.32.0",
"eslint-plugin-svelte3": "^3.2.0",
"html-minifier-terser": "^5.1.1",
@ -95,6 +98,7 @@
"nodemailer": "^6.5.0",
"nodemon": "^2.0.7",
"npm-watch": "^0.9.0",
"nyc": "^15.1.0",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"pino": "^6.11.3",
@ -112,7 +116,8 @@
"sqlite3": "^5.0.2",
"svelte-spa-router": "^3.1.0",
"tap-json": "^1.0.0",
"uuid": "^8.3.2"
"uuid": "^8.3.2",
"v8-to-istanbul": "^8.1.0"
},
"optionalDependencies": {
"utf-8-validate": "^5.0.5"

3
static/djenterator/ui_test.js

@ -1,6 +1,5 @@
import test from 'ava';
import {sleep, tid, expect, playstart, form, wait} from '../../lib/testing.js';
import faker from 'faker';
import {knex} from '../../lib/ormish.js';
test.before(async t => t.context = await playstart('http://localhost:5001/client/#<%= start_url %>'));
@ -16,7 +15,7 @@ test('test <%= start_url %> works', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
await browser.close();
}

2
tests/lib/ormish.js

@ -1,5 +1,5 @@
import test from "ava";
import { knex, SCHEMA, Model } from "../../lib/ormish.js";
import { SCHEMA, Model } from "../../lib/ormish.js";
// TODO: make a clean test that doesn't need user
// TODO: use a :memory: sqlite to do the tests
import { User } from "../../lib/models.js";

2
tests/models/media.js

@ -38,6 +38,6 @@ test('test media model basics work', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
}
})

2
tests/models/payment.js

@ -51,6 +51,6 @@ test('test payment model basics work', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
}
})

4
tests/models/site.js

@ -13,7 +13,7 @@ test('test site model basics work', async (t) => {
t.not(result, undefined);
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
await Site.delete({key: "test_number"});
}
@ -37,7 +37,7 @@ test('test site model works with complex types', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
await Site.delete({key: "test_complex"});
}

2
tests/models/user.js

@ -47,7 +47,7 @@ test('test user model basics work', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
await User.delete({id: user.id});
}

2
tests/models/user_payment.js

@ -61,7 +61,7 @@ test('test user can have multiple payments', async (t) => {
t.true(buyer_pays.map(b => b.id).includes(pay2.id));
} catch(error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
if(buyer_id) await User.delete({id: buyer_id});
if(buyer_pays) {

65
tests/ui/demos.js

@ -1,27 +1,60 @@
import test from 'ava';
import {sleep, tid, expect, playstart, wait} from '../../lib/testing.js';
import {tid, expect, playstart, playstop} from '../../lib/testing.js';
export const panels = [
"Accordion", "AspectRatio", "Badge", "ButtonGroup", "Calendar", "Callout",
"Cards", "Carousel", "Chat", "Code", "Countdown", "Darkmode",
"DataTable", "Flipper", "Form", "Icon", "IconImage",
"LiveStream", "LoggedIn", "Login", "Markdown", "Modal", "OGPreview",
"Pagination", "PlaceHolder", "Progress", "Sidebar", "SnapImage", "Spinner",
"StackLayer", "Switch", "Tabs", "Tiles", "Toast", "Tooltip",
"Video", "WTVideo",
];
export const panels = {
Accordion: () => {},
AspectRatio: () => {},
Badge: () => {},
ButtonGroup: () => {},
Calendar: () => {},
Callout: () => {},
Cards: () => {},
Carousel: () => {},
Chat: () => {},
Code: () => {},
Countdown: () => {},
Darkmode: () => {},
DataTable: () => {},
Flipper: () => {},
Form: () => {},
Icon: () => {},
IconImage: () => {},
LiveStream: () => {},
LoggedIn: () => {},
Login: () => {},
Markdown: () => {},
Modal: () => {},
OGPreview: () => {},
Pagination: () => {},
PlaceHolder: () => {},
Progress: () => {},
Sidebar: () => {},
SnapImage: () => {},
Spinner: () => {},
StackLayer: () => {},
Switch: () => {},
Tabs: () => {},
Tiles: () => {},
Toast: () => {},
Tooltip: () => {},
Video: () => {},
WTVideo: () => {},
}
test.before(async t => t.context = await playstart('http://localhost:5001/client/#/bando/components/'));
test.before(async t => t.context = await playstart('http://localhost:5001/client/#/'));
test.after(async t => await t.context.browser.close());
test.after(async t => {
await playstop(t.context.browser, t.context.p);
});
test('can load each component', async (t) => {
const {browser, context, p} = t.context;
try {
p.goto('http://localhost:5001/client/#/bando/components/');
await expect(t, p, tid("page-bando-demos"));
for(let panel of panels) {
for(let [panel, tester] of Object.entries(panels)) {
await p.click(tid(`sidebar-link-${panel}`));
await expect(t, p, tid(`demo-${panel}`));
@ -33,11 +66,11 @@ test('can load each component', async (t) => {
await p.click(tid(`tab-demo`));
await expect(t, p, tid(`tab-demo`));
await tester();
}
} catch (error) {
console.log(error);
t.fail(error);
} finally {
await browser.close();
t.fail(error.message);
}
});

6
tests/ui/login.js

@ -1,11 +1,13 @@
import test from 'ava';
import { User } from "../../lib/models.js";
import {sleep, random_user, expect, wait, tid, playstart} from '../../lib/testing.js';
import {sleep, random_user, expect, wait, tid, playstart, playstop} from '../../lib/testing.js';
test.before(async t => t.context = await playstart('http://localhost:5001/client/#/login/'));
test.after(async t => await t.context.browser.close());
test.after(async t => {
await playstop(t.context.browser, t.context.p);
});
test('standalone login page works', async (t) => {
const {browser, context, p} = t.context;

7
tests/ui/payments.js

@ -1,5 +1,5 @@
import test from 'ava';
import {sleep, random_user, tid, expect, playstart, } from '../../lib/testing.js';
import {sleep, random_user, tid, expect, playstart, playstop } from '../../lib/testing.js';
import {knex} from '../../lib/ormish.js';
import { User } from "../../lib/models.js";
@ -11,8 +11,8 @@ test.before(async t => {
});
test.after(async t => {
await t.context.browser.close();
knex.destroy();
await playstop(t.context.browser, t.context.p);
});
const login = async (t, p) => {
@ -55,8 +55,7 @@ test('test /FairPay works', async (t) => {
} catch (error) {
console.log(error);
t.fail(error);
t.fail(error.message);
} finally {
await browser.close();
}
});

11
tests/ui/register.js

@ -1,12 +1,15 @@
import test from 'ava';
import {sleep, tid, playstart, form, wait} from '../../lib/testing.js';
import {sleep, tid, playstart, playstop, form, wait} from '../../lib/testing.js';
import faker from 'faker';
import {knex} from '../../lib/ormish.js';
import { User } from "../../lib/models.js";
test.before(async t => t.context = await playstart('http://localhost:5001/client/#/register/'));
test.after(async t => await t.context.browser.close());
test.after(async t => {
knex.destroy();
await playstop(t.context.browser, t.context.p);
});
test('register form error', async (t) => {
const {browser, context, p} = t.context;
@ -49,8 +52,6 @@ test('register form error', async (t) => {
await User.delete({id: res[0].id});
} catch (error) {
console.log(error);
t.fail(error);
} finally {
await browser.close();
t.fail(error.message);
}
});

Loading…
Cancel
Save