Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test: factories hand their overrides over apart from the row

Maurice188c6153d5e4
diff --git a/server/tests/helpers/factories/atlas.ts b/server/tests/helpers/factories/atlas.ts
index 646908d5c..b7e2e3fcd 100644
--- a/server/tests/helpers/factories/atlas.ts
+++ b/server/tests/helpers/factories/atlas.ts
@@ -13,15 +13,19 @@ export function makeBucketListItem(
userId: number,
overrides: EntityData<BucketList> = {},
): Promise<BucketListRow> {
- return createRow(orm, BucketList, {
- user: userId,
- name: 'Test Destination',
- lat: null,
- lng: null,
- country_code: null,
- notes: null,
- ...overrides,
- });
+ return createRow(
+ orm,
+ BucketList,
+ {
+ user: userId,
+ name: 'Test Destination',
+ lat: null,
+ lng: null,
+ country_code: null,
+ notes: null,
+ },
+ overrides,
+ );
}
/** Marks the country visited by hand; marking it twice is a no-op. The code is upper-cased as the atlas stores it. */
diff --git a/server/tests/helpers/factories/budget.ts b/server/tests/helpers/factories/budget.ts
index 530723ff8..08036eadd 100644
--- a/server/tests/helpers/factories/budget.ts
+++ b/server/tests/helpers/factories/budget.ts
@@ -13,13 +13,17 @@ export function makeBudgetItem(
tripId: number,
overrides: EntityData<BudgetItems> = {},
): Promise<BudgetItemRow> {
- return createRow(orm, BudgetItems, {
- trip: tripId,
- name: 'Test Budget Item',
- category: 'Transport',
- total_price: 100,
- ...overrides,
- });
+ return createRow(
+ orm,
+ BudgetItems,
+ {
+ trip: tripId,
+ name: 'Test Budget Item',
+ category: 'Transport',
+ total_price: 100,
+ },
+ overrides,
+ );
}
/** Adds the user to the expense's split, with an explicit share when `amount` is given. */
@@ -29,7 +33,7 @@ export function addBudgetItemMember(
userId: number,
overrides: EntityData<BudgetItemMembers> = {},
): Promise<EntityDTO<BudgetItemMembers>> {
- return createRow(orm, BudgetItemMembers, { budgetItem: budgetItemId, user: userId, ...overrides });
+ return createRow(orm, BudgetItemMembers, { budgetItem: budgetItemId, user: userId }, overrides);
}
/** Records that the user paid `amount` of the expense. */
diff --git a/server/tests/helpers/factories/collab.ts b/server/tests/helpers/factories/collab.ts
index ff9780577..68fbd3c16 100644
--- a/server/tests/helpers/factories/collab.ts
+++ b/server/tests/helpers/factories/collab.ts
@@ -14,15 +14,19 @@ export function makeCollabNote(
userId: number,
overrides: EntityData<CollabNotes> = {},
): Promise<CollabNoteRow> {
- return createRow(orm, CollabNotes, {
- trip: tripId,
- user: userId,
- title: 'Test Note',
- content: null,
- category: 'General',
- color: '#6366f1',
- ...overrides,
- });
+ return createRow(
+ orm,
+ CollabNotes,
+ {
+ trip: tripId,
+ user: userId,
+ title: 'Test Note',
+ content: null,
+ category: 'General',
+ color: '#6366f1',
+ },
+ overrides,
+ );
}
/** A chat message on the trip; `replyToRef` makes it a reply. */
@@ -32,5 +36,5 @@ export function makeCollabMessage(
userId: number,
overrides: EntityData<CollabMessages> = {},
): Promise<CollabMessageRow> {
- return createRow(orm, CollabMessages, { trip: tripId, user: userId, text: 'Test message', ...overrides });
+ return createRow(orm, CollabMessages, { trip: tripId, user: userId, text: 'Test message' }, overrides);
}
diff --git a/server/tests/helpers/factories/collections.ts b/server/tests/helpers/factories/collections.ts
index d09d4ecbf..76e02b330 100644
--- a/server/tests/helpers/factories/collections.ts
+++ b/server/tests/helpers/factories/collections.ts
@@ -14,11 +14,15 @@ export function makeCollection(
ownerId: number,
overrides: EntityData<Collections> = {},
): Promise<CollectionRow> {
- return createRow(orm, Collections, {
- owner: ownerId,
- name: `Test Collection ${nextSeq('collection')}`,
- ...overrides,
- });
+ return createRow(
+ orm,
+ Collections,
+ {
+ owner: ownerId,
+ name: `Test Collection ${nextSeq('collection')}`,
+ },
+ overrides,
+ );
}
/** Invites the user into the collection; `status: 'accepted'` makes them a member right away. */
@@ -28,13 +32,17 @@ export function addCollectionMember(
userId: number,
overrides: EntityData<CollectionMembers> = {},
): Promise<EntityDTO<CollectionMembers>> {
- return createRow(orm, CollectionMembers, {
- collection: collectionId,
- user: userId,
- status: 'accepted',
- role: 'editor',
- ...overrides,
- });
+ return createRow(
+ orm,
+ CollectionMembers,
+ {
+ collection: collectionId,
+ user: userId,
+ status: 'accepted',
+ role: 'editor',
+ },
+ overrides,
+ );
}
/** A place saved into the collection by `ownerId`. */
@@ -44,14 +52,18 @@ export function makeCollectionPlace(
ownerId: number,
overrides: EntityData<CollectionPlaces> = {},
): Promise<CollectionPlaceRow> {
- return createRow(orm, CollectionPlaces, {
- collection: collectionId,
- owner: ownerId,
- name: `Saved Place ${nextSeq('collection-place')}`,
- lat: 48.8566,
- lng: 2.3522,
- ...overrides,
- });
+ return createRow(
+ orm,
+ CollectionPlaces,
+ {
+ collection: collectionId,
+ owner: ownerId,
+ name: `Saved Place ${nextSeq('collection-place')}`,
+ lat: 48.8566,
+ lng: 2.3522,
+ },
+ overrides,
+ );
}
/** Puts the tags on the saved place. */
diff --git a/server/tests/helpers/factories/files.ts b/server/tests/helpers/factories/files.ts
index f077a0303..1c2af52b9 100644
--- a/server/tests/helpers/factories/files.ts
+++ b/server/tests/helpers/factories/files.ts
@@ -17,14 +17,18 @@ export function makeTripFile(
overrides: EntityData<TripFiles> = {},
): Promise<TripFileRow> {
const n = nextSeq('trip-file');
- return createRow(orm, TripFiles, {
- trip: tripId,
- filename: `test-file-${n}.pdf`,
- original_name: `Test File ${n}.pdf`,
- file_size: 1024,
- mime_type: 'application/pdf',
- ...overrides,
- });
+ return createRow(
+ orm,
+ TripFiles,
+ {
+ trip: tripId,
+ filename: `test-file-${n}.pdf`,
+ original_name: `Test File ${n}.pdf`,
+ file_size: 1024,
+ mime_type: 'application/pdf',
+ },
+ overrides,
+ );
}
/** Links the file to a booking, an assignment, a place or an expense (name exactly one in `target`). */
diff --git a/server/tests/helpers/factories/journeys.ts b/server/tests/helpers/factories/journeys.ts
index 6e02d2168..9244ac877 100644
--- a/server/tests/helpers/factories/journeys.ts
+++ b/server/tests/helpers/factories/journeys.ts
@@ -20,15 +20,19 @@ export async function makeJourney(
overrides: EntityData<Journeys> = {},
): Promise<JourneyRow> {
const now = Date.now();
- const journey = await createRow(orm, Journeys, {
- user: userId,
- title: `Test Journey ${nextSeq('journey')}`,
- subtitle: null,
- status: 'active',
- created_at: now,
- updated_at: now,
- ...overrides,
- });
+ const journey = await createRow(
+ orm,
+ Journeys,
+ {
+ user: userId,
+ title: `Test Journey ${nextSeq('journey')}`,
+ subtitle: null,
+ status: 'active',
+ created_at: now,
+ updated_at: now,
+ },
+ overrides,
+ );
await insertRow(orm, JourneyContributors, { journey: journey.id, user: userId, role: 'owner', added_at: now });
return journey;
}
@@ -41,17 +45,21 @@ export function makeJourneyEntry(
overrides: EntityData<JourneyEntries> = {},
): Promise<JourneyEntryRow> {
const now = Date.now();
- return createRow(orm, JourneyEntries, {
- journey: journeyId,
- author: authorId,
- type: 'entry',
- entry_date: '2026-01-15',
- visibility: 'private',
- sort_order: 0,
- created_at: now,
- updated_at: now,
- ...overrides,
- });
+ return createRow(
+ orm,
+ JourneyEntries,
+ {
+ journey: journeyId,
+ author: authorId,
+ type: 'entry',
+ entry_date: '2026-01-15',
+ visibility: 'private',
+ sort_order: 0,
+ created_at: now,
+ updated_at: now,
+ },
+ overrides,
+ );
}
/** Adds the user as a contributor; an existing contributor keeps their role. */
diff --git a/server/tests/helpers/factories/notifications.ts b/server/tests/helpers/factories/notifications.ts
index 40afb5550..ba7b0df3d 100644
--- a/server/tests/helpers/factories/notifications.ts
+++ b/server/tests/helpers/factories/notifications.ts
@@ -13,16 +13,20 @@ export function makeNotification(
recipientId: number,
overrides: EntityData<Notifications> = {},
): Promise<NotificationRow> {
- return createRow(orm, Notifications, {
- recipient: recipientId,
- type: 'simple',
- scope: 'user',
- target: recipientId,
- title_key: 'notifications.test.title',
- text_key: 'notifications.test.text',
- is_read: 0,
- ...overrides,
- });
+ return createRow(
+ orm,
+ Notifications,
+ {
+ recipient: recipientId,
+ type: 'simple',
+ scope: 'user',
+ target: recipientId,
+ title_key: 'notifications.test.title',
+ text_key: 'notifications.test.text',
+ is_read: 0,
+ },
+ overrides,
+ );
}
/** Sets the instance's active notification channels ('email', 'webhook', 'email,webhook', 'none'). */
diff --git a/server/tests/helpers/factories/packing.ts b/server/tests/helpers/factories/packing.ts
index 72563175d..8ce9b5cb0 100644
--- a/server/tests/helpers/factories/packing.ts
+++ b/server/tests/helpers/factories/packing.ts
@@ -13,13 +13,17 @@ export function makePackingItem(
tripId: number,
overrides: EntityData<PackingItems> = {},
): Promise<PackingItemRow> {
- return createRow(orm, PackingItems, {
- trip: tripId,
- name: 'Test Item',
- category: 'Clothing',
- checked: 0,
- ...overrides,
- });
+ return createRow(
+ orm,
+ PackingItems,
+ {
+ trip: tripId,
+ name: 'Test Item',
+ category: 'Clothing',
+ checked: 0,
+ },
+ overrides,
+ );
}
/** A bag on the trip. */
@@ -28,11 +32,15 @@ export function makePackingBag(
tripId: number,
overrides: EntityData<PackingBags> = {},
): Promise<PackingBagRow> {
- return createRow(orm, PackingBags, {
- trip: tripId,
- name: `Bag ${nextSeq('packing-bag')}`,
- ...overrides,
- });
+ return createRow(
+ orm,
+ PackingBags,
+ {
+ trip: tripId,
+ name: `Bag ${nextSeq('packing-bag')}`,
+ },
+ overrides,
+ );
}
/** Shares the bag with the users; pairs that already exist are skipped. */
diff --git a/server/tests/helpers/factories/places.ts b/server/tests/helpers/factories/places.ts
index c5bf26fbf..914b0e0af 100644
--- a/server/tests/helpers/factories/places.ts
+++ b/server/tests/helpers/factories/places.ts
@@ -21,12 +21,16 @@ export function makeCategory(orm: FactoryOrm, overrides: EntityData<Categories>
/** A tag owned by `userId`. */
export function makeTag(orm: FactoryOrm, userId: number, overrides: EntityData<Tags> = {}): Promise<TagRow> {
- return createRow(orm, Tags, {
- user: userId,
- name: `Test Tag ${nextSeq('tag')}`,
- color: '#10b981',
- ...overrides,
- });
+ return createRow(
+ orm,
+ Tags,
+ {
+ user: userId,
+ name: `Test Tag ${nextSeq('tag')}`,
+ color: '#10b981',
+ },
+ overrides,
+ );
}
/** The lowest-id category, the one a place gets when the test names none. */
@@ -48,15 +52,19 @@ export async function makePlace(
overrides: EntityData<Places> = {},
): Promise<PlaceRow> {
const category = 'category' in overrides ? overrides.category : await firstCategoryId(orm);
- return createRow(orm, Places, {
- trip: tripId,
- name: 'Test Place',
- lat: 48.8566,
- lng: 2.3522,
- description: null,
- ...overrides,
- category,
- });
+ return createRow(
+ orm,
+ Places,
+ {
+ trip: tripId,
+ name: 'Test Place',
+ lat: 48.8566,
+ lng: 2.3522,
+ description: null,
+ category,
+ },
+ { ...overrides, category },
+ );
}
/** Puts the tags on the place; tags it already has are skipped. */
diff --git a/server/tests/helpers/factories/plugins.ts b/server/tests/helpers/factories/plugins.ts
index 00341d719..108d7bb22 100644
--- a/server/tests/helpers/factories/plugins.ts
+++ b/server/tests/helpers/factories/plugins.ts
@@ -14,7 +14,7 @@ export type PluginRow = EntityDTO<Plugins>;
* settings surface wants.
*/
export async function makePlugin(orm: FactoryOrm, id: string, overrides: EntityData<Plugins> = {}): Promise<PluginRow> {
- await insertRow(orm, Plugins, { id, name: id, version: '1.0.0', ...overrides });
+ await insertRow(orm, Plugins, { id, name: id, version: '1.0.0' }, overrides);
const plugin = await findRow(orm, Plugins, { id });
if (!plugin) throw new Error(`makePlugin: no plugin ${id} after its insert`);
return plugin;
@@ -27,12 +27,16 @@ export function makePluginSettingsField(
fieldKey: string,
overrides: EntityData<PluginSettingsFields> = {},
): Promise<EntityDTO<PluginSettingsFields>> {
- return createRow(orm, PluginSettingsFields, {
- plugin_id: pluginId,
- field_key: fieldKey,
- label: fieldKey,
- ...overrides,
- });
+ return createRow(
+ orm,
+ PluginSettingsFields,
+ {
+ plugin_id: pluginId,
+ field_key: fieldKey,
+ label: fieldKey,
+ },
+ overrides,
+ );
}
/** Stores the user's config for the plugin as JSON, replacing any earlier one. */
diff --git a/server/tests/helpers/factories/reservations.ts b/server/tests/helpers/factories/reservations.ts
index c839a2b05..61a1e0599 100644
--- a/server/tests/helpers/factories/reservations.ts
+++ b/server/tests/helpers/factories/reservations.ts
@@ -14,13 +14,17 @@ export function makeReservation(
tripId: number,
overrides: EntityData<Reservations> = {},
): Promise<ReservationRow> {
- return createRow(orm, Reservations, {
- trip: tripId,
- title: 'Test Reservation',
- type: 'flight',
- day: null,
- ...overrides,
- });
+ return createRow(
+ orm,
+ Reservations,
+ {
+ trip: tripId,
+ title: 'Test Reservation',
+ type: 'flight',
+ day: null,
+ },
+ overrides,
+ );
}
/**
@@ -32,16 +36,20 @@ export function makeReservationEndpoint(
reservationId: number,
overrides: EntityData<ReservationEndpoints> = {},
): Promise<ReservationEndpointRow> {
- return createRow(orm, ReservationEndpoints, {
- reservation: reservationId,
- role: 'from',
- sequence: 0,
- name: 'Paris Charles de Gaulle',
- code: 'CDG',
- lat: 49.0097,
- lng: 2.5479,
- ...overrides,
- });
+ return createRow(
+ orm,
+ ReservationEndpoints,
+ {
+ reservation: reservationId,
+ role: 'from',
+ sequence: 0,
+ name: 'Paris Charles de Gaulle',
+ code: 'CDG',
+ lat: 49.0097,
+ lng: 2.5479,
+ },
+ overrides,
+ );
}
/** Puts the user on the booking's traveller list. */
diff --git a/server/tests/helpers/factories/todos.ts b/server/tests/helpers/factories/todos.ts
index 16b3055fd..180903154 100644
--- a/server/tests/helpers/factories/todos.ts
+++ b/server/tests/helpers/factories/todos.ts
@@ -21,12 +21,16 @@ export async function makeTodoItem(
);
return last?.sort_order == null ? 0 : last.sort_order + 1;
}));
- return createRow(orm, TodoItems, {
- trip: tripId,
- name: 'Test Todo',
- checked: 0,
- category: null,
- ...overrides,
- sort_order: sortOrder,
- });
+ return createRow(
+ orm,
+ TodoItems,
+ {
+ trip: tripId,
+ name: 'Test Todo',
+ checked: 0,
+ category: null,
+ sort_order: sortOrder,
+ },
+ { ...overrides, sort_order: sortOrder },
+ );
}
diff --git a/server/tests/helpers/factories/tokens.ts b/server/tests/helpers/factories/tokens.ts
index 2485a43c3..670905571 100644
--- a/server/tests/helpers/factories/tokens.ts
+++ b/server/tests/helpers/factories/tokens.ts
@@ -65,11 +65,15 @@ export function makeInviteToken(
createdBy: number,
overrides: EntityData<InviteTokens> = {},
): Promise<EntityDTO<InviteTokens>> {
- return createRow(orm, InviteTokens, {
- token: `test-invite-${nextSeq('invite-token')}`,
- max_uses: 1,
- used_count: 0,
- createdByRef: createdBy,
- ...overrides,
- });
+ return createRow(
+ orm,
+ InviteTokens,
+ {
+ token: `test-invite-${nextSeq('invite-token')}`,
+ max_uses: 1,
+ used_count: 0,
+ createdByRef: createdBy,
+ },
+ overrides,
+ );
}
diff --git a/server/tests/helpers/factories/trips.ts b/server/tests/helpers/factories/trips.ts
index 1092f0f92..4788ec7fe 100644
--- a/server/tests/helpers/factories/trips.ts
+++ b/server/tests/helpers/factories/trips.ts
@@ -122,10 +122,14 @@ export function makeShareToken(
>
> = {},
): Promise<EntityDTO<ShareTokens>> {
- return createRow(orm, ShareTokens, {
- trip: tripId,
- createdByRef: createdBy,
- token: overrides.token ?? `share-${nextSeq('share-token')}-${tripId}`,
- ...overrides,
- });
+ return createRow(
+ orm,
+ ShareTokens,
+ {
+ trip: tripId,
+ createdByRef: createdBy,
+ token: overrides.token ?? `share-${nextSeq('share-token')}-${tripId}`,
+ },
+ overrides,
+ );
}
diff --git a/server/tests/helpers/factories/vacay.ts b/server/tests/helpers/factories/vacay.ts
index 839b06072..2d5063dab 100644
--- a/server/tests/helpers/factories/vacay.ts
+++ b/server/tests/helpers/factories/vacay.ts
@@ -13,7 +13,7 @@ export function makeVacayPlan(
ownerId: number,
overrides: EntityData<VacayPlans> = {},
): Promise<VacayPlanRow> {
- return createRow(orm, VacayPlans, { owner: ownerId, ...overrides });
+ return createRow(orm, VacayPlans, { owner: ownerId }, overrides);
}
/** Invites the user into the plan; `status: 'accepted'` (the default here) makes them a member. */
@@ -34,5 +34,5 @@ export function makeVacayEntry(
date: string,
overrides: EntityData<VacayEntries> = {},
): Promise<EntityDTO<VacayEntries>> {
- return createRow(orm, VacayEntries, { plan: planId, user: userId, date, ...overrides });
+ return createRow(orm, VacayEntries, { plan: planId, user: userId, date }, overrides);
}