good
Some checks failed
CI / Backend tests (pull_request) Has been cancelled
CI / Frontend lint (pull_request) Has been cancelled
CI / Frontend unit tests (pull_request) Has been cancelled
CI / Frontend build (pull_request) Has been cancelled
CI / Playwright e2e (pull_request) Has been cancelled

This commit is contained in:
Andras Schmelczer 2026-05-30 15:55:29 +01:00
parent 5ac6633d40
commit 617e3ef16d
6 changed files with 147 additions and 95 deletions

View file

@ -69,7 +69,7 @@ interface ExampleDonePattern {
desc: (sequence: number) => string;
}
const EXAMPLE_DONE_BLOCKS_PER_TOWER = 120;
const EXAMPLE_DONE_BLOCKS_PER_TOWER = 12;
@Injectable({ providedIn: 'root' })
export class StoreService implements OnDestroy {
@ -333,11 +333,11 @@ export class StoreService implements OnDestroy {
pages.map((p) =>
p.id === pageId
? {
...p,
towers: p.towers.map((t) =>
t.id === towerId ? { ...t, blocks: [...t.blocks, block] } : t,
),
}
...p,
towers: p.towers.map((t) =>
t.id === towerId ? { ...t, blocks: [...t.blocks, block] } : t,
),
}
: p,
),
);
@ -356,16 +356,16 @@ export class StoreService implements OnDestroy {
pages.map((p) =>
p.id === pageId
? {
...p,
towers: p.towers.map((t) =>
t.id === towerId
? {
...t,
blocks: this.patchBlockList(t.blocks, blockId, patch).blocks,
}
: t,
),
}
...p,
towers: p.towers.map((t) =>
t.id === towerId
? {
...t,
blocks: this.patchBlockList(t.blocks, blockId, patch).blocks,
}
: t,
),
}
: p,
),
);
@ -377,13 +377,13 @@ export class StoreService implements OnDestroy {
pages.map((p) =>
p.id === pageId
? {
...p,
towers: p.towers.map((t) =>
t.id === towerId
? { ...t, blocks: t.blocks.filter((b) => b.id !== blockId) }
: t,
),
}
...p,
towers: p.towers.map((t) =>
t.id === towerId
? { ...t, blocks: t.blocks.filter((b) => b.id !== blockId) }
: t,
),
}
: p,
),
);
@ -396,21 +396,21 @@ export class StoreService implements OnDestroy {
pages.map((p) =>
p.id === pageId
? {
...p,
towers: p.towers.map((t) =>
t.id === towerId
? (() => {
const block = t.blocks.find((b) => b.id === blockId);
if (!block) return t;
const result = this.patchBlockList(t.blocks, blockId, {
is_done: !block.is_done,
});
becameDone = result.becameDone;
return { ...t, blocks: result.blocks };
})()
: t,
),
}
...p,
towers: p.towers.map((t) =>
t.id === towerId
? (() => {
const block = t.blocks.find((b) => b.id === blockId);
if (!block) return t;
const result = this.patchBlockList(t.blocks, blockId, {
is_done: !block.is_done,
});
becameDone = result.becameDone;
return { ...t, blocks: result.blocks };
})()
: t,
),
}
: p,
),
);

View file

@ -280,7 +280,7 @@ describe('StoreService', () => {
expect(blocks[2].created_at).toBe(100);
});
it('loads welcome example data with hundreds of completed squares', () => {
it('loads welcome example data with a stack of completed squares per tower', () => {
const api = makeMockApi();
const store = configure(api);
@ -292,13 +292,13 @@ describe('StoreService', () => {
expect(page.towers).toHaveLength(3);
const doneBlocks = page.towers.flatMap((tower) => tower.blocks.filter((b) => b.is_done));
expect(doneBlocks.length).toBeGreaterThanOrEqual(300);
expect(doneBlocks.length).toBeGreaterThanOrEqual(90);
expect(new Set(page.towers.flatMap((tower) => tower.blocks.map((b) => b.difficulty))).size)
.toBeGreaterThan(1);
for (const tower of page.towers) {
const doneDates = tower.blocks.filter((b) => b.is_done).map((b) => b.created_at);
expect(doneDates.length).toBeGreaterThanOrEqual(100);
expect(doneDates.length).toBeGreaterThanOrEqual(30);
expect(doneDates).toEqual([...doneDates].sort((a, b) => a - b));
expect(new Set(tower.blocks.map((b) => b.difficulty)).size).toBeGreaterThan(1);
}