fix(places): the third CI run, no awaits in loops and an edit target that may be none

The rating order test pages through its cursor with a recursion and checks
the refused floors at once instead of awaiting in a loop, and the edit hook
types its first editable copy as possibly none, which the strict check reads
from a conditional rather than a narrowed assignment.
This commit is contained in:
Maurice
2026-11-30 00:16:23 +00:00
parent 1c9ac0b159
commit 29ae0de1ef
2 changed files with 10 additions and 12 deletions
@@ -105,10 +105,10 @@ describe('the rating filter of All places', () => {
it('narrows a kind as well, and refuses a floor outside 1 to 5', async () => {
const s = await seed();
expect(names(await page(s.me.id, { min_rating: 2, kind: 'list' }))).toEqual(['Delta']);
for (const bad of ['0', '6', '4.5', 'x']) {
const res = await request(server).get(LIBRARY).query({ min_rating: bad }).set(as(s.me.id));
expect(res.status).toBe(400);
}
const refused = await Promise.all(
['0', '6', '4.5', 'x'].map((bad) => request(server).get(LIBRARY).query({ min_rating: bad }).set(as(s.me.id))),
);
expect(refused.map((res) => res.status)).toEqual([400, 400, 400, 400]);
});
it('averages over the votes the reader can see: the friend reaches the trip only', async () => {
@@ -127,16 +127,14 @@ describe('the rating order of All places', () => {
it('pages through its cursor without a gap or a double', async () => {
const s = await seed();
const seen: string[] = [];
let cursor: string | null = null;
for (let i = 0; i < 5; i++) {
/** The pages from `cursor` on, one entry each, until the order ends. */
const rest = async (cursor: string | null, depth: number): Promise<string[]> => {
const query: Record<string, string | number> = { sort: 'rating', limit: 1 };
if (cursor) query.cursor = cursor;
const p = await page(s.me.id, query);
seen.push(...names(p));
cursor = p.next_cursor;
if (!cursor) break;
}
return p.next_cursor && depth < 5 ? [...names(p), ...(await rest(p.next_cursor, depth + 1))] : names(p);
};
const seen = await rest(null, 0);
expect(seen).toEqual(['Beta', 'Alpha', 'Delta', 'Gamma']);
// A cursor of the name order is no cursor of the rating order.
const byName = await page(s.me.id, { limit: 1 });