mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
fix(ci): the second round of the quick-win checks on the server
oidc_auto_redirect is managed-locked in the registry too, costs_mode is read as the mode it is, the days of a dated trip are read through the factories, and the dashboard's country order moves out of the atlas service into a module of its own, so the service keeps its size.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
import { db as testDb } from '../../../src/db/database';
|
||||
import { BudgetItems } from '../../../src/db/entities/BudgetItems.entity';
|
||||
import { Days } from '../../../src/db/entities/Days.entity';
|
||||
import { ShareTokens } from '../../../src/db/entities/ShareTokens.entity';
|
||||
import { TripMembers } from '../../../src/db/entities/TripMembers.entity';
|
||||
import { Trips } from '../../../src/db/entities/Trips.entity';
|
||||
@@ -15,7 +16,7 @@ import { NotificationsService } from '../../../src/nest/notifications/notificati
|
||||
import { invalidatePermissionsCache } from '../../../src/nest/permissions/permissions-cache';
|
||||
import { createUser, createAdmin, createTrip, addTripMember, createDayNote } from '../../helpers/factories';
|
||||
import { addBudgetItemMember, addBudgetItemPayer, makeBudgetItem } from '../../helpers/factories/budget';
|
||||
import { countRows, findRow, updateRows } from '../../helpers/factories/rows';
|
||||
import { countRows, findRow, findRows, updateRows } from '../../helpers/factories/rows';
|
||||
import { setAppSetting } from '../../helpers/factories/settings';
|
||||
import { makeShareToken } from '../../helpers/factories/trips';
|
||||
import { FakeRealtimeService } from '../../helpers/fake-realtime';
|
||||
@@ -496,9 +497,7 @@ describe('Tool: export_trip_ics', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Paris Trip', start_date: '2025-06-01', end_date: '2025-06-05' });
|
||||
// A dated trip comes with its days; the first one is the 1st of June.
|
||||
const day = testDb.prepare('SELECT id FROM days WHERE trip_id = ? AND day_number = 1').get(trip.id) as {
|
||||
id: number;
|
||||
};
|
||||
const [day] = await findRows(orm, Days, { trip: trip.id }, { id: 'asc' });
|
||||
createDayNote(testDb, day.id, trip.id, { text: 'Pick up the museum pass' });
|
||||
await withHarness(user.id, async (h) => {
|
||||
const call = async (args: Record<string, unknown>) =>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// The dashboard's order of visited countries (#2648).
|
||||
import { CountryVisits, latestPerCoordinate } from '../../../src/nest/atlas/atlas-visit-order';
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('CountryVisits', () => {
|
||||
it('ATLAS-ORDER-001: puts the latest reached country first and the hand-marked ones after', () => {
|
||||
const visits = new CountryVisits();
|
||||
visits.note('pt', '2025-04-10');
|
||||
visits.note('JP', '2026-05-02');
|
||||
visits.note('pt', '2026-01-20');
|
||||
visits.note(null, '2026-09-01');
|
||||
expect(visits.ordered(['IS', 'JP'])).toEqual(['JP', 'PT', 'IS']);
|
||||
});
|
||||
|
||||
it('ATLAS-ORDER-002: keeps the order a country of one trip was found in', () => {
|
||||
const visits = new CountryVisits();
|
||||
visits.note('FR', '2026-03-01');
|
||||
visits.note('ES', '2026-03-01');
|
||||
visits.note('IT', null);
|
||||
expect(visits.ordered([])).toEqual(['FR', 'ES', 'IT']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('latestPerCoordinate', () => {
|
||||
it('ATLAS-ORDER-003: keeps one row per coordinate, the one of the latest trip', () => {
|
||||
const rows = [
|
||||
{ id: 1, lat: 1, lng: 2, trip_last_date: '2025-01-01' },
|
||||
{ id: 2, lat: 1, lng: 2, trip_last_date: '2026-01-01' },
|
||||
{ id: 3, lat: 3, lng: 4, trip_last_date: null },
|
||||
];
|
||||
expect(latestPerCoordinate(rows).map((r) => r.id)).toEqual([2, 3]);
|
||||
});
|
||||
});
|
||||
@@ -1687,7 +1687,7 @@ describe('per-day summaries (#2602)', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Lisbon', start_date: '2025-06-02', end_date: '2025-06-03' });
|
||||
// A dated trip comes with its days; the first one is the 2nd of June.
|
||||
const day = testDb.prepare('SELECT id FROM days WHERE trip_id = ? AND day_number = 1').get(trip.id) as { id: number };
|
||||
const [day] = await findRows(orm, Days, { trip: trip.id }, { id: 'asc' });
|
||||
const untimed = createPlace(testDb, trip.id, { name: 'Untimed Spot' });
|
||||
createDayAssignment(testDb, day.id, untimed.id);
|
||||
createDayNote(testDb, day.id, trip.id, { text: 'Buy tram tickets' });
|
||||
|
||||
Reference in New Issue
Block a user