feat: order revision, rial wage from variant, product tags; drop user-app-v2
Admin order edit with category chips and timeline; customer checkout charges variant rialWage; product tags; retire the unused user-app-v2 tree. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -38,9 +38,6 @@ const chk = (cond, msg) => {
|
||||
};
|
||||
const step = (t) => console.log('\n' + t);
|
||||
|
||||
/** Differences found between the two apps, reported at the end. */
|
||||
const divergences = [];
|
||||
|
||||
const createdOrders = [];
|
||||
|
||||
let token = null;
|
||||
@@ -92,19 +89,16 @@ function loadCartRules(app) {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
// ── 0. BOTH APPS' CART RULES ────────────────────────────────────────────
|
||||
step('0 — CART STOCK RULES, in each app\'s own source');
|
||||
// ── 0. USER-APP CART RULES ──────────────────────────────────────────────
|
||||
step('0 — CART STOCK RULES, in user-app source');
|
||||
const v1 = loadCartRules('user-app');
|
||||
const v2 = loadCartRules('user-app-v2');
|
||||
|
||||
for (const [name, m] of [['user-app', v1], ['user-app-v2', v2]]) {
|
||||
chk(m.hasCapQty, `${name}: capQty() exists`);
|
||||
chk(m.hasMaxQty, `${name}: maxQty() exists`);
|
||||
chk(m.hasAddGuard, `${name}: addToCart refuses an un-orderable variant`);
|
||||
chk(m.hasQtyClamp, `${name}: updateFeild clamps a qty change`);
|
||||
}
|
||||
chk(v1.hasCapQty, 'user-app: capQty() exists');
|
||||
chk(v1.hasMaxQty, 'user-app: maxQty() exists');
|
||||
chk(v1.hasAddGuard, 'user-app: addToCart refuses an un-orderable variant');
|
||||
chk(v1.hasQtyClamp, 'user-app: updateFeild clamps a qty change');
|
||||
|
||||
if (v1.capQty && v2.capQty) {
|
||||
if (v1.capQty) {
|
||||
const cases = [
|
||||
{ want: 10, variant: { qty: 3 }, expect: 3, label: 'want 10 of 3 in stock -> 3' },
|
||||
{ want: 2, variant: { qty: 5 }, expect: 2, label: 'want 2 of 5 in stock -> 2' },
|
||||
@@ -114,17 +108,10 @@ function loadCartRules(app) {
|
||||
];
|
||||
for (const c of cases) {
|
||||
const a = v1.capQty(c.want, c.variant);
|
||||
const b = v2.capQty(c.want, c.variant);
|
||||
chk(a === c.expect, `user-app: ${c.label} (got ${a})`);
|
||||
chk(b === c.expect, `user-app-v2: ${c.label} (got ${b})`);
|
||||
if (a !== b) divergences.push(`capQty(${c.want}, ${JSON.stringify(c.variant)}): v1=${a} v2=${b}`);
|
||||
}
|
||||
}
|
||||
|
||||
const sameStore = v1.src === v2.src;
|
||||
chk(sameStore, 'the two cart stores are byte-identical');
|
||||
if (!sameStore) divergences.push('cartStore.ts differs between the apps');
|
||||
|
||||
// ── 1. LOGIN WITH THE MASTER CODE ───────────────────────────────────────
|
||||
step('1 — LOGIN with the delivery master code');
|
||||
const customer = await prisma.customer.findFirst({
|
||||
@@ -281,11 +268,6 @@ function loadCartRules(app) {
|
||||
console.log('\nFailures:');
|
||||
failures.forEach((f) => console.log(' - ' + f));
|
||||
}
|
||||
console.log(
|
||||
divergences.length
|
||||
? `\nDIVERGENCES between the apps:\n${divergences.map((d) => ' - ' + d).join('\n')}`
|
||||
: '\nNo behavioural divergence between user-app and user-app-v2.',
|
||||
);
|
||||
console.log('='.repeat(60));
|
||||
|
||||
await prisma.$disconnect();
|
||||
|
||||
Reference in New Issue
Block a user