Add ifStuck/stop to frames and captured date to sequences (Refs #23)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,9 @@ test('sequence validation: layout, image, text, secret, id, title', () => {
|
||||
bad((x) => { x.frames[0].image = 5; }, /image must be a string/);
|
||||
bad((x) => { x.frames[0].text = null; }, /text must be a string/);
|
||||
bad((x) => { x.frames[0].secret = 'yes'; }, /secret must be a boolean/);
|
||||
bad((x) => { x.frames[0].ifStuck = 5; }, /ifStuck must be a string/);
|
||||
bad((x) => { x.frames[0].stop = 'yes'; }, /stop must be a boolean/);
|
||||
bad((x) => { x.captured = 'yesterday'; }, /captured must be YYYY-MM-DD/);
|
||||
bad((x) => { x.title = ''; }, /missing title/);
|
||||
bad((x) => { x.id = d.sections[0].records[0].id; }, /duplicate id/);
|
||||
bad((x) => { delete x.frames; }, /frames must be an array/);
|
||||
@@ -116,8 +119,11 @@ test('frameLayout hides empty text; frameView withholds secret frames only when
|
||||
assert.equal(frameLayout({ layout: 'right', text: 'x' }), 'right');
|
||||
assert.equal(frameLayout({ layout: 'none', text: 'x' }), 'none');
|
||||
const f = { image: PNG, text: 'pw is hunter2', layout: 'under', secret: true };
|
||||
assert.deepEqual(frameView(f, false), { withheld: true, image: '', text: '', layout: 'none' });
|
||||
assert.deepEqual(frameView(f, false), { withheld: true, image: '', text: '', ifStuck: '', stop: false, layout: 'none' });
|
||||
assert.equal(frameView(f, true).text, 'pw is hunter2');
|
||||
const g = { image: PNG, text: '', layout: 'none', ifStuck: ' call 555-0100 ', stop: true };
|
||||
assert.deepEqual([frameView(g, false).ifStuck, frameView(g, false).stop], ['call 555-0100', true]);
|
||||
assert.deepEqual([frameView({ ...g, secret: true }, false).ifStuck, frameView({ ...g, secret: true }, false).stop], ['', false]);
|
||||
assert.equal(frameView({ image: '', text: '', layout: 'under', secret: true }, false).withheld, false);
|
||||
});
|
||||
|
||||
|
||||
@@ -345,3 +345,20 @@ test('clearSecrets erases secret fields and frames, keeps the rest, returns the
|
||||
assert.deepEqual(validate(doc), []);
|
||||
assert.equal(clearSecrets(doc), 0);
|
||||
});
|
||||
|
||||
test('addCapture adds a frame and stamps the sequence captured date; clearSecrets clears ifStuck on secret steps', async () => {
|
||||
const { addCapture, clearSecrets, addSequence } = await import('../src/ops.js');
|
||||
const doc = emptyDocument('x');
|
||||
const s = addSection(doc, 'records', 'Banking');
|
||||
const q = addSequence(doc, s);
|
||||
assert.equal(q.captured, undefined);
|
||||
const f = addCapture(q, '');
|
||||
assert.equal(q.frames.length, 1);
|
||||
assert.equal(f.layout, 'under');
|
||||
assert.match(q.captured, /^\d{4}-\d{2}-\d{2}$/);
|
||||
f.secret = true; f.ifStuck = 'call 555-0100'; f.stop = true;
|
||||
assert.equal(clearSecrets(doc), 1);
|
||||
assert.equal(f.ifStuck, '');
|
||||
assert.equal(f.stop, true);
|
||||
assert.deepEqual(validate(doc), []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user