mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
test: follow the qol sweep in the e2e schemas and the assertions it changed
The hand-written e2e schemas gain the new columns and place_regions, and the unit assertions take the new arguments and fields. The Public API page names GET /api/auth/app-config for the running version.
This commit is contained in:
@@ -34,7 +34,7 @@ const { db } = vi.hoisted(() => {
|
||||
tmp.exec(`CREATE TABLE day_assignments (id INTEGER PRIMARY KEY AUTOINCREMENT, day_id INTEGER NOT NULL,
|
||||
place_id INTEGER NOT NULL, order_index INTEGER NOT NULL DEFAULT 0, notes TEXT,
|
||||
assignment_time TEXT, assignment_end_time TEXT, leg_transport_mode TEXT,
|
||||
accommodation_id INTEGER,
|
||||
accommodation_id INTEGER, route_excluded INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT DEFAULT (datetime('now')));`);
|
||||
// The auto-sort reads a booked night's hour off its booking, so the table has to be
|
||||
// here even though nothing in this file books one.
|
||||
|
||||
@@ -37,6 +37,7 @@ const { db } = vi.hoisted(() => {
|
||||
is_private INTEGER NOT NULL DEFAULT 0,
|
||||
owner_id INTEGER,
|
||||
updated_at DATETIME,
|
||||
packed_quantity INTEGER,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);`);
|
||||
tmp.exec(`CREATE TABLE packing_bags (
|
||||
|
||||
@@ -41,8 +41,11 @@ const { db } = vi.hoisted(() => {
|
||||
tmp.exec('CREATE TABLE days (id INTEGER PRIMARY KEY AUTOINCREMENT, trip_id INTEGER NOT NULL, day_number INTEGER, date TEXT, title TEXT);');
|
||||
// The GPX export reads the trip title for <metadata> and the filename.
|
||||
tmp.exec('CREATE TABLE trips (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT);');
|
||||
// The places list reads each place's country and region (#2537).
|
||||
tmp.exec(`CREATE TABLE place_regions (place_id INTEGER PRIMARY KEY, country_code TEXT NOT NULL,
|
||||
region_code TEXT NOT NULL, region_name TEXT NOT NULL);`);
|
||||
tmp.exec(`CREATE TABLE day_assignments (id INTEGER PRIMARY KEY AUTOINCREMENT, day_id INTEGER NOT NULL,
|
||||
place_id INTEGER NOT NULL, order_index INTEGER DEFAULT 0);`);
|
||||
place_id INTEGER NOT NULL, order_index INTEGER DEFAULT 0, route_excluded INTEGER NOT NULL DEFAULT 0);`);
|
||||
// reclaimPlaceImage ref-counts an uploaded thumbnail across both tables.
|
||||
// Deleting a place cancels the nights booked at it (#2354), so the delete path
|
||||
// reads this table even in a file that never books one.
|
||||
|
||||
@@ -34,7 +34,7 @@ const { db } = vi.hoisted(() => {
|
||||
tmp.exec(`CREATE TABLE day_assignments (id INTEGER PRIMARY KEY AUTOINCREMENT, day_id INTEGER NOT NULL,
|
||||
place_id INTEGER NOT NULL, order_index INTEGER DEFAULT 0, notes TEXT, reservation_status TEXT,
|
||||
reservation_notes TEXT, reservation_datetime TEXT, assignment_time TEXT, assignment_end_time TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
route_excluded INTEGER NOT NULL DEFAULT 0, created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
tmp.exec(`CREATE TABLE day_notes (id INTEGER PRIMARY KEY AUTOINCREMENT, day_id INTEGER NOT NULL,
|
||||
trip_id INTEGER NOT NULL, text TEXT, time TEXT, icon TEXT, sort_order INTEGER DEFAULT 0,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
@@ -51,7 +51,7 @@ const { db } = vi.hoisted(() => {
|
||||
tmp.exec(`CREATE TABLE packing_items (id INTEGER PRIMARY KEY AUTOINCREMENT, trip_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL, checked INTEGER DEFAULT 0, category TEXT, sort_order INTEGER DEFAULT 0,
|
||||
weight_grams INTEGER, bag_id INTEGER, quantity INTEGER NOT NULL DEFAULT 1,
|
||||
is_private INTEGER NOT NULL DEFAULT 0, owner_id INTEGER, updated_at DATETIME,
|
||||
is_private INTEGER NOT NULL DEFAULT 0, owner_id INTEGER, updated_at DATETIME, packed_quantity INTEGER,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
tmp.exec(`CREATE TABLE packing_item_recipients (item_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (item_id, user_id));`);
|
||||
@@ -75,6 +75,9 @@ const { db } = vi.hoisted(() => {
|
||||
needs_review INTEGER DEFAULT 0, day_plan_position REAL, external_source TEXT, sync_enabled INTEGER,
|
||||
ingest_state TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
tmp.exec('CREATE TABLE days (id INTEGER PRIMARY KEY AUTOINCREMENT, trip_id INTEGER NOT NULL, day_number INTEGER, date TEXT);');
|
||||
// The places list reads each place's country and region (#2537).
|
||||
tmp.exec(`CREATE TABLE place_regions (place_id INTEGER PRIMARY KEY, country_code TEXT NOT NULL,
|
||||
region_code TEXT NOT NULL, region_name TEXT NOT NULL);`);
|
||||
tmp.exec(`CREATE TABLE places (id INTEGER PRIMARY KEY AUTOINCREMENT, trip_id INTEGER NOT NULL, name TEXT,
|
||||
image_url TEXT, address TEXT, lat REAL, lng REAL, category_id INTEGER, description TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
|
||||
|
||||
@@ -51,7 +51,7 @@ const { db } = vi.hoisted(() => {
|
||||
UNIQUE(user_id, plan_id, date));`);
|
||||
tmp.exec(`CREATE TABLE vacay_company_holidays (id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
plan_id INTEGER NOT NULL REFERENCES vacay_plans(id) ON DELETE CASCADE,
|
||||
date TEXT NOT NULL, note TEXT DEFAULT '', UNIQUE(plan_id, date));`);
|
||||
date TEXT NOT NULL, note TEXT DEFAULT '', fraction REAL NOT NULL DEFAULT 1, UNIQUE(plan_id, date));`);
|
||||
tmp.exec(`CREATE TABLE vacay_holiday_calendars (id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
plan_id INTEGER NOT NULL REFERENCES vacay_plans(id) ON DELETE CASCADE,
|
||||
type TEXT NOT NULL DEFAULT 'public_holiday', region TEXT NOT NULL, label TEXT,
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('Tool: clear_day_assignments (#2470)', () => {
|
||||
expect(data.success).toBe(true);
|
||||
expect([...data.removedIds].sort()).toEqual([a1.id, a2.id].sort());
|
||||
expect(testDb.prepare('SELECT COUNT(*) AS n FROM day_assignments WHERE day_id = ?').get(day.id)).toEqual({ n: 0 });
|
||||
expect(broadcastMock).toHaveBeenCalledWith(trip.id, 'assignment:deleted', { assignmentId: a1.id, dayId: day.id });
|
||||
expect(broadcastMock).toHaveBeenCalledWith(trip.id, 'assignment:deleted', expect.objectContaining({ assignmentId: a1.id, dayId: day.id }));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1223,9 +1223,9 @@ describe('applySettlementUpdate', () => {
|
||||
|
||||
const res = budget.applySettlementUpdate(7, 1, { from_user_id: 2, to_user_id: 1, amount: 10.126 });
|
||||
// from, to, rounded amount, currency-flag(0)/value(null), rate-flag(null)/value(1),
|
||||
// settled_at-flag(0)/value(null), id.
|
||||
// No currency/exchange_rate/settled_at passed → all three CASE guards keep the existing columns.
|
||||
expect(run).toHaveBeenCalledWith(2, 1, 10.13, 0, null, null, 1, 0, null, 7);
|
||||
// settled_at-flag(0)/value(null), note-flag(0)/value(null) (#2340), id.
|
||||
// No currency/exchange_rate/settled_at/note passed → every CASE guard keeps the existing column.
|
||||
expect(run).toHaveBeenCalledWith(2, 1, 10.13, 0, null, null, 1, 0, null, 0, null, 7);
|
||||
expect(res).toMatchObject({ id: 7, from_user_id: 2, to_user_id: 1, amount: 10.13 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -932,14 +932,15 @@ describe('MapsService: Amap first inside China when picked outright (#1636)', ()
|
||||
mockProviderGet.mockReturnValue({ value: 'amap' });
|
||||
keys({ amap: 'akey' });
|
||||
osmAnswers([]);
|
||||
const fetchSpy = vi.fn().mockResolvedValue(ok({ count: '0', pois: [] }));
|
||||
vi.stubGlobal('fetch', fetchSpy);
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(ok({ count: '0', pois: [] })));
|
||||
const searchText = vi.spyOn(AmapPlacesProvider.prototype, 'searchText');
|
||||
spies.push(searchText);
|
||||
|
||||
const result = await svc.searchPlaces(1, 'nothing here', 'zh', BEIJING);
|
||||
|
||||
expect(result).toEqual({ places: [], source: 'amap' });
|
||||
expect(trekPlacesSearch).toHaveBeenCalled();
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
||||
expect(searchText).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('AMAP-097: a search centred outside China keeps the usual order, so the Eiffel Tower does not land in Macau', async () => {
|
||||
|
||||
@@ -1514,7 +1514,7 @@ describe('getSharedCalendars', () => {
|
||||
|
||||
const calendars = svc.getSharedCalendars(viewer.id, '2025');
|
||||
|
||||
expect(calendars[0].companyHolidays).toEqual([{ date: '2025-12-24' }]);
|
||||
expect(calendars[0].companyHolidays).toEqual([{ date: '2025-12-24', fraction: 1 }]);
|
||||
});
|
||||
|
||||
it('VACAY-SVC-065: an owner without any plan yields empty arrays (no lazy creation)', () => {
|
||||
|
||||
@@ -236,7 +236,7 @@ describe('addon-gated domains validate their input', () => {
|
||||
const toggleCompanyHoliday = vi.fn(() => ({}));
|
||||
const host = build({ vacay: { toggleCompanyHoliday } });
|
||||
await host.dispatch(req('vacay.toggleCompanyHoliday', { date: '2027-01-01' }), 42);
|
||||
expect(toggleCompanyHoliday).toHaveBeenCalledWith(1, '2027-01-01', undefined, undefined);
|
||||
expect(toggleCompanyHoliday).toHaveBeenCalledWith(1, '2027-01-01', undefined, undefined, undefined);
|
||||
});
|
||||
|
||||
it('ADDONERR-010e a collab message without a replyTo passes null', async () => {
|
||||
|
||||
@@ -285,7 +285,7 @@ describe('every schema-validated method rejects a payload its schema refuses', (
|
||||
createTestPluginRegistry([new VacayRpc(vacay, guards), new TagsRpc(tags)]),
|
||||
);
|
||||
await host.dispatch(req('vacay.toggleCompanyHoliday', { date: '2027-01-01', note: 42 }), 42);
|
||||
expect(toggleCompanyHoliday).toHaveBeenCalledWith(1, '2027-01-01', undefined, undefined);
|
||||
expect(toggleCompanyHoliday).toHaveBeenCalledWith(1, '2027-01-01', undefined, undefined, undefined);
|
||||
await host.dispatch(req('tags.update', { tagId: 1, input: { name: 'kept' } }), 42);
|
||||
expect(update).toHaveBeenCalledWith(1, 'kept', undefined);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user