kryptheon 0.1.57 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +38 -38
- package/README.md +8 -1
- package/kryptheon-api.js +614 -20
- package/kryptheon-baselines.js +232 -232
- package/kryptheon-changes.js +222 -222
- package/kryptheon-code.js +61 -1
- package/kryptheon-dashboard.js +8 -2
- package/kryptheon-fonts-OFL.txt +98 -98
- package/kryptheon-keys.js +353 -353
- package/kryptheon-map.js +152 -12
- package/kryptheon-probe-reporter.js +29 -29
- package/kryptheon-probe.config.js +37 -37
- package/kryptheon-project.js +600 -600
- package/kryptheon-roles.js +239 -37
- package/kryptheon-selectors.js +301 -301
- package/kryptheon-store.js +334 -334
- package/kryptheon-testfiles.js +98 -98
- package/kryptheon-webhook.js +332 -67
- package/package.json +1 -1
- package/playwright.config.js +73 -73
package/kryptheon-testfiles.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
// Which files in tests/ are Kryptheon's recordings, and what a new one is
|
|
2
|
-
// called.
|
|
3
|
-
//
|
|
4
|
-
// Found in blind round 13 (a TypeScript service with vitest): its own unit
|
|
5
|
-
// test, tests/incidents.test.ts, was taken for a recording - check said it
|
|
6
|
-
// "only opens a page and stops", and the dashboard showed "Record your main
|
|
7
|
-
// flows: Done, 1 recording held" before anything was recorded. Then the
|
|
8
|
-
// first real recording, saved as tests/<name>.spec.js, was picked up by the
|
|
9
|
-
// project's own `npm test` (vitest), which failed on it: "Playwright Test did
|
|
10
|
-
// not expect test() to be called here". A tool that breaks the app's own
|
|
11
|
-
// tests is one nobody keeps.
|
|
12
|
-
//
|
|
13
|
-
// So: a recording is a file that uses Playwright or Kryptheon's fixture -
|
|
14
|
-
// anything else in tests/ belongs to the project and is left alone. And in a
|
|
15
|
-
// project whose unit-test runner collects *.spec.js / *.test.js, a new
|
|
16
|
-
// recording is saved as <name>.kryptheon.js, which only Kryptheon runs.
|
|
17
|
-
|
|
18
|
-
const fs = require('fs');
|
|
19
|
-
const path = require('path');
|
|
20
|
-
|
|
21
|
-
const SPEC_NAME = /\.(spec|test)\.[cm]?[jt]sx?$/;
|
|
22
|
-
const OWN_NAME = /\.kryptheon\.js$/;
|
|
23
|
-
// What a recording imports: Playwright directly (older or hand-made ones,
|
|
24
|
-
// repaired by check) or the fixture - by package name, or by any path that
|
|
25
|
-
// ends in kryptheon-fixture(.js), relative or absolute.
|
|
26
|
-
const USES_PLAYWRIGHT = /(['"`])(?:@playwright\/test|[^'"`\r\n]*kryptheon-fixture(?:\.js)?)\1/;
|
|
27
|
-
|
|
28
|
-
/** Whether this file in tests/ is one of Kryptheon's recordings. */
|
|
29
|
-
function isRecordingFile(name, source) {
|
|
30
|
-
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
31
|
-
return USES_PLAYWRIGHT.test(String(source || ''));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** The recordings in a tests folder, as paths relative to it. */
|
|
35
|
-
function recordingNames(testsDir) {
|
|
36
|
-
let entries = [];
|
|
37
|
-
try {
|
|
38
|
-
entries = fs.readdirSync(testsDir, { recursive: true });
|
|
39
|
-
} catch (err) {
|
|
40
|
-
try {
|
|
41
|
-
entries = fs.readdirSync(testsDir);
|
|
42
|
-
} catch (err2) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return entries.map(String).filter((name) => {
|
|
47
|
-
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
48
|
-
try {
|
|
49
|
-
return isRecordingFile(name, fs.readFileSync(path.join(testsDir, name), 'utf8'));
|
|
50
|
-
} catch (err) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The unit-test runner this project uses that would also collect
|
|
58
|
-
* tests/*.spec.js or tests/*.test.js: 'vitest', 'jest', 'mocha' - or null.
|
|
59
|
-
*/
|
|
60
|
-
function unitRunnerOf(projectDir) {
|
|
61
|
-
let pkg = {};
|
|
62
|
-
try {
|
|
63
|
-
pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
|
|
64
|
-
} catch (err) {
|
|
65
|
-
pkg = {};
|
|
66
|
-
}
|
|
67
|
-
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
|
68
|
-
const script = String((pkg.scripts && pkg.scripts.test) || '');
|
|
69
|
-
let files = [];
|
|
70
|
-
try {
|
|
71
|
-
files = fs.readdirSync(projectDir);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
files = [];
|
|
74
|
-
}
|
|
75
|
-
const has = (re) => files.some((f) => re.test(f));
|
|
76
|
-
if (deps.vitest || /\bvitest\b/.test(script) || has(/^vitest\.config\./)) return 'vitest';
|
|
77
|
-
if (deps.jest || pkg.jest || /\bjest\b/.test(script) || has(/^jest\.config\./)) return 'jest';
|
|
78
|
-
if (deps.mocha || /\bmocha\b/.test(script) || has(/^\.mocharc/)) return 'mocha';
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** What a new recording's file name ends in, in this project. */
|
|
83
|
-
function recordingExtension(projectDir) {
|
|
84
|
-
return unitRunnerOf(projectDir) ? '.kryptheon.js' : '.spec.js';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** A recording's name without its ending: "login" for login.spec.js or login.kryptheon.js. */
|
|
88
|
-
function bareName(name) {
|
|
89
|
-
return String(name).replace(OWN_NAME, '').replace(/\.spec\.js$/, '');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports = {
|
|
93
|
-
isRecordingFile: isRecordingFile,
|
|
94
|
-
recordingNames: recordingNames,
|
|
95
|
-
unitRunnerOf: unitRunnerOf,
|
|
96
|
-
recordingExtension: recordingExtension,
|
|
97
|
-
bareName: bareName,
|
|
98
|
-
};
|
|
1
|
+
// Which files in tests/ are Kryptheon's recordings, and what a new one is
|
|
2
|
+
// called.
|
|
3
|
+
//
|
|
4
|
+
// Found in blind round 13 (a TypeScript service with vitest): its own unit
|
|
5
|
+
// test, tests/incidents.test.ts, was taken for a recording - check said it
|
|
6
|
+
// "only opens a page and stops", and the dashboard showed "Record your main
|
|
7
|
+
// flows: Done, 1 recording held" before anything was recorded. Then the
|
|
8
|
+
// first real recording, saved as tests/<name>.spec.js, was picked up by the
|
|
9
|
+
// project's own `npm test` (vitest), which failed on it: "Playwright Test did
|
|
10
|
+
// not expect test() to be called here". A tool that breaks the app's own
|
|
11
|
+
// tests is one nobody keeps.
|
|
12
|
+
//
|
|
13
|
+
// So: a recording is a file that uses Playwright or Kryptheon's fixture -
|
|
14
|
+
// anything else in tests/ belongs to the project and is left alone. And in a
|
|
15
|
+
// project whose unit-test runner collects *.spec.js / *.test.js, a new
|
|
16
|
+
// recording is saved as <name>.kryptheon.js, which only Kryptheon runs.
|
|
17
|
+
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const SPEC_NAME = /\.(spec|test)\.[cm]?[jt]sx?$/;
|
|
22
|
+
const OWN_NAME = /\.kryptheon\.js$/;
|
|
23
|
+
// What a recording imports: Playwright directly (older or hand-made ones,
|
|
24
|
+
// repaired by check) or the fixture - by package name, or by any path that
|
|
25
|
+
// ends in kryptheon-fixture(.js), relative or absolute.
|
|
26
|
+
const USES_PLAYWRIGHT = /(['"`])(?:@playwright\/test|[^'"`\r\n]*kryptheon-fixture(?:\.js)?)\1/;
|
|
27
|
+
|
|
28
|
+
/** Whether this file in tests/ is one of Kryptheon's recordings. */
|
|
29
|
+
function isRecordingFile(name, source) {
|
|
30
|
+
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
31
|
+
return USES_PLAYWRIGHT.test(String(source || ''));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The recordings in a tests folder, as paths relative to it. */
|
|
35
|
+
function recordingNames(testsDir) {
|
|
36
|
+
let entries = [];
|
|
37
|
+
try {
|
|
38
|
+
entries = fs.readdirSync(testsDir, { recursive: true });
|
|
39
|
+
} catch (err) {
|
|
40
|
+
try {
|
|
41
|
+
entries = fs.readdirSync(testsDir);
|
|
42
|
+
} catch (err2) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return entries.map(String).filter((name) => {
|
|
47
|
+
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
48
|
+
try {
|
|
49
|
+
return isRecordingFile(name, fs.readFileSync(path.join(testsDir, name), 'utf8'));
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The unit-test runner this project uses that would also collect
|
|
58
|
+
* tests/*.spec.js or tests/*.test.js: 'vitest', 'jest', 'mocha' - or null.
|
|
59
|
+
*/
|
|
60
|
+
function unitRunnerOf(projectDir) {
|
|
61
|
+
let pkg = {};
|
|
62
|
+
try {
|
|
63
|
+
pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
|
|
64
|
+
} catch (err) {
|
|
65
|
+
pkg = {};
|
|
66
|
+
}
|
|
67
|
+
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
|
68
|
+
const script = String((pkg.scripts && pkg.scripts.test) || '');
|
|
69
|
+
let files = [];
|
|
70
|
+
try {
|
|
71
|
+
files = fs.readdirSync(projectDir);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
files = [];
|
|
74
|
+
}
|
|
75
|
+
const has = (re) => files.some((f) => re.test(f));
|
|
76
|
+
if (deps.vitest || /\bvitest\b/.test(script) || has(/^vitest\.config\./)) return 'vitest';
|
|
77
|
+
if (deps.jest || pkg.jest || /\bjest\b/.test(script) || has(/^jest\.config\./)) return 'jest';
|
|
78
|
+
if (deps.mocha || /\bmocha\b/.test(script) || has(/^\.mocharc/)) return 'mocha';
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** What a new recording's file name ends in, in this project. */
|
|
83
|
+
function recordingExtension(projectDir) {
|
|
84
|
+
return unitRunnerOf(projectDir) ? '.kryptheon.js' : '.spec.js';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A recording's name without its ending: "login" for login.spec.js or login.kryptheon.js. */
|
|
88
|
+
function bareName(name) {
|
|
89
|
+
return String(name).replace(OWN_NAME, '').replace(/\.spec\.js$/, '');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
isRecordingFile: isRecordingFile,
|
|
94
|
+
recordingNames: recordingNames,
|
|
95
|
+
unitRunnerOf: unitRunnerOf,
|
|
96
|
+
recordingExtension: recordingExtension,
|
|
97
|
+
bareName: bareName,
|
|
98
|
+
};
|