diff --git a/client/src/mobile/components/NativeImportSheet.test.tsx b/client/src/mobile/components/NativeImportSheet.test.tsx
index befb4ec20..0d0b7c454 100644
--- a/client/src/mobile/components/NativeImportSheet.test.tsx
+++ b/client/src/mobile/components/NativeImportSheet.test.tsx
@@ -208,7 +208,9 @@ describe('NativeImportSheet', () => {
answer = () => resolve([]);
})
);
- act(() => void useTripAddonsStore.getState().load(1));
+ await act(async () => {
+ void useTripAddonsStore.getState().load(1);
+ });
expect(screen.getByRole('button', { name: /Japan/ })).toBeInTheDocument();
await act(async () => answer());
expect(screen.getByRole('button', { name: /Japan/ })).toBeInTheDocument();
diff --git a/client/src/pages/admin/useAdmin.test.tsx b/client/src/pages/admin/useAdmin.test.tsx
index 1aa40af94..e9fcbbe93 100644
--- a/client/src/pages/admin/useAdmin.test.tsx
+++ b/client/src/pages/admin/useAdmin.test.tsx
@@ -1031,9 +1031,13 @@ describe('useAdmin', () => {
await waitFor(() => expect(result.current.admin.isLoading).toBe(false));
expect(result.current.admin.activeTab).toBe('security');
- act(() => void result.current.navigate('/admin?tab=services'));
+ await act(async () => {
+ await result.current.navigate('/admin?tab=services');
+ });
expect(result.current.admin.activeTab).toBe('services');
- act(() => void result.current.navigate('/admin?tab=settings'));
+ await act(async () => {
+ await result.current.navigate('/admin?tab=settings');
+ });
expect(result.current.admin.activeTab).toBe('security');
act(() => result.current.admin.setActiveTab('audit'));
expect(result.current.admin.activeTab).toBe('audit');
diff --git a/client/src/pages/tripPlanner/useRoadtripStopEdits.ts b/client/src/pages/tripPlanner/useRoadtripStopEdits.ts
index a7cd7d223..5095c7cb2 100644
--- a/client/src/pages/tripPlanner/useRoadtripStopEdits.ts
+++ b/client/src/pages/tripPlanner/useRoadtripStopEdits.ts
@@ -49,8 +49,12 @@ async function writeEditedStop(
tripId: PlannerBase['tripId'],
assignments: TripStoreState['assignments'],
{ placeId, assignmentId, dwellMinutes: before }: { placeId: number; assignmentId?: number; dwellMinutes?: number },
- { stopType, dwellMinutes }: { stopType: RoadtripStopType | null; dwellMinutes: number },
- { mayEditVisit, refused }: { mayEditVisit: boolean; refused: string },
+ {
+ stopType,
+ dwellMinutes,
+ mayEditVisit,
+ refused,
+ }: { stopType: RoadtripStopType | null; dwellMinutes: number; mayEditVisit: boolean; refused: string },
): Promise
{
const visitDayId = savedVisitDayOf(assignments, assignmentId)
if (assignmentId == null || visitDayId === null) {
@@ -101,7 +105,9 @@ export function useRoadtripStopEdits(options: RoadtripStopEditsOptions) {
}
try {
if (stopDraft.editing) {
- await writeEditedStop(tripActions, tripId, assignments, stopDraft.editing, { stopType, dwellMinutes }, {
+ await writeEditedStop(tripActions, tripId, assignments, stopDraft.editing, {
+ stopType,
+ dwellMinutes,
mayEditVisit: can('day_edit', trip),
refused: t('trip.journal.errorForbidden'),
})
diff --git a/client/src/store/tripAddonsStore.ts b/client/src/store/tripAddonsStore.ts
index 2198bdd87..c3734c3f4 100644
--- a/client/src/store/tripAddonsStore.ts
+++ b/client/src/store/tripAddonsStore.ts
@@ -70,7 +70,11 @@ export const useTripAddonsStore = create((set, get) => ({
// A push that landed meanwhile is newer than this answer and stays, in the
// store and in the device's copy the answer was written over.
if (current && current.rev !== rev) {
- if (addons && current.addons) void tripAddonsRepo.remember(tripId, current.addons).catch(() => {});
+ if (addons && current.addons)
+ void tripAddonsRepo.remember(tripId, current.addons).catch(() => {
+ // The device copy stays one answer behind until the next read of this trip writes it.
+ return undefined;
+ });
return current.addons;
}
const entry: TripAddonsEntry = addons
diff --git a/server/src/nest/integrations/dawarich-sync.service.ts b/server/src/nest/integrations/dawarich-sync.service.ts
index c640c4e51..f3913cd82 100644
--- a/server/src/nest/integrations/dawarich-sync.service.ts
+++ b/server/src/nest/integrations/dawarich-sync.service.ts
@@ -362,11 +362,14 @@ export class DawarichSyncService {
* @txIndependent one stay at a time after its network read.
*/
private async rereadUnnamed(nameStay: StayNamer): Promise {
- for (const stay of nameStay.unnamed.slice(0, MAX_UNNAMED_STAY_REREADS)) {
+ // One after another: a read that finds the budget spent stops the rest.
+ await nameStay.unnamed.slice(0, MAX_UNNAMED_STAY_REREADS).reduce>(async (going, stay) => {
+ if (!(await going)) return false;
const found = await nameStay.read(stay.startedAt, stay.endedAt);
- if (found === undefined) return;
+ if (found === undefined) return false;
if (found !== null) await this.suggestions.renameNewVisit(stay.id, found);
- }
+ return true;
+ }, Promise.resolve(true));
}
/**
diff --git a/server/src/nest/plugins/plugin-event-addons.ts b/server/src/nest/plugins/plugin-event-addons.ts
index 5d38792c7..900c2f8c4 100644
--- a/server/src/nest/plugins/plugin-event-addons.ts
+++ b/server/src/nest/plugins/plugin-event-addons.ts
@@ -47,7 +47,7 @@ export function tripEventSink(addons: AddonsService, orm: MikroORM | undefined,
return (tripId, event, meta) => {
const addonId = tripAddonOfEvent(event);
const before = queues.get(tripId);
- if (!addonId && !before) return deliver(tripId, event, meta);
+ if (!addonId && before === undefined) return deliver(tripId, event, meta);
const ask = () => (addonId ? addons.isEnabledForTrip(tripId, addonId) : Promise.resolve(true));
const on = (orm && addonId ? withRequestContext(orm, ask) : ask()).catch(() => false);
const queued = (before ?? Promise.resolve())
diff --git a/server/tests/postgres/backup-round-trip.test.ts b/server/tests/postgres/backup-round-trip.test.ts
index 4473396c1..c2e64a620 100644
--- a/server/tests/postgres/backup-round-trip.test.ts
+++ b/server/tests/postgres/backup-round-trip.test.ts
@@ -82,10 +82,7 @@ afterAll(async () => {
describe('Postgres backup round trip', () => {
it('PGRT-001: a dump restores over a changed schema, dropping what came later, views and functions included', async (ctx) => {
- if (unfit) {
- console.log(`PGRT-001 skipped: ${unfit}`);
- ctx.skip();
- }
+ if (unfit) ctx.skip(`PGRT-001 skipped: ${unfit}`);
await asOwner((run) =>
oneByOne(
[
diff --git a/server/tests/unit/db/engine/postgres/script-settings.test.ts b/server/tests/unit/db/engine/postgres/script-settings.test.ts
index 65d782337..ccf227f52 100644
--- a/server/tests/unit/db/engine/postgres/script-settings.test.ts
+++ b/server/tests/unit/db/engine/postgres/script-settings.test.ts
@@ -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));
},
);
diff --git a/server/tests/unit/db/migrate-encryption-parity.test.ts b/server/tests/unit/db/migrate-encryption-parity.test.ts
index b4840ca57..2fd1f6112 100644
--- a/server/tests/unit/db/migrate-encryption-parity.test.ts
+++ b/server/tests/unit/db/migrate-encryption-parity.test.ts
@@ -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);
diff --git a/server/tests/unit/mcp/tools-files.test.ts b/server/tests/unit/mcp/tools-files.test.ts
index 332c094b3..1901efba0 100644
--- a/server/tests/unit/mcp/tools-files.test.ts
+++ b/server/tests/unit/mcp/tools-files.test.ts
@@ -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',
diff --git a/server/tests/unit/nest/files.service.test.ts b/server/tests/unit/nest/files.service.test.ts
index 465f68e56..bddf7394c 100644
--- a/server/tests/unit/nest/files.service.test.ts
+++ b/server/tests/unit/nest/files.service.test.ts
@@ -386,8 +386,12 @@ describe('listFiles', () => {
const files = (await svc.listFiles(trip.id, false, true)) as Record[];
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);
});
});
diff --git a/server/tests/unit/nest/mail-ingest/mail-ingest.controller.test.ts b/server/tests/unit/nest/mail-ingest/mail-ingest.controller.test.ts
index 49f66e9f9..b05fe486f 100644
--- a/server/tests/unit/nest/mail-ingest/mail-ingest.controller.test.ts
+++ b/server/tests/unit/nest/mail-ingest/mail-ingest.controller.test.ts
@@ -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());
});
});
diff --git a/server/tests/unit/nest/reservations.service.test.ts b/server/tests/unit/nest/reservations.service.test.ts
index 4253761db..10239e172 100644
--- a/server/tests/unit/nest/reservations.service.test.ts
+++ b/server/tests/unit/nest/reservations.service.test.ts
@@ -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 () => {