Skip to content

Commit 8ed1357

Browse files
committed
updates for robustness
1 parent 29d08a7 commit 8ed1357

9 files changed

Lines changed: 34 additions & 12 deletions

File tree

apps/api/src/tests/fromschema/v1-fromschema.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ test.describe('POST /v1/generate/fromschema', () => {
3131
expect(response.status()).toBe(400);
3232
const body = await response.json();
3333
expect(Array.isArray(body.errors)).toBe(true);
34+
expect(body.diagnostics).not.toBeNull();
35+
expect(Array.isArray(body.diagnostics)).toBe(false);
3436
expect(typeof body.diagnostics).toBe('object');
3537
});
3638
});

apps/api/src/tests/generate/v1-generate-amend.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ test.describe('POST /v1/generate/amend', () => {
2424
expect(response.status()).toBe(200);
2525
const body = await response.json();
2626
expect(body.rows).toEqual([['Bob'], ['Eve']]);
27+
expect(body.diagnostics).not.toBeNull();
28+
expect(Array.isArray(body.diagnostics)).toBe(false);
2729
expect(typeof body.diagnostics).toBe('object');
2830
});
2931

@@ -35,6 +37,8 @@ test.describe('POST /v1/generate/amend', () => {
3537
expect(response.status()).toBe(400);
3638
const body = await response.json();
3739
expect(Array.isArray(body.errors)).toBe(true);
40+
expect(body.diagnostics).not.toBeNull();
41+
expect(Array.isArray(body.diagnostics)).toBe(false);
3842
expect(typeof body.diagnostics).toBe('object');
3943
});
4044
});

apps/api/src/tests/generate/v1-generate.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ test.describe('POST /v1/generate', () => {
3030
expect(response.status()).toBe(400);
3131
const body = await response.json();
3232
expect(Array.isArray(body.errors)).toBe(true);
33+
expect(body.diagnostics).not.toBeNull();
34+
expect(Array.isArray(body.diagnostics)).toBe(false);
3335
expect(typeof body.diagnostics).toBe('object');
3436
});
3537
});

apps/api/src/tests/options/options-endpoints.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ test.describe('/v1/generate/options endpoints', () => {
3434
expect(response.status()).toBe(400);
3535
const body = await response.json();
3636
expect(Array.isArray(body.errors)).toBe(true);
37+
expect(body.diagnostics).not.toBeNull();
3738
expect(typeof body.diagnostics).toBe('object');
39+
expect(Array.isArray(body.diagnostics)).toBe(false);
3840
});
3941
});

apps/web/generator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<li>Use + and - to add or remove rows and arrows to reorder.</li>
4747
<li>Use Preview to generate a sample set into the table.</li>
4848
<li>Use Generate Data to download file output in the selected format.</li>
49-
<li>If your schema contains at least two enums then your can Generate Pairwise combinations.</li>
49+
<li>If your schema contains at least two enums then you can Generate Pairwise combinations.</li>
5050
<li>Click between "Edit as Text" and "Edit as Schema" to use the edit view that works best for you.</li>
5151
<li>Preview and Generate row counts are independent.</li>
5252
</ul>

packages/core-ui/js/gui_components/options_panels/options-test-framework-panel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class TestFrameworkOptionsPanel {
225225
);
226226
this.htmlData.setCheckBoxFrom("input[name='include-setup']", options.includeSetup, true);
227227
this.htmlData.setCheckBoxFrom("input[name='pretty-print']", options.prettyPrint, true);
228+
this.refreshHelpTipsForSelectedFramework();
228229
}
229230
}
230231

packages/core-ui/src/tests/utils/options-help-parity.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('option panel help parity with core tips', () => {
6060
];
6161

6262
for (const panel of panels) {
63+
host.innerHTML = '';
6364
panel.addToGui();
6465
const helpIcons = Array.from(host.querySelectorAll('.option-help-icon'));
6566
expect(helpIcons.length).toBeGreaterThan(0);

packages/core/js/options/format-option-catalog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ function getTipsForFormat(format, { customTips } = {}) {
392392
const tips = {};
393393
for (const key of keys) {
394394
tips[key] =
395-
runtimeCustomTips[key] ||
396-
configuredTips[key] ||
397-
COMMON_OPTION_TIPS_BY_KEY[key] ||
395+
runtimeCustomTips[key] ??
396+
configuredTips[key] ??
397+
COMMON_OPTION_TIPS_BY_KEY[key] ??
398398
`Configure ${key.replace(/([A-Z])/g, ' $1').toLowerCase()}.`;
399399
}
400400
return tips;

tests/integration/cross-surface-option-parity.test.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ import {
88
sanitizeUiOptionsForFormat,
99
} from '../../packages/core-ui/js/gui_components/options-catalog-adapter.js';
1010

11-
function firstJsonLine(output) {
11+
function jsonRpcMessages(output) {
1212
return output
1313
.split(/\r?\n/)
1414
.map((line) => line.trim())
15-
.find((line) => line.startsWith('{'));
15+
.filter((line) => line.startsWith('{'))
16+
.map((line) => {
17+
try {
18+
return JSON.parse(line);
19+
} catch {
20+
return null;
21+
}
22+
})
23+
.filter(Boolean);
1624
}
1725

1826
function requestMcpServer(payload) {
@@ -23,10 +31,13 @@ function requestMcpServer(payload) {
2331
input: request,
2432
encoding: 'utf8',
2533
cwd: repoRoot,
34+
timeout: 15000,
2635
});
27-
const line = firstJsonLine(output);
28-
expect(line).toBeTruthy();
29-
return JSON.parse(line);
36+
const messages = jsonRpcMessages(output);
37+
expect(messages.length).toBeGreaterThan(0);
38+
const response = messages.find((message) => message?.id === payload.id);
39+
expect(response).toBeTruthy();
40+
return response;
3041
}
3142

3243
describe('cross-surface option parity (API vs MCP vs CLI helper)', () => {
@@ -56,9 +67,8 @@ describe('cross-surface option parity (API vs MCP vs CLI helper)', () => {
5667
expect(mcpPayload.ok).toBe(true);
5768
const props = mcpPayload?.formatSchema?.optionSchema?.properties || {};
5869
for (const [key, tip] of Object.entries(tips)) {
59-
if (props[key]) {
60-
expect(props[key].description).toBe(tip);
61-
}
70+
expect(Object.hasOwn(props, key)).toBe(true);
71+
expect(props[key].description).toBe(tip);
6272
}
6373

6474
const normalized = normalizeAndValidateFormat(format.toUpperCase());

0 commit comments

Comments
 (0)