This commit is contained in:
seb
2026-10-15 20:14:51 +02:00
parent 7c8c24eb4d
commit 2179b2e241
23 changed files with 1242 additions and 105 deletions

View File

@@ -63,8 +63,8 @@ async function run() {
assert.ok(order1.id, 'Order must have an id');
assert.equal(order1.type, 'order');
assert.equal(order1.entityId, customer.id);
assert.equal(order1.externalNumber, 'EXT-QUOTE-123');
assert.ok(order1.number, 'Order must have auto-allocated number');
assert.equal(order1.externalNumber, quote.number);
assert.equal(order1.number, 'AUF-000001');
assert.equal(order1.lines.length, 1);
assert.equal(order1.lines[0].sku, art.sku);
assert.equal(order1.lines[0].amount, 5);
@@ -106,6 +106,35 @@ async function run() {
{ message: 'Quote not found' }
);
// 6. Quote without entity should throw 'No entity selected' if no entity passed
const quoteWithoutEntity = await store.quote.create(googleAuthId, {
number: 'Q-NO-ENT',
date: '2026-09-01T10:00:00Z',
lines: [{ sku: art.sku, name: 'Gadget', amount: 1, net: 10, taxrate: 19 }],
});
assert.equal(quoteWithoutEntity.entityId, null);
await assert.rejects(
async () => {
await store.order.createFromQuote(googleAuthId, quoteWithoutEntity.id);
},
{ message: 'No entity selected' }
);
// 7. Explicitly overriding with entityId: null should also throw 'No entity selected'
await assert.rejects(
async () => {
await store.order.createFromQuote(googleAuthId, quote.id, { entityId: null });
},
{ message: 'No entity selected' }
);
// 8. Passing entityId for quote without entity should succeed
const orderFromNoEnt = await store.order.createFromQuote(googleAuthId, quoteWithoutEntity.id, {
entityId: customer.id,
});
assert.equal(orderFromNoEnt.entityId, customer.id);
console.log('PASS: All order.createFromQuote tests passed successfully!');
} finally {
try {