mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-16 02:22:17 +00:00
acaf760b36
The server load fetched a full combined-data page at a 9999 item page size, carrying detail text and ownership fields the grid never renders, and the client re-fetched the same payload after hydration. Load a trimmed grid row instead and pack it as positional tuples so field names are not repeated for every one of a thousand-plus entries. Entry detail is fetched on demand from the new per-entry endpoint when a cell is opened, and the grid marks itself interactive so other page-start work can queue behind it.
28 lines
772 B
TypeScript
28 lines
772 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { packGrid, unpackGrid, type PokedexGridRow } from '$lib/models/PokedexGridRow';
|
|
describe('grid transport', () => {
|
|
it('round-trips missing catches and every flag combination', () => {
|
|
const rows: PokedexGridRow[] = Array.from({ length: 17 }, (_, flags) => ({
|
|
pokedexEntry: {
|
|
_id: String(flags),
|
|
pokedexNumber: 25,
|
|
pokemon: 'Pikachu',
|
|
form: 'Female',
|
|
spriteKey: '25',
|
|
canGigantamax: true
|
|
},
|
|
catchRecord:
|
|
flags === 16
|
|
? null
|
|
: {
|
|
_id: `catch-${flags}`,
|
|
caught: !!(flags & 1),
|
|
haveToEvolve: !!(flags & 2),
|
|
inHome: !!(flags & 4),
|
|
hasGigantamaxed: !!(flags & 8)
|
|
}
|
|
}));
|
|
expect(unpackGrid(packGrid(rows))).toEqual(rows);
|
|
});
|
|
});
|