@t0.labs/daxta 1.1.6 → 1.1.7

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.
@@ -10,7 +10,9 @@ export declare function isValidItCase(name?: string): boolean;
10
10
  export declare function rewriteItFromOriginal(raw: string, section?: CaseSection, method?: string, pathTemplate?: string): string | undefined;
11
11
  /**
12
12
  * Docs / Postman example line: the unique condition only.
13
- * Test keeps `creates mock tbs when cyprus payload shape` → docs `cyprus payload shape`.
13
+ * Ideal: `creates mock tbs when cyprus payload shape` → `cyprus payload shape`.
14
+ * Parametric: `should set TR companyName when value mode is sent` →
15
+ * `TR companyName when value mode is sent` (keep pre-when context so labels stay unique).
14
16
  */
15
17
  export declare function docsScenarioClause(raw?: string): string;
16
18
  export type ItSuggestion = {
@@ -175,9 +175,26 @@ function rewriteItFromOriginal(raw, section, method, pathTemplate) {
175
175
  return fitItName(`${outcome} when ${s}`);
176
176
  }
177
177
  const OUTCOME_PREFIX = /^(returns|creates|updates|upserts|inserts|merges|replaces|deletes|lists|rejects|conflicts)\s+/i;
178
+ /** Leading action verbs that are filler once the subject (field / country) is kept. */
179
+ const LEADING_ACTION = /^(set|store|keep|send|put|patch|clear|omit|include|provide|use|apply|replace|update)\s+/i;
180
+ /**
181
+ * Ideal `creates resource when …` leftovers are a short noun phrase (the resource).
182
+ * Field / mode context before `when` is distinguishing and must be kept.
183
+ */
184
+ function isResourceOnlyBefore(before) {
185
+ if (!before)
186
+ return true;
187
+ if (/[.=_]/.test(before))
188
+ return false;
189
+ if (/\b(null|empty|value|mode|as|undefined|missing)\b/i.test(before))
190
+ return false;
191
+ return before.split(/\s+/).length <= 3;
192
+ }
178
193
  /**
179
194
  * Docs / Postman example line: the unique condition only.
180
- * Test keeps `creates mock tbs when cyprus payload shape` → docs `cyprus payload shape`.
195
+ * Ideal: `creates mock tbs when cyprus payload shape` → `cyprus payload shape`.
196
+ * Parametric: `should set TR companyName when value mode is sent` →
197
+ * `TR companyName when value mode is sent` (keep pre-when context so labels stay unique).
181
198
  */
182
199
  function docsScenarioClause(raw) {
183
200
  if (!raw)
@@ -186,10 +203,24 @@ function docsScenarioClause(raw) {
186
203
  const field = s.match(/^([A-Za-z0-9_.]+)\s+-\s+(should not be\s+.+)$/i);
187
204
  if (field)
188
205
  return `${field[1]} ${field[2]}`.trim();
189
- const when = s.match(/\bwhen\s+(.+)$/i);
190
- if (when?.[1])
191
- return when[1].trim();
192
- s = s.replace(OUTCOME_PREFIX, '').replace(/^resource\s+/i, '').trim();
206
+ const whenMatch = s.match(/^(.*?)\bwhen\s+(.+)$/i);
207
+ if (whenMatch) {
208
+ let before = whenMatch[1].trim().replace(/^should\s+/i, '');
209
+ const after = whenMatch[2].trim();
210
+ if (!after)
211
+ return before || 'example';
212
+ const hadOutcome = OUTCOME_PREFIX.test(before);
213
+ before = before
214
+ .replace(OUTCOME_PREFIX, '')
215
+ .replace(/^resource\s+/i, '')
216
+ .replace(/^error\s+/i, '')
217
+ .trim();
218
+ if (!before || (hadOutcome && isResourceOnlyBefore(before)))
219
+ return after;
220
+ before = before.replace(LEADING_ACTION, '').trim();
221
+ return before ? `${before} when ${after}` : after;
222
+ }
223
+ s = s.replace(/^should\s+/i, '').replace(OUTCOME_PREFIX, '').replace(/^resource\s+/i, '').trim();
193
224
  return s || 'example';
194
225
  }
195
226
  /**
@@ -134,7 +134,7 @@ async function runTitleCheck(options) {
134
134
  console.log(` ${ui_1.c.dim('describe')} Create Mock Tbs — POST /v1/admin/mock-tbs`);
135
135
  console.log(` ${ui_1.c.dim('→ operation title in sidebar')}`);
136
136
  console.log(` ${ui_1.c.dim('it()')} creates mock tbs when cyprus payload shape`);
137
- console.log(` ${ui_1.c.dim('→ scenario clause (text after')} ${ui_1.c.ice('when')}${ui_1.c.dim(')')}`);
137
+ console.log(` ${ui_1.c.dim('→ scenario clause (when-clause; keeps pre-when field context when needed)')}`);
138
138
  console.log(` ${ui_1.c.dim('label')} 201 — Create Mock Tbs — cyprus payload shape`);
139
139
  console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('exampleLabelStyle')} ${ui_1.c.dim('in')} ${ui_1.c.ice('daxta tree')} ${ui_1.c.dim('· change with')} ${ui_1.c.ice('2')} ${ui_1.c.dim('for short labels')}`);
140
140
  const start = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Review test names now?\n` +
package/dist/cli/tree.js CHANGED
@@ -119,9 +119,12 @@ async function pickExampleStyle(current) {
119
119
  console.log('');
120
120
  console.log(` ${ui_1.c.bold('Example / scenario labels')}`);
121
121
  console.log(` ${ui_1.c.dim('Sidebar + OpenAPI export name for each test hit.')}`);
122
- console.log(` ${ui_1.c.dim('From')} ${ui_1.c.ice('it()')} ${ui_1.c.dim('— text after')} ${ui_1.c.ice('when')} ${ui_1.c.dim('becomes the scenario clause.')}`);
122
+ console.log(` ${ui_1.c.dim('From')} ${ui_1.c.ice('it()')} ${ui_1.c.dim('— unique scenario clause (when-clause, keeping pre-when field context when needed).')}`);
123
123
  console.log('');
124
124
  console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.ice('creates mock tbs when cyprus payload shape')}`);
125
+ console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('cyprus payload shape')}`);
126
+ console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.ice('should set TR companyName when value mode is sent')}`);
127
+ console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('TR companyName when value mode is sent')}`);
125
128
  console.log('');
126
129
  console.log(` ${ui_1.c.ice('1')} status-title-case ${ui_1.c.dim('(default)')}`);
127
130
  console.log(` ${ui_1.c.dim('201 — Create Mock Tbs — cyprus payload shape')}`);
package/dist/config.d.ts CHANGED
@@ -54,7 +54,7 @@ export type DaxtaConfig = {
54
54
  * - status-case → `201 — cyprus payload shape`
55
55
  * - status-title-case → `201 — Create Mock Tbs — cyprus payload shape`
56
56
  * - full → includes path + POSITIVE CASES + clause
57
- * Test it() stays `creates mock tbs when cyprus payload shape`; API docs take the `when` clause.
57
+ * Ideal it(): docs take the when-clause. Parametric it(): pre-when field context is kept.
58
58
  */
59
59
  exampleLabelStyle?: ExampleLabelStyle;
60
60
  port?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "DAxTA — Tested behavior. Trusted API docs. Generate API documentation from observed test execution.",
5
5
  "license": "MIT",
6
6
  "author": {