mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
fix(tours): fit the merged tracks together after integration
Types, test expectations and helpers the seven tracks each changed on their own, brought in line with the integrated code. tours.service.ts and the tours repository grew past the size limit with every track and hand their row and write helpers to modules of their own.
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
* Fixtures: user 1 owns trip 5 (two dated days, one without a date), user 2 is
|
||||
* a member, user 3 has no access.
|
||||
*/
|
||||
import { db } from '../../src/db/database';
|
||||
import { AssignmentParticipants } from '../../src/db/entities/AssignmentParticipants.entity';
|
||||
import { Days } from '../../src/db/entities/Days.entity';
|
||||
import { Places } from '../../src/db/entities/Places.entity';
|
||||
@@ -20,6 +19,7 @@ import { JourneyDomainService } from '../../src/nest/journey/journey-domain.serv
|
||||
import { RealtimeModule } from '../../src/nest/realtime/realtime.module';
|
||||
import { RealtimeService } from '../../src/nest/realtime/realtime.service';
|
||||
import { ToursModule } from '../../src/nest/tours/tours.module';
|
||||
import { createSnapshotTestDb } from '../helpers/db-mock';
|
||||
import { makeDayAssignment } from '../helpers/factories/itinerary';
|
||||
import { countRows, deleteRows, insertRow, insertRows } from '../helpers/factories/rows';
|
||||
import { setAddonEnabled } from '../helpers/factories/settings';
|
||||
@@ -36,10 +36,6 @@ import type { Server } from 'http';
|
||||
import request from 'supertest';
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('../../src/db/database', async () => {
|
||||
const { createSnapshotTestDb, buildDbMock } = await import('../helpers/db-mock');
|
||||
return buildDbMock(createSnapshotTestDb());
|
||||
});
|
||||
vi.mock('../../src/nest/audit/audit-log.logger', () => ({
|
||||
LOG_LEVEL: 'error',
|
||||
logInfo: vi.fn(),
|
||||
@@ -48,6 +44,7 @@ vi.mock('../../src/nest/audit/audit-log.logger', () => ({
|
||||
logWarn: vi.fn(),
|
||||
}));
|
||||
|
||||
const db = createSnapshotTestDb();
|
||||
const journeyHooks = {
|
||||
reconcileTripSkeletons: vi.fn().mockResolvedValue(undefined),
|
||||
onPlaceCreated: vi.fn().mockResolvedValue(undefined),
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
* Fixtures: user 1 owns trip 5 (two days), user 2 is a member whom the
|
||||
* permission spy denies 'place_edit', user 3 has no access.
|
||||
*/
|
||||
import { db } from '../../src/db/database';
|
||||
import { Days } from '../../src/db/entities/Days.entity';
|
||||
import { Places } from '../../src/db/entities/Places.entity';
|
||||
import { TourActivities } from '../../src/db/entities/TourActivities.entity';
|
||||
@@ -20,6 +19,7 @@ import { PermissionsService } from '../../src/nest/permissions/permissions.servi
|
||||
import { RealtimeModule } from '../../src/nest/realtime/realtime.module';
|
||||
import { RealtimeService } from '../../src/nest/realtime/realtime.service';
|
||||
import { ToursModule } from '../../src/nest/tours/tours.module';
|
||||
import { createSnapshotTestDb } from '../helpers/db-mock';
|
||||
import { makeDayAssignment } from '../helpers/factories/itinerary';
|
||||
import { countRows, deleteRows, findRow, insertRows } from '../helpers/factories/rows';
|
||||
import { setAddonEnabled } from '../helpers/factories/settings';
|
||||
@@ -36,10 +36,6 @@ import type { Server } from 'http';
|
||||
import request from 'supertest';
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';
|
||||
|
||||
vi.mock('../../src/db/database', async () => {
|
||||
const { createSnapshotTestDb, buildDbMock } = await import('../helpers/db-mock');
|
||||
return buildDbMock(createSnapshotTestDb());
|
||||
});
|
||||
vi.mock('../../src/nest/audit/audit-log.logger', () => ({
|
||||
LOG_LEVEL: 'error',
|
||||
logInfo: vi.fn(),
|
||||
@@ -48,6 +44,7 @@ vi.mock('../../src/nest/audit/audit-log.logger', () => ({
|
||||
logWarn: vi.fn(),
|
||||
}));
|
||||
|
||||
const db = createSnapshotTestDb();
|
||||
const journeyHooks = {
|
||||
reconcileTripSkeletons: vi.fn().mockResolvedValue(undefined),
|
||||
onPlaceCreated: vi.fn().mockResolvedValue(undefined),
|
||||
|
||||
@@ -325,7 +325,12 @@ describe('Horse tours e2e (real guards + temp SQLite)', () => {
|
||||
.field('tour_type', 'horse')
|
||||
.attach('file', Buffer.from(GPX), { filename: 'ride.gpx', contentType: 'application/gpx+xml' });
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body.tours[0]).toMatchObject({ tour_type: 'horse', origin: 'gpx', duration: null, bike_profile: null });
|
||||
expect(res.body.tours[0]).toMatchObject({
|
||||
tour_type: 'horse',
|
||||
origin: 'gpx',
|
||||
duration: null,
|
||||
bike_profile: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -172,7 +172,11 @@ describe('Runs e2e (real guards + temp SQLite)', () => {
|
||||
});
|
||||
const list = await request(server).get('/api/trips/5/tours').set('Cookie', sessionCookie(VIEWER));
|
||||
expect(list.status).toBe(200);
|
||||
expect(list.body.tours[0]).toMatchObject({ place_id: placeId, run_profile: 'running', run_pace_seconds_per_km: 360 });
|
||||
expect(list.body.tours[0]).toMatchObject({
|
||||
place_id: placeId,
|
||||
run_profile: 'running',
|
||||
run_pace_seconds_per_km: 360,
|
||||
});
|
||||
const detail = await request(server).get(`/api/trips/5/tours/${placeId}`).set('Cookie', sessionCookie(OWNER));
|
||||
expect(detail.body.tour).toMatchObject({ tour_type: 'run', run_profile: 'running', duration: 48 });
|
||||
expect(detail.body.waypoints).toHaveLength(2);
|
||||
|
||||
@@ -195,16 +195,17 @@ describe('Ski tracks e2e (real guards + temp SQLite)', () => {
|
||||
expect(opened.provenance).toMatchObject({ origin: 'gpx', source: { kind: 'gpx', fileName: 'hut.gpx' } });
|
||||
});
|
||||
|
||||
it('TOURS-SKI-E2E-002: a cross-country track keeps its technique, unknown included', async () => {
|
||||
for (const technique of ['classic', 'skating', 'unknown']) {
|
||||
it.each(['classic', 'skating', 'unknown'])(
|
||||
'TOURS-SKI-E2E-002: a cross-country track keeps its technique, unknown included: %s',
|
||||
async (technique) => {
|
||||
const placeId = await importSki({ ski_discipline: 'cross_country', ski_technique: technique });
|
||||
expect(await findRow(orm, Tours, { place: placeId })).toMatchObject({
|
||||
ski_discipline: 'cross_country',
|
||||
ski_technique: technique,
|
||||
});
|
||||
await deleteRows(orm, Places);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it('TOURS-SKI-E2E-003: refuses a ski import without its discipline or with a technique it has not, and ski fields on a hike', async () => {
|
||||
const refused = await Promise.all(
|
||||
|
||||
Reference in New Issue
Block a user