feat(review): View prompt + Call 2 declared attrs, Create-desc gate
Shared assemble_call2 for GET .../call2/prompt and POST call2 (seed + DECLARED ATTRIBUTES + dimension fact + brand/geo; photo slots without base64). Create desc disabled until content LLM + title/short + species + wood cats/primary + edge + ≥1 figure + grade + moisture + price; show missing. figure_term_ids required for ready. Moisture defaults to Kiln dried (kd). Pin snl / liveedge in wood-cat UI. Ready-on-change via MultiSelect onCommit.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import {
|
||||
canCreateDesc,
|
||||
missingCreateDesc,
|
||||
missingCreateDescLabels,
|
||||
} from './createDescGate';
|
||||
|
||||
const full = {
|
||||
contentLlmEnabled: true,
|
||||
title: 'Figured Walnut Live Edge Slab',
|
||||
shortDescription: 'Figured Walnut Live Edge Slab, 9ft …',
|
||||
speciesId: 11,
|
||||
woodCategoryIds: [21],
|
||||
primaryCatId: 21,
|
||||
edgeTermId: '321',
|
||||
figureTermIds: [328],
|
||||
gradeTermId: 342,
|
||||
moistureTermId: '326',
|
||||
price: '184.00',
|
||||
};
|
||||
|
||||
test('Create desc gate: full set passes; does not require description', () => {
|
||||
assert.equal(canCreateDesc(full), true);
|
||||
assert.deepEqual(missingCreateDesc(full), []);
|
||||
});
|
||||
|
||||
test('Create desc gate: lists each missing field; no description key', () => {
|
||||
const miss = missingCreateDesc({
|
||||
...full,
|
||||
contentLlmEnabled: false,
|
||||
title: '',
|
||||
shortDescription: ' ',
|
||||
speciesId: null,
|
||||
woodCategoryIds: [],
|
||||
primaryCatId: '',
|
||||
edgeTermId: '',
|
||||
figureTermIds: [],
|
||||
gradeTermId: '',
|
||||
moistureTermId: '',
|
||||
price: '',
|
||||
});
|
||||
assert.deepEqual(miss, [
|
||||
'content_llm',
|
||||
'title',
|
||||
'short_description',
|
||||
'species',
|
||||
'wood_categories',
|
||||
'primary',
|
||||
'edge',
|
||||
'figure',
|
||||
'grade',
|
||||
'moisture',
|
||||
'price',
|
||||
]);
|
||||
assert.equal(miss.includes('description'), false);
|
||||
const labels = missingCreateDescLabels({
|
||||
...full,
|
||||
figureTermIds: [],
|
||||
price: '',
|
||||
});
|
||||
assert.ok(labels.includes('≥1 figure'));
|
||||
assert.ok(labels.includes('price'));
|
||||
});
|
||||
|
||||
test('Create desc gate: recomputes on field change (reactive-ready)', () => {
|
||||
assert.equal(canCreateDesc({ ...full, figureTermIds: [] }), false);
|
||||
assert.equal(canCreateDesc({ ...full, figureTermIds: [1] }), true);
|
||||
assert.equal(canCreateDesc({ ...full, moistureTermId: '' }), false);
|
||||
assert.equal(canCreateDesc({ ...full, moistureTermId: 326 }), true);
|
||||
});
|
||||
Reference in New Issue
Block a user