@ihyeon/error-to-test 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.ko.md +51 -0
- package/README.md +111 -2
- package/bin/error-to-test.mjs +3 -0
- package/dist/analysis.d.ts +7 -0
- package/dist/analysis.js +35 -0
- package/dist/artifacts.d.ts +15 -0
- package/dist/artifacts.js +120 -0
- package/dist/candidates.d.ts +3 -0
- package/dist/candidates.js +188 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +146 -0
- package/dist/exports/flow-qa.d.ts +4 -0
- package/dist/exports/flow-qa.js +122 -0
- package/dist/grouping.d.ts +2 -0
- package/dist/grouping.js +73 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/input.d.ts +13 -0
- package/dist/input.js +270 -0
- package/dist/redact.d.ts +3 -0
- package/dist/redact.js +47 -0
- package/dist/results.d.ts +2 -0
- package/dist/results.js +70 -0
- package/dist/types.d.ts +207 -0
- package/dist/types.js +1 -0
- package/dist/validation.d.ts +8 -0
- package/dist/validation.js +102 -0
- package/docs/releases.md +44 -0
- package/examples/error.txt +2 -0
- package/examples/errors.json +27 -0
- package/examples/manual.json +15 -0
- package/examples/profile.json +34 -0
- package/package.json +26 -4
package/dist/redact.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const URL_PATTERN = /(?:\bhttps?:\/\/|(?<!:)\/\/)[^\s<>"']+/gi;
|
|
2
|
+
const EMAIL = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
3
|
+
const JSON_SECRET = /(["'])(authorization|auth|token|access[_-]?token|refresh[_-]?token|api[_-]?key|private[_-]?key|client[_-]?secret|password|passwd|passcode|pin|otp|secret|cookie|session[_-]?id)\1(\s*:\s*)(["'])(?:\\.|(?!\4)[\s\S])*?\4/gi;
|
|
4
|
+
const JSON_SECRET_SCALAR = /(["'])(authorization|auth|token|access[_-]?token|refresh[_-]?token|api[_-]?key|private[_-]?key|client[_-]?secret|password|passwd|passcode|pin|otp|secret|cookie|session[_-]?id)\1(\s*:\s*)(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)(?=\s*[,}\]])/gi;
|
|
5
|
+
const SECRET = /\b(authorization|auth|token|access[_-]?token|refresh[_-]?token|api[_-]?key|private[_-]?key|client[_-]?secret|password|passwd|passcode|pin|otp|secret|cookie|session[_-]?id)\s*[:=]\s*(?:["']?)(?:Bearer\s+)?[^\s,;"']+/gi;
|
|
6
|
+
const STANDALONE_TOKEN = /\b(?:gh[oprsu]_[A-Za-z0-9_]{16,}|xox[baprs]-[A-Za-z0-9-]{16,}|sk-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{16,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,})\b/g;
|
|
7
|
+
const PRIVATE_KEY = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/g;
|
|
8
|
+
export function safeUrl(value) {
|
|
9
|
+
try {
|
|
10
|
+
const url = value.startsWith('//') ? new URL(value, 'https://placeholder.invalid/') : new URL(value);
|
|
11
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:')
|
|
12
|
+
return '[redacted-url]';
|
|
13
|
+
return `${url.origin}${redactTextWithoutUrls(url.pathname)}`;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
if (value.startsWith('//'))
|
|
17
|
+
return '[redacted-url]';
|
|
18
|
+
const path = value.split(/[?#]/, 1)[0] ?? '';
|
|
19
|
+
return redactTextWithoutUrls(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function redactTextWithoutUrls(value) {
|
|
23
|
+
return value
|
|
24
|
+
.replace(PRIVATE_KEY, '[redacted-private-key]')
|
|
25
|
+
.replace(JSON_SECRET, '$1$2$1$3$4[redacted]$4')
|
|
26
|
+
.replace(JSON_SECRET_SCALAR, '$1$2$1$3"[redacted]"')
|
|
27
|
+
.replace(/\bBearer\s+[^\s,;"']+/gi, 'Bearer [redacted]')
|
|
28
|
+
.replace(SECRET, '$1=[redacted]')
|
|
29
|
+
.replace(STANDALONE_TOKEN, '[redacted-token]')
|
|
30
|
+
.replace(EMAIL, '[redacted-email]');
|
|
31
|
+
}
|
|
32
|
+
export function redactText(value) {
|
|
33
|
+
return redactTextWithoutUrls(value.replace(URL_PATTERN, (match) => safeUrl(match)));
|
|
34
|
+
}
|
|
35
|
+
export function pagePath(value) {
|
|
36
|
+
if (!value)
|
|
37
|
+
return '';
|
|
38
|
+
try {
|
|
39
|
+
const url = value.startsWith('//') ? new URL(value, 'https://placeholder.invalid/') : new URL(value);
|
|
40
|
+
return redactTextWithoutUrls(url.pathname || '/');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
if (value.startsWith('//'))
|
|
44
|
+
return '[redacted-path]';
|
|
45
|
+
return redactTextWithoutUrls((value.split(/[?#]/, 1)[0] ?? '').replace(/^https?:\/\/[^/]+/i, '') || '/');
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/results.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { lstat, mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { jsonText, readBoundedFile, verifyBundle } from "./artifacts.js";
|
|
4
|
+
import { record, text, timestamp } from "./validation.js";
|
|
5
|
+
import { redactText } from "./redact.js";
|
|
6
|
+
const runStatuses = new Set(['passed', 'failed', 'blocked', 'error', 'interrupted']);
|
|
7
|
+
const caseStatuses = new Set(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']);
|
|
8
|
+
/** Associate a normalized Flow QA report with the exact exported immutable suite. */
|
|
9
|
+
export async function linkFlowQaReport(directory, rawReport) {
|
|
10
|
+
const root = resolve(directory);
|
|
11
|
+
const verified = await verifyBundle(root);
|
|
12
|
+
if (!verified.suite)
|
|
13
|
+
throw new Error('This bundle has no suite to associate with a run.');
|
|
14
|
+
const provenance = record(JSON.parse(await readBoundedFile(resolve(root, 'provenance.json'))), 'provenance');
|
|
15
|
+
const report = record(rawReport, 'report');
|
|
16
|
+
if (report.schemaVersion !== 'flow-qa/report-1')
|
|
17
|
+
throw new Error('Use a normalized Flow QA report-1, not an e2e raw report.');
|
|
18
|
+
const runId = text(report.runId, 'report.runId');
|
|
19
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(runId))
|
|
20
|
+
throw new Error('Invalid Flow QA run ID.');
|
|
21
|
+
if (report.suiteHash !== provenance.suiteSha256)
|
|
22
|
+
throw new Error('The run used a different suite. Its result cannot be linked to these candidates.');
|
|
23
|
+
const status = text(report.status, 'report.status');
|
|
24
|
+
if (!runStatuses.has(status))
|
|
25
|
+
throw new Error('Invalid Flow QA run status.');
|
|
26
|
+
if (!Array.isArray(report.cases) || report.cases.length > 100 || !Array.isArray(provenance.mappings))
|
|
27
|
+
throw new Error('Invalid Flow QA case list.');
|
|
28
|
+
const mappings = provenance.mappings.map((item, index) => record(item, `mappings[${index}]`));
|
|
29
|
+
const expected = new Map(mappings.map(item => [item.caseId, item]));
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const cases = report.cases.map((item, index) => {
|
|
32
|
+
const original = record(item, `report.cases[${index}]`), id = text(original.id, 'case.id');
|
|
33
|
+
const mapping = expected.get(id);
|
|
34
|
+
if (!mapping || seen.has(id))
|
|
35
|
+
throw new Error('The report contains unknown or duplicate case IDs.');
|
|
36
|
+
seen.add(id);
|
|
37
|
+
const caseStatus = text(original.status, 'case.status');
|
|
38
|
+
if (!caseStatuses.has(caseStatus))
|
|
39
|
+
throw new Error('Invalid Flow QA case status.');
|
|
40
|
+
return { ...mapping, status: caseStatus, ...(original.reason === undefined ? {} : { reason: redactText(text(original.reason, 'case.reason')) }) };
|
|
41
|
+
});
|
|
42
|
+
if (seen.size !== expected.size)
|
|
43
|
+
throw new Error('The report does not account for every exported case.');
|
|
44
|
+
if (status === 'passed' && cases.some(item => item.status === 'failed' || item.status === 'error'))
|
|
45
|
+
throw new Error('The report status contradicts its case results.');
|
|
46
|
+
const startedAt = timestamp(report.startedAt, 'report.startedAt'), finishedAt = timestamp(report.finishedAt, 'report.finishedAt');
|
|
47
|
+
if (finishedAt < startedAt)
|
|
48
|
+
throw new Error('The run finished before its start timestamp.');
|
|
49
|
+
const output = {
|
|
50
|
+
schemaVersion: 'error-to-test/results-1', runId,
|
|
51
|
+
inputSha256: provenance.inputSha256, suiteSha256: provenance.suiteSha256,
|
|
52
|
+
startedAt, finishedAt,
|
|
53
|
+
status, cases,
|
|
54
|
+
note: 'These results cover the specified assertions. No source issue was automatically closed.',
|
|
55
|
+
};
|
|
56
|
+
const resultsRoot = resolve(root, 'results');
|
|
57
|
+
try {
|
|
58
|
+
await mkdir(resultsRoot, { mode: 0o700 });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error.code !== 'EEXIST')
|
|
62
|
+
throw error;
|
|
63
|
+
const info = await lstat(resultsRoot);
|
|
64
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
65
|
+
throw new Error('Results must be stored in a real directory inside this bundle.');
|
|
66
|
+
}
|
|
67
|
+
const file = resolve(resultsRoot, `${runId}.json`);
|
|
68
|
+
await writeFile(file, jsonText(output), { flag: 'wx', mode: 0o600 });
|
|
69
|
+
return file;
|
|
70
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export type EventType = 'javascript' | 'promise' | 'react' | 'console' | 'http' | 'network' | 'manual';
|
|
2
|
+
export type Runtime = 'browser' | 'webview-ios' | 'webview-android' | 'unknown';
|
|
3
|
+
export type Locator = {
|
|
4
|
+
by: 'role';
|
|
5
|
+
value: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
} | {
|
|
8
|
+
by: 'text' | 'label' | 'testId';
|
|
9
|
+
value: string;
|
|
10
|
+
};
|
|
11
|
+
export type WebStep = {
|
|
12
|
+
type: 'open';
|
|
13
|
+
path: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'act';
|
|
16
|
+
instruction: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'click';
|
|
19
|
+
locator: Locator;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'fill';
|
|
22
|
+
locator: Locator;
|
|
23
|
+
value: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'assertVisible';
|
|
26
|
+
locator: Locator;
|
|
27
|
+
visible: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'assertText';
|
|
30
|
+
locator: Locator;
|
|
31
|
+
expected: string;
|
|
32
|
+
match: 'equals' | 'contains';
|
|
33
|
+
} | {
|
|
34
|
+
type: 'assertUrl';
|
|
35
|
+
expected: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'assertAgent';
|
|
38
|
+
instruction: string;
|
|
39
|
+
};
|
|
40
|
+
export interface ErrorObservation {
|
|
41
|
+
id: string;
|
|
42
|
+
source: 'browser-error' | 'manual';
|
|
43
|
+
project: string;
|
|
44
|
+
environment: string;
|
|
45
|
+
release: string;
|
|
46
|
+
type: EventType;
|
|
47
|
+
message: string;
|
|
48
|
+
runtime: Runtime;
|
|
49
|
+
name?: string;
|
|
50
|
+
stack?: string;
|
|
51
|
+
componentStack?: string;
|
|
52
|
+
page?: string;
|
|
53
|
+
occurredAt?: string;
|
|
54
|
+
viewId?: string;
|
|
55
|
+
network?: {
|
|
56
|
+
method: string;
|
|
57
|
+
url: string;
|
|
58
|
+
status?: number;
|
|
59
|
+
durationMs?: number;
|
|
60
|
+
};
|
|
61
|
+
reproduction: string[];
|
|
62
|
+
preconditions: string[];
|
|
63
|
+
questions: string[];
|
|
64
|
+
expected?: string;
|
|
65
|
+
expectedSource?: string;
|
|
66
|
+
steps: WebStep[];
|
|
67
|
+
}
|
|
68
|
+
export interface SourceCoverage {
|
|
69
|
+
kind: 'browser-error-json' | 'manual-json' | 'manual-text';
|
|
70
|
+
frequency: 'captured-events' | 'submitted-reports';
|
|
71
|
+
partial: boolean;
|
|
72
|
+
inputCount: number;
|
|
73
|
+
duplicates: number;
|
|
74
|
+
filtered: number;
|
|
75
|
+
retention: 'unknown';
|
|
76
|
+
period?: {
|
|
77
|
+
from?: string;
|
|
78
|
+
to?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface ParsedInput {
|
|
82
|
+
observations: ErrorObservation[];
|
|
83
|
+
coverage: SourceCoverage;
|
|
84
|
+
sha256: string;
|
|
85
|
+
warnings: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface IssueGroup {
|
|
88
|
+
id: string;
|
|
89
|
+
fingerprintVersion: 1;
|
|
90
|
+
project: string;
|
|
91
|
+
environment: string;
|
|
92
|
+
release: string;
|
|
93
|
+
runtime: Runtime;
|
|
94
|
+
type: EventType;
|
|
95
|
+
pagePath: string;
|
|
96
|
+
signature: string;
|
|
97
|
+
message: string;
|
|
98
|
+
count: number;
|
|
99
|
+
viewCount: number;
|
|
100
|
+
lastOccurredAt?: string;
|
|
101
|
+
eventIds: string[];
|
|
102
|
+
evidence: ErrorObservation[];
|
|
103
|
+
context?: {
|
|
104
|
+
expected?: string;
|
|
105
|
+
expectedSource?: string;
|
|
106
|
+
reproduction?: string[];
|
|
107
|
+
preconditions?: string[];
|
|
108
|
+
steps?: WebStep[];
|
|
109
|
+
questions: string[];
|
|
110
|
+
conflicts: string[];
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface ScenarioRule {
|
|
114
|
+
id: string;
|
|
115
|
+
title: string;
|
|
116
|
+
match: {
|
|
117
|
+
type?: EventType;
|
|
118
|
+
messageIncludes?: string;
|
|
119
|
+
pagePath?: string;
|
|
120
|
+
networkPath?: string;
|
|
121
|
+
environment?: string;
|
|
122
|
+
release?: string;
|
|
123
|
+
runtime?: Runtime;
|
|
124
|
+
};
|
|
125
|
+
requirement: string;
|
|
126
|
+
expectedSource: string;
|
|
127
|
+
preconditions: string[];
|
|
128
|
+
setupConfirmed: boolean;
|
|
129
|
+
questions: string[];
|
|
130
|
+
steps: WebStep[];
|
|
131
|
+
}
|
|
132
|
+
export interface AppProfile {
|
|
133
|
+
schemaVersion: 'error-to-test/profile-1';
|
|
134
|
+
name: string;
|
|
135
|
+
scenarios: ScenarioRule[];
|
|
136
|
+
}
|
|
137
|
+
export interface TestCandidate {
|
|
138
|
+
id: string;
|
|
139
|
+
groupId: string;
|
|
140
|
+
title: string;
|
|
141
|
+
state: 'needs-context' | 'draft';
|
|
142
|
+
facts: string[];
|
|
143
|
+
hypotheses: string[];
|
|
144
|
+
reproduction: string[];
|
|
145
|
+
preconditions: string[];
|
|
146
|
+
expected?: {
|
|
147
|
+
text: string;
|
|
148
|
+
source: string;
|
|
149
|
+
};
|
|
150
|
+
questions: string[];
|
|
151
|
+
steps: WebStep[];
|
|
152
|
+
eventIds: string[];
|
|
153
|
+
ruleId?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface Analysis {
|
|
156
|
+
schemaVersion: 'error-to-test/analysis-1';
|
|
157
|
+
source: {
|
|
158
|
+
sha256: string;
|
|
159
|
+
profileSha256?: string;
|
|
160
|
+
};
|
|
161
|
+
coverage: SourceCoverage;
|
|
162
|
+
groups: IssueGroup[];
|
|
163
|
+
candidates: TestCandidate[];
|
|
164
|
+
warnings: string[];
|
|
165
|
+
}
|
|
166
|
+
export interface FlowQaSuite {
|
|
167
|
+
schemaVersion: 'flow-qa/suite-1';
|
|
168
|
+
platform: 'web';
|
|
169
|
+
id: string;
|
|
170
|
+
title: string;
|
|
171
|
+
source?: {
|
|
172
|
+
file: string;
|
|
173
|
+
sha256: string;
|
|
174
|
+
};
|
|
175
|
+
requirements: {
|
|
176
|
+
id: string;
|
|
177
|
+
text: string;
|
|
178
|
+
}[];
|
|
179
|
+
cases: {
|
|
180
|
+
id: string;
|
|
181
|
+
title: string;
|
|
182
|
+
requirementIds: string[];
|
|
183
|
+
preconditions: string[];
|
|
184
|
+
questions: string[];
|
|
185
|
+
steps: WebStep[];
|
|
186
|
+
}[];
|
|
187
|
+
}
|
|
188
|
+
export interface FlowQaExport {
|
|
189
|
+
flow: string;
|
|
190
|
+
suite?: FlowQaSuite;
|
|
191
|
+
provenance: {
|
|
192
|
+
schemaVersion: 'error-to-test/provenance-1';
|
|
193
|
+
inputSha256: string;
|
|
194
|
+
analysisSha256: string;
|
|
195
|
+
reportSha256?: string;
|
|
196
|
+
profileSha256?: string;
|
|
197
|
+
flowSha256: string;
|
|
198
|
+
suiteSha256?: string;
|
|
199
|
+
reviewed: boolean;
|
|
200
|
+
mappings: {
|
|
201
|
+
caseId: string;
|
|
202
|
+
candidateId: string;
|
|
203
|
+
groupId: string;
|
|
204
|
+
eventIds: string[];
|
|
205
|
+
}[];
|
|
206
|
+
};
|
|
207
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WebStep } from './types.ts';
|
|
2
|
+
export declare function hash(value: string): string;
|
|
3
|
+
export declare function record(value: unknown, label: string): Record<string, unknown>;
|
|
4
|
+
export declare function text(value: unknown, label: string, required?: boolean): string;
|
|
5
|
+
export declare function optionalText(value: unknown, label: string): string | undefined;
|
|
6
|
+
export declare function strings(value: unknown, label: string): string[];
|
|
7
|
+
export declare function timestamp(value: unknown, label: string): string;
|
|
8
|
+
export declare function parseWebSteps(value: unknown, label: string): WebStep[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export function hash(value) {
|
|
3
|
+
return createHash('sha256').update(value).digest('hex');
|
|
4
|
+
}
|
|
5
|
+
export function record(value, label) {
|
|
6
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
7
|
+
throw new Error(`${label} must be an object.`);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
export function text(value, label, required = true) {
|
|
11
|
+
if (typeof value !== 'string' || (required && !value.trim()) || value.length > 8192)
|
|
12
|
+
throw new Error(`${label} must be ${required ? 'a non-empty' : 'a'} string of at most 8192 characters.`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
export function optionalText(value, label) {
|
|
16
|
+
return value === undefined ? undefined : text(value, label);
|
|
17
|
+
}
|
|
18
|
+
export function strings(value, label) {
|
|
19
|
+
if (value === undefined)
|
|
20
|
+
return [];
|
|
21
|
+
if (!Array.isArray(value) || value.length > 100)
|
|
22
|
+
throw new Error(`${label} must be an array of at most 100 strings.`);
|
|
23
|
+
return value.map((item, index) => text(item, `${label}[${index}]`));
|
|
24
|
+
}
|
|
25
|
+
export function timestamp(value, label) {
|
|
26
|
+
const input = text(value, label);
|
|
27
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|([+-])(\d{2}):(\d{2}))$/.exec(input);
|
|
28
|
+
if (!match)
|
|
29
|
+
throw new Error(`${label} must be an ISO timestamp with a timezone.`);
|
|
30
|
+
const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
|
|
31
|
+
const offsetHour = Number(match[10] ?? 0), offsetMinute = Number(match[11] ?? 0);
|
|
32
|
+
if (month < 1 || month > 12 || day < 1 || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59)
|
|
33
|
+
throw new Error(`${label} is not a valid timestamp.`);
|
|
34
|
+
const parsed = Date.parse(input);
|
|
35
|
+
const offset = match[8] === 'Z' ? 0 : (match[9] === '+' ? 1 : -1) * (offsetHour * 60 + offsetMinute);
|
|
36
|
+
const local = new Date(parsed + offset * 60000);
|
|
37
|
+
if (!Number.isFinite(parsed) || local.getUTCFullYear() !== year || local.getUTCMonth() + 1 !== month || local.getUTCDate() !== day || local.getUTCHours() !== hour || local.getUTCMinutes() !== minute || local.getUTCSeconds() !== second)
|
|
38
|
+
throw new Error(`${label} is not a valid timestamp.`);
|
|
39
|
+
return new Date(parsed).toISOString();
|
|
40
|
+
}
|
|
41
|
+
const roles = new Set(['button', 'link', 'textbox', 'heading', 'checkbox', 'radio', 'combobox', 'option', 'status', 'alert', 'dialog', 'tab', 'row', 'cell', 'list', 'listitem', 'navigation', 'searchbox', 'switch']);
|
|
42
|
+
function exactKeys(raw, keys, label) {
|
|
43
|
+
if (Object.keys(raw).some(key => !keys.includes(key)))
|
|
44
|
+
throw new Error(`${label} contains unsupported fields.`);
|
|
45
|
+
}
|
|
46
|
+
function locator(value, label) {
|
|
47
|
+
const raw = record(value, label);
|
|
48
|
+
if (raw.by === 'role') {
|
|
49
|
+
exactKeys(raw, ['by', 'value', 'name'], label);
|
|
50
|
+
const role = text(raw.value, `${label}.value`);
|
|
51
|
+
if (!roles.has(role))
|
|
52
|
+
throw new Error(`${label}.value is not a supported role.`);
|
|
53
|
+
const name = optionalText(raw.name, `${label}.name`);
|
|
54
|
+
return { by: 'role', value: role, ...(name !== undefined ? { name } : {}) };
|
|
55
|
+
}
|
|
56
|
+
if (raw.by !== 'text' && raw.by !== 'label' && raw.by !== 'testId')
|
|
57
|
+
throw new Error(`${label}.by is not supported.`);
|
|
58
|
+
exactKeys(raw, ['by', 'value'], label);
|
|
59
|
+
return { by: raw.by, value: text(raw.value, `${label}.value`) };
|
|
60
|
+
}
|
|
61
|
+
export function parseWebSteps(value, label) {
|
|
62
|
+
if (value === undefined)
|
|
63
|
+
return [];
|
|
64
|
+
if (!Array.isArray(value) || value.length > 100)
|
|
65
|
+
throw new Error(`${label} must be an array of at most 100 steps.`);
|
|
66
|
+
return value.map((item, index) => {
|
|
67
|
+
const key = `${label}[${index}]`, raw = record(item, key);
|
|
68
|
+
switch (raw.type) {
|
|
69
|
+
case 'open': {
|
|
70
|
+
exactKeys(raw, ['type', 'path'], key);
|
|
71
|
+
const path = text(raw.path, `${key}.path`);
|
|
72
|
+
if (!path.startsWith('/') || path.startsWith('//') || path.includes('\\') || /[\p{Cc}\p{Cf}]/u.test(path))
|
|
73
|
+
throw new Error(`${key}.path must be an app-relative path.`);
|
|
74
|
+
return { type: 'open', path };
|
|
75
|
+
}
|
|
76
|
+
case 'act':
|
|
77
|
+
case 'assertAgent':
|
|
78
|
+
exactKeys(raw, ['type', 'instruction'], key);
|
|
79
|
+
return { type: raw.type, instruction: text(raw.instruction, `${key}.instruction`) };
|
|
80
|
+
case 'click':
|
|
81
|
+
exactKeys(raw, ['type', 'locator'], key);
|
|
82
|
+
return { type: 'click', locator: locator(raw.locator, `${key}.locator`) };
|
|
83
|
+
case 'fill':
|
|
84
|
+
exactKeys(raw, ['type', 'locator', 'value'], key);
|
|
85
|
+
return { type: 'fill', locator: locator(raw.locator, `${key}.locator`), value: text(raw.value, `${key}.value`, false) };
|
|
86
|
+
case 'assertVisible':
|
|
87
|
+
exactKeys(raw, ['type', 'locator', 'visible'], key);
|
|
88
|
+
if (raw.visible !== undefined && typeof raw.visible !== 'boolean')
|
|
89
|
+
throw new Error(`${key}.visible must be a boolean.`);
|
|
90
|
+
return { type: 'assertVisible', locator: locator(raw.locator, `${key}.locator`), visible: raw.visible !== false };
|
|
91
|
+
case 'assertText':
|
|
92
|
+
exactKeys(raw, ['type', 'locator', 'expected', 'match'], key);
|
|
93
|
+
if (raw.match !== undefined && raw.match !== 'equals' && raw.match !== 'contains')
|
|
94
|
+
throw new Error(`${key}.match must be equals or contains.`);
|
|
95
|
+
return { type: 'assertText', locator: locator(raw.locator, `${key}.locator`), expected: text(raw.expected, `${key}.expected`), match: raw.match ?? 'equals' };
|
|
96
|
+
case 'assertUrl':
|
|
97
|
+
exactKeys(raw, ['type', 'expected'], key);
|
|
98
|
+
return { type: 'assertUrl', expected: text(raw.expected, `${key}.expected`) };
|
|
99
|
+
default: throw new Error(`${key}.type is not a supported web step.`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
package/docs/releases.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Releases and verification
|
|
2
|
+
|
|
3
|
+
Package: `@ihyeon/error-to-test` · Repository: [hyeonse-swing/error-to-test](https://github.com/hyeonse-swing/error-to-test) · Workflow: `.github/workflows/ci.yml`.
|
|
4
|
+
|
|
5
|
+
## Automatic publication
|
|
6
|
+
|
|
7
|
+
Pull requests and main pushes verify the package on Ubuntu and macOS. A verified main push then prepares an immutable release source:
|
|
8
|
+
|
|
9
|
+
- The first publication uses the manifest version (`0.1.0`). A new npm package needs one authenticated bootstrap publication before its Trusted Publisher can be configured.
|
|
10
|
+
- Changes to `src/`, `bin/`, `examples/`, `LICENSE`, `package.json`, `package-lock.json`, or `tsconfig.json` automatically increase patch when the manifest still matches npm latest. The workflow commits the version change as `github-actions[bot]` and publishes that exact commit in the same run.
|
|
11
|
+
- Documentation/test-only pushes skip publication. They still run verification.
|
|
12
|
+
- To request a minor/major release, increase package and lock versions together (for example `npm version minor --no-git-tag-version`) and push to main. Stable `X.Y.Z` versions only.
|
|
13
|
+
- Failed publication can be retried on the original workflow run. An already prepared direct bot patch is reused. Existing versions must match the selected source SHA; they are never overwritten or silently accepted from another source.
|
|
14
|
+
- Main workflows are serialized without cancellation. If main advances to an unrelated commit during preparation, the old run stops instead of moving the branch backwards.
|
|
15
|
+
|
|
16
|
+
Publishing uses npm Trusted Publishing (GitHub Actions OIDC) for `hyeonse-swing/error-to-test`, workflow `ci.yml`, with direct-publish permission. No long-lived npm secret is stored in GitHub. The publisher checks registry version/source SHA, downloads and verifies SHA-512 tarball bytes, and installs the registry package into a fresh consumer for import/CLI checks. Only then does the workflow create or confirm `v<version>` and a GitHub Release pointing at the same source commit.
|
|
17
|
+
|
|
18
|
+
## Local checks
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm ci
|
|
22
|
+
npm run check
|
|
23
|
+
npm run check:package
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To test real error capture and browser execution, supply local checked-out SDK/Flow QA sources and an installed Chromium browser:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
FLOW_QA_SOURCE=/path/to/flow-qa BROWSER_ERROR_SOURCE=/path/to/browser-error-log npm run smoke:flowqa
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The browser integration was verified on 2026-10-13 with a controlled local application and no model calls or external account:
|
|
33
|
+
|
|
34
|
+
| Check | Observed result |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| Real SDK events to grouped TC candidates | 3 groups, 2 actionable drafts, 1 unresolved case |
|
|
37
|
+
| Review gate | All 3 unreviewed cases blocked |
|
|
38
|
+
| Before repair | 2 regression cases failed; unresolved case blocked |
|
|
39
|
+
| After repair | Both regression cases passed; unresolved case stayed blocked |
|
|
40
|
+
| Flow QA UI library | Generated suite discovered and loaded |
|
|
41
|
+
| Report linkage | Before/after reports linked to the exact suite and source groups |
|
|
42
|
+
| Changed source | Stale flow and bundle rejected |
|
|
43
|
+
|
|
44
|
+
An unresolved case means the overall QA run can remain `blocked` even when the two runnable cases pass. This integration check is separate from standalone CI and requires the sibling packages; CI does not fetch company repositories or application data. Live service authentication, native devices, and production behavior are outside this proof.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"partial": true,
|
|
4
|
+
"events": [
|
|
5
|
+
{
|
|
6
|
+
"schemaVersion": 1, "eventId": "demo-js-1", "project": "error-to-test-demo", "environment": "test", "release": "buggy", "sdkVersion": "0.1.5",
|
|
7
|
+
"occurredAt": "2026-10-13T01:00:00Z", "viewId": "view-1", "sequence": 1, "elapsedMs": 100,
|
|
8
|
+
"type": "javascript", "name": "TypeError", "message": "Cannot read properties of undefined (reading 'name')", "stack": "at renderItem (/app.js:33:8)", "page": "http://127.0.0.1:4179/items", "runtime": "browser"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"schemaVersion": 1, "eventId": "demo-js-2", "project": "error-to-test-demo", "environment": "test", "release": "buggy", "sdkVersion": "0.1.5",
|
|
12
|
+
"occurredAt": "2026-10-13T01:01:00Z", "viewId": "view-2", "sequence": 1, "elapsedMs": 100,
|
|
13
|
+
"type": "javascript", "name": "TypeError", "message": "Cannot read properties of undefined (reading 'name')", "stack": "at renderItem (/app.js:33:8)", "page": "http://127.0.0.1:4179/items", "runtime": "browser"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"schemaVersion": 1, "eventId": "demo-http-1", "project": "error-to-test-demo", "environment": "test", "release": "buggy", "sdkVersion": "0.1.5",
|
|
17
|
+
"occurredAt": "2026-10-13T01:02:00Z", "viewId": "view-3", "sequence": 1, "elapsedMs": 100,
|
|
18
|
+
"type": "http", "message": "HTTP 503 GET /api/items", "page": "http://127.0.0.1:4179/network", "runtime": "browser",
|
|
19
|
+
"network": { "method": "GET", "url": "http://127.0.0.1:4179/api/items", "status": 503, "durationMs": 20 }
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"schemaVersion": 1, "eventId": "demo-unknown-1", "project": "error-to-test-demo", "environment": "test", "release": "buggy", "sdkVersion": "0.1.5",
|
|
23
|
+
"occurredAt": "2026-10-13T01:03:00Z", "viewId": "view-4", "sequence": 1, "elapsedMs": 100,
|
|
24
|
+
"type": "manual", "message": "Missing product policy for this error", "page": "http://127.0.0.1:4179/unknown", "runtime": "browser"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "error-to-test/manual-1",
|
|
3
|
+
"errors": [
|
|
4
|
+
{
|
|
5
|
+
"message": "TypeError: Cannot read properties of undefined (reading 'name')",
|
|
6
|
+
"type": "javascript",
|
|
7
|
+
"runtime": "browser",
|
|
8
|
+
"page": "/items",
|
|
9
|
+
"stack": "at renderItem (/app.js:33:8)",
|
|
10
|
+
"reproduction": ["Open the item list", "Click View item when the item is missing"],
|
|
11
|
+
"expected": "Show Item unavailable instead of breaking the panel",
|
|
12
|
+
"expectedSource": "Reported intended behavior; confirm with the app owner"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "error-to-test/profile-1",
|
|
3
|
+
"name": "Controlled local error-handling demo",
|
|
4
|
+
"scenarios": [
|
|
5
|
+
{
|
|
6
|
+
"id": "missing-item", "title": "Missing item shows a fallback",
|
|
7
|
+
"match": { "pagePath": "/items", "messageIncludes": "reading 'name'" },
|
|
8
|
+
"requirement": "Clicking View item with missing item data shows Item unavailable.",
|
|
9
|
+
"expectedSource": "Local demo contract: missing item fallback",
|
|
10
|
+
"preconditions": ["Use the local demo; item data is intentionally missing on a fresh page."],
|
|
11
|
+
"setupConfirmed": true,
|
|
12
|
+
"steps": [
|
|
13
|
+
{ "type": "open", "path": "/items" },
|
|
14
|
+
{ "type": "click", "locator": { "by": "role", "value": "button", "name": "View item" } },
|
|
15
|
+
{ "type": "assertText", "locator": { "by": "role", "value": "status" }, "expected": "Item unavailable", "match": "equals" }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "network-retry", "title": "Failed request explains the error and supports retry",
|
|
20
|
+
"match": { "type": "http", "pagePath": "/network", "networkPath": "/api/items" },
|
|
21
|
+
"requirement": "A 503 response shows Service unavailable. Retrying successfully displays Demo item.",
|
|
22
|
+
"expectedSource": "Local demo contract: deterministic first-request failure and retry",
|
|
23
|
+
"preconditions": ["Use the local demo; Load items returns 503 and Retry returns 200."],
|
|
24
|
+
"setupConfirmed": true,
|
|
25
|
+
"steps": [
|
|
26
|
+
{ "type": "open", "path": "/network" },
|
|
27
|
+
{ "type": "click", "locator": { "by": "role", "value": "button", "name": "Load items" } },
|
|
28
|
+
{ "type": "assertText", "locator": { "by": "role", "value": "alert" }, "expected": "Service unavailable", "match": "equals" },
|
|
29
|
+
{ "type": "click", "locator": { "by": "role", "value": "button", "name": "Retry" } },
|
|
30
|
+
{ "type": "assertText", "locator": { "by": "testId", "value": "item-list" }, "expected": "Demo item", "match": "equals" }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ihyeon/error-to-test",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Turn captured browser errors and pasted error reports into traceable regression test candidates.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Hyeonse Im",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/hyeonse-swing/error-to-test.git" },
|
|
8
|
+
"homepage": "https://github.com/hyeonse-swing/error-to-test#readme",
|
|
9
|
+
"bugs": { "url": "https://github.com/hyeonse-swing/error-to-test/issues" },
|
|
10
|
+
"keywords": ["browser-errors", "regression-testing", "test-cases", "qa", "cli", "flow-qa"],
|
|
11
|
+
"publishConfig": { "access": "public", "tag": "latest", "registry": "https://registry.npmjs.org" },
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": { "node": ">=24.8.0" },
|
|
14
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
15
|
+
"bin": { "error-to-test": "bin/error-to-test.mjs" },
|
|
16
|
+
"files": ["dist", "bin/error-to-test.mjs", "docs", "examples", "README.ko.md", "LICENSE"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"test": "node --test tests/*.test.ts",
|
|
21
|
+
"check": "npm run typecheck && npm test && npm run build",
|
|
22
|
+
"prepack": "npm run build",
|
|
23
|
+
"check:package": "npm run build && node scripts/package-smoke.mjs",
|
|
24
|
+
"smoke:flowqa": "node scripts/flowqa-smoke.ts",
|
|
25
|
+
"demo": "node bin/dev.mjs analyze --input examples/errors.json --profile examples/profile.json --out .error-to-test/demo"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": { "@types/node": "^24.0.0", "typescript": "5.9.3" }
|
|
28
|
+
}
|