Rename deutsche Testbezeichner und ergaenze Mehrstapel-Testabdeckung
test/storage.test.js: wieder -> reloaded, kaputt -> broken, zweiterEintrag -> secondEntry, vorschlag -> proposal (Bezeichner, nicht die deutschen Testbeschreibungen). Neuer Test deckt die bislang nur mit einem einzigen Stapel geprueften Stapelzaehler-Neuberechnung beim Laden ab: drei gespeicherte Stapel mit absichtlich falschem count, davon einer (C) ganz ohne zugeordnete Eintraege - alle drei muessen unabhaengig voneinander korrekt aus den tatsaechlichen Eintraegen neu berechnet werden (A=2, B=1, C=0). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+46
-24
@@ -30,11 +30,11 @@ test('Sitzung ueberlebt Sichern und Laden', () => {
|
||||
commitAssignment(session, { ...emptySpec(), capacityGb: 64 }, 'barcode', 'A');
|
||||
saveSession(session, store);
|
||||
|
||||
const wieder = loadSession(store);
|
||||
assert.equal(wieder.stacks.length, 1);
|
||||
assert.equal(wieder.stacks[0].count, 1);
|
||||
assert.equal(wieder.entries[0].spec.capacityGb, 64);
|
||||
assert.equal(wieder.nextEntryId, 2);
|
||||
const reloaded = loadSession(store);
|
||||
assert.equal(reloaded.stacks.length, 1);
|
||||
assert.equal(reloaded.stacks[0].count, 1);
|
||||
assert.equal(reloaded.entries[0].spec.capacityGb, 64);
|
||||
assert.equal(reloaded.nextEntryId, 2);
|
||||
});
|
||||
|
||||
test('clearSession raeumt auf', () => {
|
||||
@@ -51,12 +51,12 @@ test('kaputter Inhalt liefert null statt einer Ausnahme', () => {
|
||||
});
|
||||
|
||||
test('Sichern ohne funktionierenden Speicher wirft nicht', () => {
|
||||
const kaputt = {
|
||||
const broken = {
|
||||
getItem: () => null,
|
||||
setItem: () => { throw new Error('quota exceeded'); },
|
||||
removeItem: () => {},
|
||||
};
|
||||
assert.doesNotThrow(() => saveSession(createSession(), kaputt));
|
||||
assert.doesNotThrow(() => saveSession(createSession(), broken));
|
||||
});
|
||||
|
||||
test('stacks mit Nicht-Objekten liefert null', () => {
|
||||
@@ -115,9 +115,31 @@ test('Stapelzaehler wird beim Laden aus den Eintraegen neu berechnet', () => {
|
||||
entries: [{ entryId: 1, stackId: 'A', spec: emptySpec(), source: 'barcode' }],
|
||||
nextEntryId: 2,
|
||||
}));
|
||||
const wieder = loadSession(store);
|
||||
assert.notEqual(wieder, null);
|
||||
assert.equal(wieder.stacks[0].count, 1);
|
||||
const reloaded = loadSession(store);
|
||||
assert.notEqual(reloaded, null);
|
||||
assert.equal(reloaded.stacks[0].count, 1);
|
||||
});
|
||||
|
||||
test('Stapelzaehler werden beim Laden fuer mehrere Stapel unabhaengig neu berechnet, auch fuer einen ohne Eintraege', () => {
|
||||
const store = fakeStore();
|
||||
store.setItem('ram-sortierhilfe:session', JSON.stringify({
|
||||
stacks: [
|
||||
{ id: 'A', count: 99, spec: emptySpec() },
|
||||
{ id: 'B', count: 99, spec: emptySpec() },
|
||||
{ id: 'C', count: 99, spec: emptySpec() },
|
||||
],
|
||||
entries: [
|
||||
{ entryId: 1, stackId: 'A', spec: emptySpec(), source: 'barcode' },
|
||||
{ entryId: 2, stackId: 'A', spec: emptySpec(), source: 'barcode' },
|
||||
{ entryId: 3, stackId: 'B', spec: emptySpec(), source: 'ocr' },
|
||||
],
|
||||
nextEntryId: 4,
|
||||
}));
|
||||
const reloaded = loadSession(store);
|
||||
assert.notEqual(reloaded, null);
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'A').count, 2, 'Stapel A hat zwei zugeordnete Eintraege');
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'B').count, 1, 'Stapel B hat einen zugeordneten Eintrag');
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'C').count, 0, 'Stapel C ohne jeden Eintrag wird auf 0 neu berechnet, nicht auf den gespeicherten Wert');
|
||||
});
|
||||
|
||||
test('Eintrag mit unbekannter Stapelkennung liefert null', () => {
|
||||
@@ -171,25 +193,25 @@ test('nach Sichern und Laden funktioniert Weiterarbeiten weiterhin', () => {
|
||||
const session = createSession();
|
||||
const spec = { ...emptySpec(), capacityGb: 64 };
|
||||
commitAssignment(session, spec, 'barcode', 'A');
|
||||
const zweiterEintrag = commitAssignment(session, spec, 'barcode', 'A');
|
||||
const secondEntry = commitAssignment(session, spec, 'barcode', 'A');
|
||||
saveSession(session, store);
|
||||
|
||||
const wieder = loadSession(store);
|
||||
const reloaded = loadSession(store);
|
||||
|
||||
const vorschlag = proposeAssignment(wieder, spec);
|
||||
assert.equal(vorschlag.kind, 'match');
|
||||
assert.equal(vorschlag.stackId, 'A');
|
||||
commitAssignment(wieder, spec, 'barcode', vorschlag.stackId);
|
||||
assert.equal(wieder.stacks[0].count, 3);
|
||||
assert.equal(wieder.nextEntryId, 4);
|
||||
const proposal = proposeAssignment(reloaded, spec);
|
||||
assert.equal(proposal.kind, 'match');
|
||||
assert.equal(proposal.stackId, 'A');
|
||||
commitAssignment(reloaded, spec, 'barcode', proposal.stackId);
|
||||
assert.equal(reloaded.stacks[0].count, 3);
|
||||
assert.equal(reloaded.nextEntryId, 4);
|
||||
|
||||
moveEntry(wieder, zweiterEintrag.entryId, 'B');
|
||||
assert.equal(wieder.stacks.find((s) => s.id === 'A').count, 2);
|
||||
assert.equal(wieder.stacks.find((s) => s.id === 'B').count, 1);
|
||||
moveEntry(reloaded, secondEntry.entryId, 'B');
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'A').count, 2);
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'B').count, 1);
|
||||
|
||||
removeEntry(wieder, zweiterEintrag.entryId);
|
||||
assert.equal(wieder.entries.find((e) => e.entryId === zweiterEintrag.entryId), undefined);
|
||||
assert.equal(wieder.stacks.find((s) => s.id === 'B'), undefined);
|
||||
removeEntry(reloaded, secondEntry.entryId);
|
||||
assert.equal(reloaded.entries.find((e) => e.entryId === secondEntry.entryId), undefined);
|
||||
assert.equal(reloaded.stacks.find((s) => s.id === 'B'), undefined);
|
||||
});
|
||||
|
||||
test('nextEntryId als negative Zahl liefert null', () => {
|
||||
|
||||
Reference in New Issue
Block a user