mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
chore(lint): keep the fixes within the lint ratchets
No promise in a condition, sequential awaits through a reduce instead of a loop, no non-null assertions or any in the new tests, an awaited act, one options object for a stop edit and a handled rejection for the offline copy.
This commit is contained in:
@@ -54,9 +54,9 @@ describe('script-settings', () => {
|
||||
'SCRIPTSET-001: a PostgreSQL %i server gets the script without SET transaction_timeout, and nothing else changes',
|
||||
async (major) => {
|
||||
const expected = SCRIPT.replace('SET transaction_timeout = 0;\n', '');
|
||||
for (const size of [1, 3, 7, 64, 1 << 20]) {
|
||||
expect(await filtered(SCRIPT, major, size), `chunks of ${size}`).toBe(expected);
|
||||
}
|
||||
const sizes = [1, 3, 7, 64, 1 << 20];
|
||||
const results = await Promise.all(sizes.map((size) => filtered(SCRIPT, major, size)));
|
||||
results.forEach((result, i) => expect(result, `chunks of ${sizes[i]}`).toBe(expected));
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ describe('migrate-encryption.ts rotates the stores the app writes', () => {
|
||||
token: string | null;
|
||||
}>;
|
||||
after.close();
|
||||
expect(decryptWith('new-key', rows[0].token!)).toBe('wanderer-token');
|
||||
expect(decryptWith('new-key', String(rows[0].token))).toBe('wanderer-token');
|
||||
expect(rows[1].token).toBeNull();
|
||||
}, 30000);
|
||||
|
||||
|
||||
@@ -688,7 +688,7 @@ describe('Tool: upload_trip_file', () => {
|
||||
name: 'upload_trip_file',
|
||||
arguments: { tripId: trip.id, filename: 'receipt.pdf', content: pdf, budget_item_id: expense.id },
|
||||
}),
|
||||
) as any;
|
||||
) as { file: { id: number } };
|
||||
expect((await linkRows(data.file.id)).map((l) => l.budget_item_id)).toEqual([expense.id]);
|
||||
const foreign = await h.client.callTool({
|
||||
name: 'upload_trip_file',
|
||||
@@ -713,8 +713,8 @@ describe('Tool: upload_trip_file', () => {
|
||||
name: 'upload_trip_file',
|
||||
arguments: { tripId: trip.id, filename: 'ticket.pdf', content: pdf },
|
||||
}),
|
||||
) as any
|
||||
).file.id as number;
|
||||
) as { file: { id: number } }
|
||||
).file.id;
|
||||
const receipt = await upload();
|
||||
const refused = await h.client.callTool({
|
||||
name: 'update_trip_file',
|
||||
|
||||
@@ -386,8 +386,12 @@ describe('listFiles', () => {
|
||||
|
||||
const files = (await svc.listFiles(trip.id, false, true)) as Record<string, unknown>[];
|
||||
expect(files.map((f) => f.id).sort()).toEqual([onBooking.id, onPlace.id, receipt.id].sort());
|
||||
expect(await svc.isAttached((await svc.getFileById(receipt.id, trip.id))!)).toBe(true);
|
||||
expect(await svc.isAttached((await svc.getFileById(loose.id, trip.id))!)).toBe(false);
|
||||
const [receiptRow, looseRow] = await Promise.all([
|
||||
svc.getFileById(receipt.id, trip.id),
|
||||
svc.getFileById(loose.id, trip.id),
|
||||
]);
|
||||
expect(receiptRow && (await svc.isAttached(receiptRow))).toBe(true);
|
||||
expect(looseRow && (await svc.isAttached(looseRow))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -129,14 +129,16 @@ describe('the mail tools', () => {
|
||||
|
||||
it('are listed only while the import is on, since every call needs it', async () => {
|
||||
expect(tools).toHaveLength(7);
|
||||
for (const name of tools) {
|
||||
// One tool after another: each takes the next answer of the settings stub.
|
||||
await tools.reduce(async (previous, name) => {
|
||||
await previous;
|
||||
const entry = getEntry(MailIngestMcp as unknown as ClassRef, name);
|
||||
const when = entry?.kind === 'tool' ? entry.options.when : undefined;
|
||||
expect(when, name).toBeTypeOf('function');
|
||||
settings.isAvailable.mockResolvedValueOnce(false);
|
||||
expect(await when?.(ctx, mcp()), name).toBe(false);
|
||||
expect(await when?.(ctx, mcp()), name).toBe(true);
|
||||
}
|
||||
}, Promise.resolve());
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1548,10 +1548,12 @@ describe('ReservationsService — referenced ids stay inside the trip', () => {
|
||||
const foreignDay = await findRow(orm, Days, { trip: theirs.id }) as { id: number };
|
||||
const foreignAcc = createDayAccommodation(testDb, theirs.id, foreignPlace.id, foreignDay.id, foreignDay.id);
|
||||
|
||||
for (const accommodation_id of [3000000000, foreignAcc.id]) {
|
||||
const dropped = async (accommodation_id: number) => {
|
||||
const { reservation } = await svc.create(String(mine.id), { title: 'Hotel', type: 'hotel', accommodation_id });
|
||||
expect(await findRow(orm, Reservations, { id: reservation.id })).toMatchObject({ accommodation_id: null });
|
||||
}
|
||||
};
|
||||
await dropped(3000000000);
|
||||
await dropped(foreignAcc.id);
|
||||
});
|
||||
|
||||
it('RESV-SCOPE-011: a stay whose refs resolve to nothing is refused, never written and never dropped in silence', async () => {
|
||||
|
||||
Reference in New Issue
Block a user