@t0.labs/daxta 0.4.15 → 0.4.16
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/README.md +1 -1
- package/assets/viewer.html +15 -14
- package/dist/cli/install.js +4 -1
- package/dist/cli/main.js +1 -0
- package/dist/cli/test.js +1 -1
- package/dist/cli/titles.js +1 -2
- package/dist/jest/global-setup.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ Format: `{Title} {path} [{METHOD}] (integration)`
|
|
|
181
181
|
- Skip the title and docs fall back to the path.
|
|
182
182
|
- `it()` example names: `{outcome} when {condition}` — e.g. `creates mock tbs when payload is valid`. No path, no `[POST]`, no status (status comes from the recorded hit).
|
|
183
183
|
- `daxta titles` lists file:line for both rules; pick a suggestion, type custom, or skip.
|
|
184
|
-
- **Before tests:**
|
|
184
|
+
- **Before tests:** `daxta install` and `daxta test` ask in the terminal (TTY). `pnpm test:integration` also asks via Jest `globalSetup` when stdin is a TTY. CI only prints. `--yes` / `CI=1` skip the questions.
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
187
|
daxta titles # interactive
|
package/assets/viewer.html
CHANGED
|
@@ -2511,23 +2511,24 @@
|
|
|
2511
2511
|
};
|
|
2512
2512
|
|
|
2513
2513
|
/**
|
|
2514
|
-
*
|
|
2515
|
-
*
|
|
2516
|
-
*
|
|
2514
|
+
* Active Try-it header group wins: switching the group at the top overwrites
|
|
2515
|
+
* the example request headers (Send + cURL + Headers panel).
|
|
2516
|
+
* If the group is empty, fall back to what was recorded.
|
|
2517
2517
|
*/
|
|
2518
2518
|
const requestHeadersForScenario = (scenario) => {
|
|
2519
|
-
const recorded = { ...(scenario.headers || {}) };
|
|
2520
2519
|
const vars = varMap();
|
|
2521
2520
|
const envHeaders = resolvedHeaders();
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2521
|
+
if (Object.keys(envHeaders).length) {
|
|
2522
|
+
const out = {};
|
|
2523
|
+
for (const [name, value] of Object.entries(envHeaders)) {
|
|
2524
|
+
out[name] = String(interpolate(value, vars));
|
|
2525
|
+
}
|
|
2526
|
+
return out;
|
|
2525
2527
|
}
|
|
2528
|
+
const recorded = { ...(scenario.headers || {}) };
|
|
2526
2529
|
const out = {};
|
|
2527
2530
|
for (const [name, value] of Object.entries(recorded)) {
|
|
2528
|
-
|
|
2529
|
-
const raw = fromEnv != null && String(fromEnv).trim() !== "" ? fromEnv : value;
|
|
2530
|
-
out[name] = String(interpolate(raw, vars));
|
|
2531
|
+
out[name] = String(interpolate(value, vars));
|
|
2531
2532
|
}
|
|
2532
2533
|
return out;
|
|
2533
2534
|
};
|
|
@@ -2921,7 +2922,7 @@
|
|
|
2921
2922
|
const scenario = item.scenarios[scenarioIndex] || { status: 0, pathParams: {}, query: {}, headers: {}, name: "" };
|
|
2922
2923
|
const fields = item.docs.fields || [];
|
|
2923
2924
|
ensureRequiredHeaderGroup(item.op);
|
|
2924
|
-
const
|
|
2925
|
+
const displayHeaders = requestHeadersForScenario(scenario);
|
|
2925
2926
|
const recordedOk = scenario.status >= 200 && scenario.status < 300;
|
|
2926
2927
|
const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
|
|
2927
2928
|
const emptyResponse = scenario.resBody === undefined || scenario.status === 204;
|
|
@@ -2934,9 +2935,9 @@
|
|
|
2934
2935
|
const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
|
|
2935
2936
|
const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
|
|
2936
2937
|
const responseTitle = showingLive ? "Live response" : "Recorded response";
|
|
2937
|
-
const headersHtml = Object.keys(
|
|
2938
|
-
? Object.entries(
|
|
2939
|
-
: `<div class="meta-empty">No headers
|
|
2938
|
+
const headersHtml = Object.keys(displayHeaders).length
|
|
2939
|
+
? Object.entries(displayHeaders).map(([name, value]) => kv(name, value)).join("")
|
|
2940
|
+
: `<div class="meta-empty">No headers in this header group</div>`;
|
|
2940
2941
|
const pathParamsHtml = Object.entries(scenario.pathParams || {})
|
|
2941
2942
|
.map(([name, value]) => kv(name, value))
|
|
2942
2943
|
.join("");
|
package/dist/cli/install.js
CHANGED
|
@@ -41,6 +41,7 @@ const inject_main_1 = require("./inject-main");
|
|
|
41
41
|
const discover_test_1 = require("./discover-test");
|
|
42
42
|
const jest_hooks_1 = require("./jest-hooks");
|
|
43
43
|
const tree_1 = require("./tree");
|
|
44
|
+
const titles_1 = require("./titles");
|
|
44
45
|
const ui_1 = require("./ui");
|
|
45
46
|
function readJson(filePath) {
|
|
46
47
|
return JSON.parse((0, fs_1.readFileSync)(filePath, 'utf8'));
|
|
@@ -331,11 +332,13 @@ async function installDaxta(options = {}) {
|
|
|
331
332
|
}
|
|
332
333
|
if (!dryRun) {
|
|
333
334
|
await (0, tree_1.runTreeWizard)({ embedded: true, yes: Boolean(options.yes) });
|
|
335
|
+
await (0, titles_1.runTitleCheck)({ cwd, yes: Boolean(options.yes) });
|
|
334
336
|
}
|
|
335
337
|
(0, ui_1.box)('Done', [
|
|
336
338
|
`${ui_1.c.green('✔')} DAxTA wired for ${ui_1.c.bold(project)}`,
|
|
337
339
|
`${ui_1.c.dim('env')} ${ui_1.c.cyan('DAXTA_DOCS=true')} written (set ${ui_1.c.cyan('false')} to disable /docs)`,
|
|
338
|
-
`${ui_1.c.dim('tests')} run your usual script — Docs ready
|
|
340
|
+
`${ui_1.c.dim('tests')} run your usual script — naming prompts run first, Docs ready at the end`,
|
|
341
|
+
`${ui_1.c.dim('names')} ${ui_1.c.cyan('daxta titles')} to re-label TEST_TITLE / it() cases`,
|
|
339
342
|
`${ui_1.c.dim('sidebar')} ${ui_1.c.cyan('daxta tree')} anytime to re-arrange folders`,
|
|
340
343
|
]);
|
|
341
344
|
const wired = testScript && pkg.scripts?.[testScript] ? testScript : null;
|
package/dist/cli/main.js
CHANGED
|
@@ -87,6 +87,7 @@ async function main() {
|
|
|
87
87
|
(0, migrate_1.reportMigration)({ ...migration, skipped: false });
|
|
88
88
|
}
|
|
89
89
|
await (0, tree_1.runTreeWizard)({ embedded: true, yes: Boolean(flags.yes) });
|
|
90
|
+
await (0, titles_1.runTitleCheck)({ yes: Boolean(flags.yes) });
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
if (command === 'uninstall' || command === 'remove') {
|
package/dist/cli/test.js
CHANGED
|
@@ -95,7 +95,7 @@ async function runDaxtaTest(options = {}) {
|
|
|
95
95
|
process.exitCode = 1;
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const titleExit = await (0, titles_1.runTitleCheck)({ cwd,
|
|
98
|
+
const titleExit = await (0, titles_1.runTitleCheck)({ cwd, yes, strict });
|
|
99
99
|
if (titleExit !== 0) {
|
|
100
100
|
process.exitCode = titleExit;
|
|
101
101
|
return;
|
package/dist/cli/titles.js
CHANGED
|
@@ -26,8 +26,7 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
26
26
|
const mark = index === 0 ? ui_1.c.dim(' (recommended)') : '';
|
|
27
27
|
console.log(` ${ui_1.c.cyan(String(index + 1))} ${name}${mark}`);
|
|
28
28
|
});
|
|
29
|
-
console.log(` ${ui_1.c.cyan('s')}
|
|
30
|
-
console.log(` ${ui_1.c.cyan('c')} custom`);
|
|
29
|
+
console.log(` ${ui_1.c.cyan('1–3')} pick suggestion ${ui_1.c.cyan('s')} skip ${ui_1.c.cyan('c')} type your own`);
|
|
31
30
|
const answer = await prompt(` ${ui_1.c.cyan('›')} `);
|
|
32
31
|
if (!answer || answer.toLowerCase() === 's')
|
|
33
32
|
return 'skip';
|
|
@@ -2,15 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = daxtaGlobalSetup;
|
|
4
4
|
const recorder_1 = require("../recorder");
|
|
5
|
+
const titles_1 = require("../cli/titles");
|
|
5
6
|
const scan_1 = require("../titles/scan");
|
|
6
7
|
const ui_1 = require("../cli/ui");
|
|
7
8
|
async function daxtaGlobalSetup() {
|
|
8
9
|
(0, recorder_1.clearWorkerHits)();
|
|
9
10
|
try {
|
|
11
|
+
if (process.env.DAXTA_TITLE_CHECK === 'off')
|
|
12
|
+
return;
|
|
10
13
|
const strict = process.env.DAXTA_TITLE_CHECK === 'strict';
|
|
11
|
-
const
|
|
12
|
-
|
|
14
|
+
const ci = Boolean(process.env.CI);
|
|
15
|
+
const canAsk = Boolean(process.stdin.isTTY) && !ci && process.env.DAXTA_TITLE_CHECK !== 'warn';
|
|
16
|
+
if (canAsk) {
|
|
17
|
+
const code = await (0, titles_1.runTitleCheck)({ strict });
|
|
18
|
+
if (strict && code) {
|
|
19
|
+
throw new Error('DAxTA: test naming off format. Fix with the prompts or `daxta titles`.');
|
|
20
|
+
}
|
|
13
21
|
return;
|
|
22
|
+
}
|
|
14
23
|
const report = (0, scan_1.scanTestNaming)(process.cwd());
|
|
15
24
|
if (!report.titles.length && !report.cases.length)
|
|
16
25
|
return;
|