feat(intake): record who chose an item's price (#225)
Pure and separately tested because the failure it guards is silent. Items are priced on arrival, so the schema no longer stops a number nobody chose reaching the storefront — the review queue does, by showing that nobody chose it, and an item selling at a default price looks exactly like one selling at a chosen price. Editing the number is the only thing that confirms it. Publishing an untouched field deliberately does not, because that would record "I did not look at this" as "I approved this". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { nextPriceSource, isUnconfirmed } from '../../src/intake/priceSource';
|
||||
|
||||
describe('nextPriceSource', () => {
|
||||
// Touching the number is the admin taking responsibility for it. That is the
|
||||
// only event that can confirm a price.
|
||||
it('becomes admin when the number changes', () => {
|
||||
expect(nextPriceSource('default', 9500, 8000)).toBe('admin');
|
||||
expect(nextPriceSource('ai', 4000, 4500)).toBe('admin');
|
||||
});
|
||||
|
||||
// Publishing without touching the field must NOT silently confirm it. That
|
||||
// is the whole failure this screen exists to prevent: an item selling at a
|
||||
// number nobody chose, with nothing recording that.
|
||||
it('leaves an untouched price unconfirmed', () => {
|
||||
expect(nextPriceSource('default', 8000, 8000)).toBe('default');
|
||||
expect(nextPriceSource('ai', 4500, 4500)).toBe('ai');
|
||||
});
|
||||
|
||||
// Already confirmed stays confirmed, including when re-submitted unchanged.
|
||||
it('keeps admin once set', () => {
|
||||
expect(nextPriceSource('admin', 9500, 9500)).toBe('admin');
|
||||
expect(nextPriceSource('admin', 7000, 9500)).toBe('admin');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isUnconfirmed', () => {
|
||||
it('treats anything but admin as unconfirmed', () => {
|
||||
expect(isUnconfirmed('default')).toBe(true);
|
||||
expect(isUnconfirmed('ai')).toBe(true);
|
||||
expect(isUnconfirmed('admin')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user