feat: do final stress tests
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-24 21:06:06 +02:00
parent e474ee2bc5
commit 072cda111c
14 changed files with 86 additions and 9 deletions
+12
View File
@@ -124,6 +124,18 @@ describe('findLine', () => {
});
});
describe('VenueTabs.removable', () => {
it('counts only drinks still on the line, so a removal after a settlement returns nothing to the stock', () => {
const tabs = withCola(3);
const removal = event({ type: 'line_removed', lineId: 'line-1', quantity: 5, ...cola });
expect(tabs.removable(removal)).toBe(3);
tabs.apply(event({ type: 'settled', amountInCents: 750, paymentMethod: 'cash', items: [{ ...cola, quantity: 3 }] }), time);
expect(tabs.removable(removal)).toBe(0);
expect(tabs.removable(event({ type: 'line_removed', tabId: 'gone', quantity: 1, ...cola }))).toBe(0);
});
});
describe('seedTabs and tabSummary', () => {
it("turns a terminal's snapshot into tabs the dashboard sums up the same", () => {
const [seeded] = seedTabs([{
+10
View File
@@ -171,6 +171,16 @@ export class VenueTabs {
}
}
/**
* How many drinks a line_removed event can actually take off: none when the tab or line is gone (settled or
* deleted elsewhere while the terminal was offline).
*/
removable(event: TabEventDto): number {
const tab = event.tabId ? this.tabs.get(event.tabId) : undefined;
const line = tab && findLine(tab, event);
return line ? Math.min(event.quantity ?? 0, lineQuantity(line)) : 0;
}
/** Settles everything still on the tab, as the dashboard does. Null when there is nothing to settle. */
settleAll(tabId: string, settlement: { id: string; settledAt: Date; paymentMethod: string }): SettlementDraft | null {
const tab = this.tabs.get(tabId);