@t0.labs/daxta 0.4.19 → 0.4.20
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/dist/catalog/index.js +8 -5
- package/dist/catalog/it-case.d.ts +16 -2
- package/dist/catalog/it-case.js +137 -49
- package/dist/catalog/test-title.d.ts +2 -0
- package/dist/catalog/test-title.js +31 -4
- package/dist/cli/titles.js +7 -1
- package/dist/path.util.js +2 -1
- package/dist/titles/scan.d.ts +1 -0
- package/dist/titles/scan.js +10 -4
- package/package.json +1 -1
package/dist/catalog/index.js
CHANGED
|
@@ -39,6 +39,9 @@ exports.STATUS_TEXT = {
|
|
|
39
39
|
const METHOD_ALIASES = {
|
|
40
40
|
update: ['patch', 'put'],
|
|
41
41
|
upsert: ['put', 'post', 'patch'],
|
|
42
|
+
insert: ['post'],
|
|
43
|
+
merge: ['post', 'put', 'patch'],
|
|
44
|
+
replace: ['put'],
|
|
42
45
|
};
|
|
43
46
|
const CASE_SECTION_RE = /^(POSITIVE CASES|SEMANTIC ERROR CASES(?:\s*-\s*AUTH)?|INVALID CASES|OMITTED(?: FIELD)? CASES)\s+/i;
|
|
44
47
|
function declaredMethods(test) {
|
|
@@ -49,7 +52,7 @@ function declaredMethods(test) {
|
|
|
49
52
|
const method = fromLabel.method.toLowerCase();
|
|
50
53
|
return METHOD_ALIASES[method] ?? [method];
|
|
51
54
|
}
|
|
52
|
-
const declared = test.match(
|
|
55
|
+
const declared = test.match(new RegExp(`\\[(${test_title_1.HTTP_VERBS})\\]`, 'i'));
|
|
53
56
|
if (!declared)
|
|
54
57
|
return null;
|
|
55
58
|
const method = declared[1].toLowerCase();
|
|
@@ -157,10 +160,10 @@ function apiTitle(test) {
|
|
|
157
160
|
if (fromLabel)
|
|
158
161
|
return fromLabel;
|
|
159
162
|
const patterns = [
|
|
160
|
-
/^(.+?\bAPI)\s*[-–—]\s*(?:GET|POST|PUT|PATCH|DELETE)\b/i,
|
|
163
|
+
/^(.+?\bAPI)\s*[-–—]\s*(?:GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT|INSERT|MERGE|REPLACE)\b/i,
|
|
161
164
|
/\]\s*(?:\([^)]*\)\s*)?(.+?\bAPI)\s+(?:POSITIVE|SEMANTIC|INVALID|OMITTED)\b/i,
|
|
162
165
|
/^(.+?\bAPI)\s+\/\S+\s+\[(?:GET|POST|PUT|PATCH|DELETE)/i,
|
|
163
|
-
|
|
166
|
+
new RegExp(`\\[(?:${test_title_1.HTTP_VERBS})\\]\\s*(?:\\([^)]*\\)\\s*)?(.+?\\bAPI)\\b`, 'i'),
|
|
164
167
|
];
|
|
165
168
|
for (const re of patterns) {
|
|
166
169
|
const match = test.match(re);
|
|
@@ -174,8 +177,8 @@ function caseName(test) {
|
|
|
174
177
|
if (!test)
|
|
175
178
|
return 'example';
|
|
176
179
|
let rest = test
|
|
177
|
-
.replace(
|
|
178
|
-
.replace(
|
|
180
|
+
.replace(new RegExp(`^.+?\\s+[—–-]\\s+(?:${test_title_1.HTTP_VERBS})\\s+\\S+\\s*`, 'i'), '')
|
|
181
|
+
.replace(new RegExp(`^.*?\\[(?:${test_title_1.HTTP_VERBS})\\]\\s*(?:\\(integration\\))?\\s*`, 'i'), '')
|
|
179
182
|
.replace(CASE_SECTION_RE, '')
|
|
180
183
|
.trim();
|
|
181
184
|
// "Admin Find One Basket By Id API - GET /path POSITIVE CASES returns…"
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
export type CaseSection = 'positive' | 'semantic' | 'invalid' | 'omitted' | 'auth';
|
|
2
2
|
export declare function parseCaseSection(raw?: string): CaseSection | undefined;
|
|
3
|
+
export declare function isDynamicItName(name?: string): boolean;
|
|
4
|
+
export declare function isGenericItName(name?: string): boolean;
|
|
3
5
|
export declare function isValidItCase(name?: string): boolean;
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Keep the unique clause from `should …` / existing it() text.
|
|
8
|
+
* Never collapse many cases into one generic sentence.
|
|
6
9
|
*/
|
|
7
|
-
export declare function
|
|
10
|
+
export declare function rewriteItFromOriginal(raw: string, section?: CaseSection, method?: string, pathTemplate?: string): string | undefined;
|
|
11
|
+
export type ItSuggestion = {
|
|
12
|
+
names: string[];
|
|
13
|
+
/** Safe for --yes / `a` — rewritten from this case's own text. */
|
|
14
|
+
auto: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Prefer a unique rewrite of the current it() name.
|
|
18
|
+
* Generic section templates are never auto-applied.
|
|
19
|
+
*/
|
|
20
|
+
export declare function suggestItCases(section: CaseSection | undefined, method?: string, pathTemplate?: string, original?: string): string[];
|
|
21
|
+
export declare function suggestItCaseResult(section: CaseSection | undefined, method?: string, pathTemplate?: string, original?: string): ItSuggestion;
|
package/dist/catalog/it-case.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseCaseSection = parseCaseSection;
|
|
4
|
+
exports.isDynamicItName = isDynamicItName;
|
|
5
|
+
exports.isGenericItName = isGenericItName;
|
|
4
6
|
exports.isValidItCase = isValidItCase;
|
|
7
|
+
exports.rewriteItFromOriginal = rewriteItFromOriginal;
|
|
5
8
|
exports.suggestItCases = suggestItCases;
|
|
9
|
+
exports.suggestItCaseResult = suggestItCaseResult;
|
|
6
10
|
const test_title_1 = require("./test-title");
|
|
7
|
-
const CASE_START = /^(returns|creates|updates|deletes|lists|rejects|conflicts)\b/i;
|
|
11
|
+
const CASE_START = /^(returns|creates|updates|upserts|inserts|merges|replaces|deletes|lists|rejects|conflicts)\b/i;
|
|
12
|
+
const GENERIC_IT = new Set([
|
|
13
|
+
'returns resource list when query is valid',
|
|
14
|
+
'returns resource when payload is valid',
|
|
15
|
+
'returns resource when request is valid',
|
|
16
|
+
'rejects when resource already exists',
|
|
17
|
+
'rejects when payload is invalid',
|
|
18
|
+
'rejects when a required field is omitted',
|
|
19
|
+
'rejects when unauthorized',
|
|
20
|
+
]);
|
|
8
21
|
function parseCaseSection(raw) {
|
|
9
22
|
if (!raw)
|
|
10
23
|
return undefined;
|
|
@@ -20,13 +33,28 @@ function parseCaseSection(raw) {
|
|
|
20
33
|
return 'omitted';
|
|
21
34
|
return undefined;
|
|
22
35
|
}
|
|
36
|
+
function isDynamicItName(name) {
|
|
37
|
+
return Boolean(name && /\$\{/.test(name));
|
|
38
|
+
}
|
|
39
|
+
function isGenericItName(name) {
|
|
40
|
+
const value = name?.trim().toLowerCase() ?? '';
|
|
41
|
+
if (GENERIC_IT.has(value))
|
|
42
|
+
return true;
|
|
43
|
+
if (/^rejects when (resource|payload) (already exists|is invalid)$/i.test(value))
|
|
44
|
+
return true;
|
|
45
|
+
if (/^returns [\w\s]+ list when query is valid$/i.test(value))
|
|
46
|
+
return true;
|
|
47
|
+
if (/^creates [\w\s]+ when payload is valid$/i.test(value))
|
|
48
|
+
return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
23
51
|
function isValidItCase(name) {
|
|
24
52
|
const value = name?.trim() ?? '';
|
|
25
|
-
if (value.length < 12 || value.length >
|
|
53
|
+
if (value.length < 12 || value.length > 120)
|
|
26
54
|
return false;
|
|
27
55
|
if (value.startsWith('/'))
|
|
28
56
|
return false;
|
|
29
|
-
if (/\[(GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT)\]/i.test(value))
|
|
57
|
+
if (/\[(GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT|INSERT|MERGE|REPLACE)\]/i.test(value))
|
|
30
58
|
return false;
|
|
31
59
|
if (/(POSITIVE CASES|SEMANTIC ERROR CASES|INVALID CASES|OMITTED)/i.test(value))
|
|
32
60
|
return false;
|
|
@@ -36,57 +64,117 @@ function isValidItCase(name) {
|
|
|
36
64
|
return false;
|
|
37
65
|
return true;
|
|
38
66
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
67
|
+
function stemVerb(raw) {
|
|
68
|
+
const v = raw.toLowerCase().replace(/s$/, '');
|
|
69
|
+
if (v === 'create')
|
|
70
|
+
return 'creates';
|
|
71
|
+
if (v === 'update')
|
|
72
|
+
return 'updates';
|
|
73
|
+
if (v === 'delete')
|
|
74
|
+
return 'deletes';
|
|
75
|
+
if (v === 'insert')
|
|
76
|
+
return 'inserts';
|
|
77
|
+
if (v === 'upsert')
|
|
78
|
+
return 'upserts';
|
|
79
|
+
if (v === 'merge')
|
|
80
|
+
return 'merges';
|
|
81
|
+
if (v === 'replace')
|
|
82
|
+
return 'replaces';
|
|
83
|
+
if (v === 'return')
|
|
84
|
+
return 'returns';
|
|
85
|
+
if (v === 'list')
|
|
86
|
+
return 'lists';
|
|
87
|
+
if (v === 'reject')
|
|
88
|
+
return 'rejects';
|
|
89
|
+
return `${v}s`;
|
|
90
|
+
}
|
|
91
|
+
function outcomeVerb(section, method) {
|
|
92
|
+
if (section === 'auth' || section === 'invalid' || section === 'omitted' || section === 'semantic')
|
|
93
|
+
return 'rejects';
|
|
94
|
+
const m = (method || 'get').toLowerCase();
|
|
95
|
+
if (m === 'post')
|
|
96
|
+
return 'creates';
|
|
97
|
+
if (m === 'upsert')
|
|
98
|
+
return 'upserts';
|
|
99
|
+
if (m === 'insert')
|
|
100
|
+
return 'inserts';
|
|
101
|
+
if (m === 'merge')
|
|
102
|
+
return 'merges';
|
|
103
|
+
if (m === 'replace')
|
|
104
|
+
return 'replaces';
|
|
105
|
+
if (m === 'delete')
|
|
106
|
+
return 'deletes';
|
|
107
|
+
if (m === 'put' || m === 'patch' || m === 'update')
|
|
108
|
+
return 'updates';
|
|
109
|
+
return 'returns';
|
|
110
|
+
}
|
|
111
|
+
function fitItName(value) {
|
|
112
|
+
let next = value.replace(/\s+/g, ' ').trim().replace(/[.,;:]+$/, '');
|
|
113
|
+
if (next.length > 120) {
|
|
114
|
+
next = next.slice(0, 117).replace(/\s+\S*$/, '').trim();
|
|
115
|
+
}
|
|
116
|
+
if (!isValidItCase(next) || isGenericItName(next))
|
|
117
|
+
return undefined;
|
|
118
|
+
return next;
|
|
43
119
|
}
|
|
44
120
|
/**
|
|
45
|
-
*
|
|
121
|
+
* Keep the unique clause from `should …` / existing it() text.
|
|
122
|
+
* Never collapse many cases into one generic sentence.
|
|
46
123
|
*/
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
124
|
+
function rewriteItFromOriginal(raw, section, method, pathTemplate) {
|
|
125
|
+
if (isDynamicItName(raw))
|
|
126
|
+
return undefined;
|
|
127
|
+
let s = raw.trim().replace(/\s+/g, ' ').replace(/[.,;:]+$/, '');
|
|
128
|
+
if (!s)
|
|
129
|
+
return undefined;
|
|
130
|
+
s = s.replace(/^should\s+/i, '');
|
|
131
|
+
const res = pathTemplate ? (0, test_title_1.resourceLabel)(pathTemplate).toLowerCase() : 'resource';
|
|
132
|
+
const outcome = outcomeVerb(section, method);
|
|
133
|
+
s = s
|
|
134
|
+
.replace(/^returns?\s+unauthorized\s+/i, 'rejects ')
|
|
135
|
+
.replace(/^returns?\s+conflict\s+/i, 'rejects ')
|
|
136
|
+
.replace(/^returns?\s+error\s+/i, 'rejects ')
|
|
137
|
+
.replace(/^returns?\s+bad request\s+/i, 'rejects ')
|
|
138
|
+
.replace(/^returns?\s+not found\s+/i, 'rejects ');
|
|
139
|
+
if (/^not\s+/i.test(s)) {
|
|
140
|
+
const beforeWhen = s.replace(/^not\s+/i, '').split(/\bwhen\b/i)[0].trim();
|
|
141
|
+
return fitItName(`${outcome} ${res} when not ${beforeWhen}`);
|
|
61
142
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return out;
|
|
143
|
+
const withMatch = s.match(/^(create|update|delete|insert|upsert|merge|replace)s?\s+(.+?)\s+with\s+(.+)$/i);
|
|
144
|
+
if (withMatch) {
|
|
145
|
+
return fitItName(`${stemVerb(withMatch[1])} ${withMatch[2]} when ${withMatch[3]}`);
|
|
66
146
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
add(`rejects when ${res} field is omitted`);
|
|
70
|
-
return out;
|
|
147
|
+
if (!/\bwhen\b/i.test(s)) {
|
|
148
|
+
s = s.replace(/\bwith\b/i, 'when');
|
|
71
149
|
}
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
150
|
+
if (CASE_START.test(s) && /\bwhen\b/i.test(s))
|
|
151
|
+
return fitItName(s);
|
|
152
|
+
const led = s.match(/^(create|update|delete|insert|upsert|merge|replace|return)s?\s+(.+)$/i);
|
|
153
|
+
if (led) {
|
|
154
|
+
const rest = led[2];
|
|
155
|
+
if (/\bwhen\b/i.test(rest))
|
|
156
|
+
return fitItName(`${stemVerb(led[1])} ${rest}`);
|
|
157
|
+
return fitItName(`${stemVerb(led[1])} ${rest.replace(/\bwith\b/i, 'when')}`);
|
|
76
158
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
159
|
+
if (/\bwhen\b/i.test(s)) {
|
|
160
|
+
if (/^when\s+/i.test(s))
|
|
161
|
+
return fitItName(`${outcome} ${s}`);
|
|
162
|
+
return fitItName(`${outcome} when ${s}`);
|
|
163
|
+
}
|
|
164
|
+
return fitItName(`${outcome} when ${s}`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Prefer a unique rewrite of the current it() name.
|
|
168
|
+
* Generic section templates are never auto-applied.
|
|
169
|
+
*/
|
|
170
|
+
function suggestItCases(section, method, pathTemplate, original) {
|
|
171
|
+
return suggestItCaseResult(section, method, pathTemplate, original).names;
|
|
172
|
+
}
|
|
173
|
+
function suggestItCaseResult(section, method, pathTemplate, original) {
|
|
174
|
+
if (original && isDynamicItName(original))
|
|
175
|
+
return { names: [], auto: false };
|
|
176
|
+
const fromOriginal = original ? rewriteItFromOriginal(original, section, method, pathTemplate) : undefined;
|
|
177
|
+
if (fromOriginal)
|
|
178
|
+
return { names: [fromOriginal], auto: true };
|
|
179
|
+
return { names: [], auto: false };
|
|
92
180
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HTTP_VERBS = void 0;
|
|
3
4
|
exports.isPathParam = isPathParam;
|
|
4
5
|
exports.titleCaseToken = titleCaseToken;
|
|
5
6
|
exports.isHumanOperationTitle = isHumanOperationTitle;
|
|
@@ -8,7 +9,9 @@ exports.formatTestTitle = formatTestTitle;
|
|
|
8
9
|
exports.resourceLabel = resourceLabel;
|
|
9
10
|
exports.suggestOperationTitleResult = suggestOperationTitleResult;
|
|
10
11
|
exports.suggestOperationTitles = suggestOperationTitles;
|
|
11
|
-
|
|
12
|
+
/** Verbs that appear in TEST_TITLE `[METHOD]` / `— METHOD path`. */
|
|
13
|
+
exports.HTTP_VERBS = 'GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT|INSERT|MERGE|REPLACE';
|
|
14
|
+
const METHODS = exports.HTTP_VERBS;
|
|
12
15
|
const PATH_ONLY_BRACKET_RE = new RegExp(`^(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
|
|
13
16
|
const TITLE_BRACKET_RE = new RegExp(`^(?<title>.+?)\\s+(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
|
|
14
17
|
/** `Create Mock Tbs — POST /v1/admin/mock-tbs` */
|
|
@@ -223,6 +226,22 @@ function parentParam(pathTemplate) {
|
|
|
223
226
|
}
|
|
224
227
|
return undefined;
|
|
225
228
|
}
|
|
229
|
+
function collectionAll(rest, leafAll) {
|
|
230
|
+
const last = rest[rest.length - 1];
|
|
231
|
+
const prev = rest[rest.length - 2];
|
|
232
|
+
if (prev && /^(items?|entries)$/i.test(last || '')) {
|
|
233
|
+
return `${titleCaseToken(prev)} ${titleCaseToken(last)}`;
|
|
234
|
+
}
|
|
235
|
+
return leafAll;
|
|
236
|
+
}
|
|
237
|
+
function collectionOne(rest, leafOne) {
|
|
238
|
+
const last = rest[rest.length - 1];
|
|
239
|
+
const prev = rest[rest.length - 2];
|
|
240
|
+
if (prev && /^(items?|entries)$/i.test(last || '')) {
|
|
241
|
+
return `${titleCaseToken(prev)} ${titleCaseToken(singularStem(last))}`;
|
|
242
|
+
}
|
|
243
|
+
return leafOne;
|
|
244
|
+
}
|
|
226
245
|
/**
|
|
227
246
|
* POST /v1/admin/mock-tbs → Create Mock Tbs
|
|
228
247
|
* GET /v1/me/branches → Find All Branches
|
|
@@ -235,8 +254,8 @@ function suggestOperationTitleResult(method, pathTemplate) {
|
|
|
235
254
|
const rest = operationSegments(pathTemplate);
|
|
236
255
|
const last = lastSegment(pathTemplate);
|
|
237
256
|
const prev = rest.length >= 2 ? rest[rest.length - 2] : undefined;
|
|
238
|
-
const leafAll = last ? titleCaseToken(last) : resourceLabel(pathTemplate);
|
|
239
|
-
const leafOne = last ? titleCaseToken(singularStem(last)) : leafAll;
|
|
257
|
+
const leafAll = collectionAll(rest, last ? titleCaseToken(last) : resourceLabel(pathTemplate));
|
|
258
|
+
const leafOne = collectionOne(rest, last ? titleCaseToken(singularStem(last)) : leafAll);
|
|
240
259
|
const m = method.toLowerCase();
|
|
241
260
|
const endParam = trailingParam(pathTemplate);
|
|
242
261
|
const nested = parentParam(pathTemplate);
|
|
@@ -311,6 +330,14 @@ function suggestOperationTitleResult(method, pathTemplate) {
|
|
|
311
330
|
add(`Find All ${leafAll}`);
|
|
312
331
|
else if (m === 'post')
|
|
313
332
|
add(`Create ${leafOne}`);
|
|
333
|
+
else if (m === 'upsert')
|
|
334
|
+
add(`Upsert ${leafAll}`);
|
|
335
|
+
else if (m === 'insert')
|
|
336
|
+
add(`Insert ${leafOne}`);
|
|
337
|
+
else if (m === 'merge')
|
|
338
|
+
add(`Merge ${leafAll}`);
|
|
339
|
+
else if (m === 'replace')
|
|
340
|
+
add(`Replace ${leafOne}`);
|
|
314
341
|
else if (m === 'delete' && endParam)
|
|
315
342
|
add(`Delete One ${leafOne} ${byEnd}`);
|
|
316
343
|
else if (m === 'delete')
|
|
@@ -320,7 +347,7 @@ function suggestOperationTitleResult(method, pathTemplate) {
|
|
|
320
347
|
else if (m === 'put' || m === 'patch' || m === 'update')
|
|
321
348
|
add(`Update ${leafAll}`);
|
|
322
349
|
else
|
|
323
|
-
|
|
350
|
+
add(`${titleCaseToken(m)} ${leafAll}`);
|
|
324
351
|
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
325
352
|
}
|
|
326
353
|
function suggestOperationTitles(method, pathTemplate) {
|
package/dist/cli/titles.js
CHANGED
|
@@ -56,6 +56,8 @@ function writeTitle(cwd, finding) {
|
|
|
56
56
|
return (0, scan_1.applyTitle)(cwd, finding, name);
|
|
57
57
|
}
|
|
58
58
|
function writeIt(cwd, finding) {
|
|
59
|
+
if (!finding.auto)
|
|
60
|
+
return false;
|
|
59
61
|
const name = finding.suggestions[0];
|
|
60
62
|
if (!name || !(0, it_case_1.isValidItCase)(name))
|
|
61
63
|
return false;
|
|
@@ -79,6 +81,10 @@ function applyAllRecommended(cwd, titles, cases, fromTitleIndex, fromCaseIndex)
|
|
|
79
81
|
}
|
|
80
82
|
const caseStart = fromTitleIndex < titles.length ? 0 : fromCaseIndex;
|
|
81
83
|
for (let i = caseStart; i < cases.length; i += 1) {
|
|
84
|
+
if (!cases[i].auto || !cases[i].suggestions[0]) {
|
|
85
|
+
skipped += 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
82
88
|
if (writeIt(cwd, cases[i])) {
|
|
83
89
|
console.log(` ${ui_1.c.mint('✔')} ${cases[i].suggestions[0]} ${ui_1.c.dim(cases[i].file + ':' + cases[i].line)}`);
|
|
84
90
|
written += 1;
|
|
@@ -124,7 +130,7 @@ async function runTitleCheck(options) {
|
|
|
124
130
|
}
|
|
125
131
|
(0, ui_1.banner)('Test naming', 'runs before Jest — docs / Postman labels');
|
|
126
132
|
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs — POST /v1/admin/mock-tbs`);
|
|
127
|
-
console.log(` ${ui_1.c.dim('it()')}
|
|
133
|
+
console.log(` ${ui_1.c.dim('it()')} unique per case — from should …, not one shared template`);
|
|
128
134
|
console.log(` ${ui_1.c.gold(String(total))} to review — ${ui_1.c.ice('y')} one recommended, ${ui_1.c.ice('a')} all remaining, ${ui_1.c.ice('s')} skip.`);
|
|
129
135
|
let written = 0;
|
|
130
136
|
let skipped = 0;
|
package/dist/path.util.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.pathParamNames = pathParamNames;
|
|
|
10
10
|
exports.extractPathParams = extractPathParams;
|
|
11
11
|
exports.materializePath = materializePath;
|
|
12
12
|
const config_1 = require("./config");
|
|
13
|
+
const test_title_1 = require("./catalog/test-title");
|
|
13
14
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
14
15
|
const NUMERIC_ID_RE = /^-?\d+(\.\d+)?$/;
|
|
15
16
|
const TOKENISH_RE = /^[A-Za-z0-9_-]{16,}$/;
|
|
@@ -51,7 +52,7 @@ function toOpenApiTemplate(path) {
|
|
|
51
52
|
function templateFromTestName(test) {
|
|
52
53
|
if (!test)
|
|
53
54
|
return null;
|
|
54
|
-
const match = test.match(
|
|
55
|
+
const match = test.match(new RegExp(`^/?(\\S+)\\s+\\[(?:${test_title_1.HTTP_VERBS})\\]`, 'i'));
|
|
55
56
|
if (!match)
|
|
56
57
|
return null;
|
|
57
58
|
const raw = `/${match[1].replace(/^\/+/, '')}`.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, ':$1').replace(/\/+$/, '') || '/';
|
package/dist/titles/scan.d.ts
CHANGED
package/dist/titles/scan.js
CHANGED
|
@@ -215,9 +215,14 @@ function scanFileCases(rel, text) {
|
|
|
215
215
|
const section = [...describes].reverse().find((entry) => entry.index < index && entry.section)?.section;
|
|
216
216
|
if (!section)
|
|
217
217
|
continue;
|
|
218
|
-
if ((0, it_case_1.
|
|
218
|
+
if ((0, it_case_1.isDynamicItName)(body))
|
|
219
219
|
continue;
|
|
220
220
|
const label = [...labels].reverse().find((entry) => entry.index < index);
|
|
221
|
+
const suggestion = (0, it_case_1.suggestItCaseResult)(section, label?.method, label?.path, body);
|
|
222
|
+
if (!suggestion.names.length)
|
|
223
|
+
continue;
|
|
224
|
+
if (suggestion.auto && suggestion.names[0] === body.replace(/\s+/g, ' ').trim().replace(/[.,;:]+$/, ''))
|
|
225
|
+
continue;
|
|
221
226
|
const { line, column } = indexToLineCol(text, index);
|
|
222
227
|
findings.push({
|
|
223
228
|
file: rel,
|
|
@@ -228,7 +233,8 @@ function scanFileCases(rel, text) {
|
|
|
228
233
|
section,
|
|
229
234
|
path: label?.path,
|
|
230
235
|
method: label?.method,
|
|
231
|
-
suggestions:
|
|
236
|
+
suggestions: suggestion.names,
|
|
237
|
+
auto: suggestion.auto,
|
|
232
238
|
});
|
|
233
239
|
}
|
|
234
240
|
return findings;
|
|
@@ -277,8 +283,8 @@ function printNamingFindings(report, paint) {
|
|
|
277
283
|
// spacer already from titles
|
|
278
284
|
}
|
|
279
285
|
console.log('');
|
|
280
|
-
console.log(` ${paint.yellow('!')} ${paint.bold(`${report.cases.length} it() case(s)
|
|
281
|
-
console.log(` ${paint.dim('
|
|
286
|
+
console.log(` ${paint.yellow('!')} ${paint.bold(`${report.cases.length} it() case(s) can keep unique wording`)} ${paint.dim('should … → outcome when …')}`);
|
|
287
|
+
console.log(` ${paint.dim('Never collapse')} ${paint.cyan('nace codes / TRNC / not-found')} ${paint.dim('into one shared line')}`);
|
|
282
288
|
for (const item of report.cases) {
|
|
283
289
|
console.log('');
|
|
284
290
|
console.log(` ${paint.cyan(item.file)}${paint.dim(`:${item.line}:${item.column}`)}`);
|