mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
fix(tours): a tour import takes over a track imported before Tours
A GPX track imported in 4.x is a plain place: a line, no tours row. It never showed under Tours, and importing the same file there was refused as a duplicate by its name, so there was no way to turn it into a tour (#2810). The tour import now takes over a track of the trip that has the same name and is no tour yet: the place keeps its name and line and gets the tours row, with the recorded times the file adds. The preview says so instead of "Already in the trip". New and taken-over tracks commit in one transaction.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-GPX-PREVIEW-001 to FE-GPX-PREVIEW-003
|
||||
// FE-GPX-PREVIEW-001 to FE-GPX-PREVIEW-004
|
||||
// The GPX preview as ACT-01 uses it: preset to the tour's type, a city walk
|
||||
// imported as one, and when a track was recorded shown where it carried times.
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
@@ -47,6 +47,13 @@ describe('TourGpxPreviewDialog (ACT-01)', () => {
|
||||
expect(recorded[0]).toHaveTextContent('50 min');
|
||||
});
|
||||
|
||||
it('FE-GPX-PREVIEW-004: a track taken over from before Tours reads as one, not as a duplicate (#2810)', () => {
|
||||
render(<TourGpxPreviewDialog gpxImport={gpxImport([track({ adopts_track: true })])} />);
|
||||
expect(screen.getByTestId('gpx-preview-track')).not.toHaveAttribute('data-duplicate');
|
||||
expect(screen.getByText(/tours\.import\.previewAdopts|becomes a tour/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/tours\.import\.previewDuplicate|Already in the trip/)).toBeNull();
|
||||
});
|
||||
|
||||
it('FE-GPX-PREVIEW-002: imports as the preset type, a paddle tour with its boat and water', () => {
|
||||
const current = gpxImport([track()]);
|
||||
render(
|
||||
|
||||
@@ -79,6 +79,7 @@ function PreviewTrackRow({
|
||||
{track.name || name}
|
||||
</span>
|
||||
{track.duplicate && <SoftPill tone="warning">{t('tours.import.previewDuplicate')}</SoftPill>}
|
||||
{track.adopts_track && <SoftPill>{t('tours.import.previewAdopts')}</SoftPill>}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-1.5 ps-8" style={fs(11)}>
|
||||
<span className={BADGE}>{formatDistance(track.distance_km, unit)}</span>
|
||||
|
||||
@@ -318,6 +318,21 @@ export class PlacesRepository extends TrekRepository<Places> {
|
||||
return !!row;
|
||||
}
|
||||
|
||||
/**
|
||||
* The trip's tracks that are not tours: places with `route_geometry` and no
|
||||
* `tours` row, oldest first. A GPX file imported before Tours existed (4.x)
|
||||
* left its tracks like this, and the tour import takes one over by name
|
||||
* instead of refusing it as a duplicate (#2810).
|
||||
*/
|
||||
async listTracksWithoutTour(trip_id: number | string): Promise<{ id: number; name: string; route_geometry: string }[]> {
|
||||
return this.qb('p')
|
||||
.leftJoin('p.tours', 't')
|
||||
.select(['p.id', 'p.name', 'p.route_geometry'])
|
||||
.where('p.trip_id = ? AND p.route_geometry IS NOT NULL AND t.place_id IS NULL', [trip_id])
|
||||
.orderBy({ 'p.id': 'asc' })
|
||||
.execute<{ id: number; name: string; route_geometry: string }[]>('all', false);
|
||||
}
|
||||
|
||||
/** PL19/PL21 — `DELETE FROM places WHERE id = ?`, unscoped: every caller proved trip access first. */
|
||||
async deleteById(id: number): Promise<void> {
|
||||
await this.nativeDelete({ id });
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from 'node:path';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { resolveCountryCodeSync } from '../atlas/atlas-geo';
|
||||
import { TRACK_COLORS, placeMatchStrategies, type PlaceMatchCandidate } from '@trek/shared';
|
||||
import { TRACK_COLORS, normalizePlaceName, placeMatchStrategies, type PlaceMatchCandidate } from '@trek/shared';
|
||||
import type { TrekWsPayload, TrekWsTripEventName } from '@trek/shared';
|
||||
import { RealtimeService } from '../realtime/realtime.service';
|
||||
import type { TripAccess } from '../../db/repositories/Trips.repository';
|
||||
@@ -765,6 +765,28 @@ export class PlacesService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The rows of a tour import that take over a track already in the trip,
|
||||
* by row index: a place with a track and no tour yet, under the same name,
|
||||
* one place per row. A GPX file imported before Tours existed (4.x) left
|
||||
* its tracks as plain places, and the name alone made every tour import of
|
||||
* the same file a duplicate with no tour to show for it (#2810).
|
||||
*/
|
||||
async tracksToAdopt(tripId: string, rows: PreparedGpxPlace[]): Promise<Map<number, { id: number; route_geometry: string }>> {
|
||||
const byName = new Map<string, { id: number; route_geometry: string }[]>();
|
||||
for (const track of await this.placesRepo.listTracksWithoutTour(tripId)) {
|
||||
const key = normalizePlaceName(track.name);
|
||||
if (key) byName.set(key, [...(byName.get(key) ?? []), track]);
|
||||
}
|
||||
const adopt = new Map<number, { id: number; route_geometry: string }>();
|
||||
rows.forEach((row, index) => {
|
||||
const key = normalizePlaceName(row.name);
|
||||
const track = key ? byName.get(key)?.shift() : undefined;
|
||||
if (track) adopt.set(index, track);
|
||||
});
|
||||
return adopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the place on this trip that `candidate` already is, or null.
|
||||
*
|
||||
|
||||
@@ -70,7 +70,10 @@ export function activityFacts(
|
||||
}
|
||||
|
||||
/** The times an import stores for a track, as the DATETIME columns hold them; NULL without. */
|
||||
function storedTimes(row: PreparedGpxPlace | undefined): { started: DbTimestamp | null; ended: DbTimestamp | null } {
|
||||
export function recordedTimesOf(row: PreparedGpxPlace | undefined): {
|
||||
started: DbTimestamp | null;
|
||||
ended: DbTimestamp | null;
|
||||
} {
|
||||
const times = row?.trackTimes;
|
||||
return times
|
||||
? { started: dbNow(new Date(times.startedAt)), ended: dbNow(new Date(times.endedAt)) }
|
||||
@@ -93,7 +96,7 @@ export function trackTimesFor(
|
||||
(row, at) => !taken.has(at) && row.name === place.name && row.lat === place.lat && row.lng === place.lng,
|
||||
);
|
||||
if (index >= 0) taken.add(index);
|
||||
byPlace.set(place.id, storedTimes(rows[index]));
|
||||
byPlace.set(place.id, recordedTimesOf(rows[index]));
|
||||
}
|
||||
return byPlace;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { toRowId } from '../common/row-id';
|
||||
import { UnitOfWork } from '../database/unit-of-work';
|
||||
import { PlaceImportService } from '../place-import/place-import.service';
|
||||
import { PlacesService } from '../places/places.service';
|
||||
import { toActivity, trackTimesFor } from './tour-activities.helpers';
|
||||
import { recordedTimesOf, toActivity, trackTimesFor } from './tour-activities.helpers';
|
||||
import {
|
||||
copiedFacet,
|
||||
copyStart,
|
||||
@@ -58,6 +58,30 @@ import {
|
||||
wandererDifficultyToSac,
|
||||
} from '@trek/shared';
|
||||
|
||||
/** `fn` over `items` one after the other, in order: the writes of one import share a transaction. */
|
||||
async function inOrder<T, R>(items: readonly T[], fn: (item: T) => Promise<R>): Promise<R[]> {
|
||||
return items.reduce<Promise<R[]>>(async (done, item) => [...(await done), await fn(item)], Promise.resolve([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* What the type adds to each tour a file import makes: a bike tour and a run
|
||||
* their profile, a paddle tour its boat and water, a ski track its discipline
|
||||
* and technique (SKI-02). A run comes in without a pace and a ski track
|
||||
* without a time: neither is worked out for them, so they stay unknown.
|
||||
*/
|
||||
function importedTypeFields(fields: TourGpxImportFields) {
|
||||
return {
|
||||
bike_profile: fields.bike_profile ?? null,
|
||||
run_profile: fields.run_profile ?? null,
|
||||
run_pace_seconds_per_km: null,
|
||||
ski_discipline: fields.ski_discipline ?? null,
|
||||
ski_technique: fields.ski_technique ?? null,
|
||||
boat_type: fields.boat_type ?? null,
|
||||
water_context: fields.water_context ?? null,
|
||||
paddle_speed_kmh: null,
|
||||
};
|
||||
}
|
||||
|
||||
export interface ImportGpxAsTourResult {
|
||||
tours: TourListItem[];
|
||||
caution: boolean;
|
||||
@@ -783,88 +807,38 @@ export class ToursService {
|
||||
const { rows } = await readTourFile(this.placeImport, fileBuffer, fileName);
|
||||
if (rows.length === 0) return null;
|
||||
await this.assertTourTypeEnabled(fields.tour_type);
|
||||
// What the type adds to each imported tour: a bike tour and a run their profile, a paddle tour its boat and water,
|
||||
// a ski track its discipline and technique (SKI-02). A run comes in without a pace and a ski track without a
|
||||
// time: neither is worked out for them, so they stay unknown.
|
||||
const typeFields = {
|
||||
bike_profile: fields.bike_profile ?? null,
|
||||
run_profile: fields.run_profile ?? null,
|
||||
run_pace_seconds_per_km: null,
|
||||
ski_discipline: fields.ski_discipline ?? null,
|
||||
ski_technique: fields.ski_technique ?? null,
|
||||
boat_type: fields.boat_type ?? null,
|
||||
water_context: fields.water_context ?? null,
|
||||
paddle_speed_kmh: null,
|
||||
};
|
||||
const typeFields = importedTypeFields(fields);
|
||||
|
||||
const adopt = await this.places.tracksToAdopt(tripId, rows);
|
||||
const fresh = rows.filter((_, index) => !adopt.has(index));
|
||||
const tours: TourListItem[] = [];
|
||||
const adopted: number[] = [];
|
||||
const result = await this.uow.transactional(async () => {
|
||||
// A nested transactional, so the places and their facets commit together.
|
||||
const imported = await this.places.importPreparedGpx(tripId, rows);
|
||||
const times = trackTimesFor(rows, imported.places);
|
||||
for (const place of imported.places) {
|
||||
const recorded = times.get(place.id);
|
||||
const metrics = computeTourMetrics(parseRouteGeometry(place.route_geometry));
|
||||
const matchConfidence = metrics.hasElevation ? 1 : 0.3;
|
||||
await this.toursRepo.insertTour({
|
||||
place_id: place.id,
|
||||
tour_type: fields.tour_type,
|
||||
...typeFields,
|
||||
distance: metrics.distanceKm,
|
||||
elevation_gain: metrics.elevationGainM,
|
||||
elevation_loss: metrics.elevationLossM,
|
||||
duration: null,
|
||||
planned_duration_minutes: null,
|
||||
break_additional_minutes: null,
|
||||
match_confidence: matchConfidence,
|
||||
max_hiking_difficulty: null,
|
||||
origin: 'gpx',
|
||||
origin_file_name: importFileName(fileName),
|
||||
track_started_at: recorded?.started ?? null,
|
||||
track_ended_at: recorded?.ended ?? null,
|
||||
});
|
||||
tours.push(
|
||||
tourItemOf({
|
||||
place_id: place.id,
|
||||
name: place.name,
|
||||
description: place.description ?? null,
|
||||
website: place.website ?? null,
|
||||
tour_type: fields.tour_type,
|
||||
...typeFields,
|
||||
distance: metrics.distanceKm,
|
||||
elevation_gain: metrics.elevationGainM,
|
||||
elevation_loss: metrics.elevationLossM,
|
||||
duration: null,
|
||||
planned_duration_minutes: null,
|
||||
break_additional_minutes: null,
|
||||
difficulty: null,
|
||||
wanderer_ref: null,
|
||||
match_confidence: matchConfidence,
|
||||
max_hiking_difficulty: null,
|
||||
derived_from_place_id: null,
|
||||
origin: 'gpx',
|
||||
portage_speed_kmh: null,
|
||||
paddle_lake_style: null,
|
||||
track_marks: null,
|
||||
has_recorded_track: 0,
|
||||
planned: 0,
|
||||
has_waypoints: 0,
|
||||
stage_ends: 0,
|
||||
route_missing: 0,
|
||||
revision: 1,
|
||||
hiking_preferences: null,
|
||||
track_started_at: recorded?.started ?? null,
|
||||
track_ended_at: recorded?.ended ?? null,
|
||||
}),
|
||||
);
|
||||
}
|
||||
const imported =
|
||||
fresh.length > 0 ? await this.places.importPreparedGpx(tripId, fresh) : { places: [], count: 0, skipped: 0 };
|
||||
const times = trackTimesFor(fresh, imported.places);
|
||||
tours.push(
|
||||
...(await inOrder(imported.places, (place) =>
|
||||
this.insertImportedTour(place, place.route_geometry ?? null, times.get(place.id), fields, typeFields, fileName),
|
||||
)),
|
||||
);
|
||||
// A track from before Tours keeps its place and its line and becomes the
|
||||
// tour; the file adds the recorded times 4.x never stored.
|
||||
await inOrder([...adopt], async ([index, track]) => {
|
||||
const place = await this.places.get(tripId, String(track.id));
|
||||
if (!place) return;
|
||||
const recorded = recordedTimesOf(rows[index]);
|
||||
tours.push(await this.insertImportedTour(place, track.route_geometry, recorded, fields, typeFields, fileName));
|
||||
adopted.push(place.id);
|
||||
});
|
||||
return imported;
|
||||
});
|
||||
|
||||
if (result.places.length === 0) return { tours: [], caution: false, skipped: result.skipped };
|
||||
if (tours.length === 0) return { tours: [], caution: false, skipped: result.skipped };
|
||||
this.broadcastToursChanged(
|
||||
tripId,
|
||||
result.places.map((place) => place.id),
|
||||
tours.map((tour) => tour.place_id),
|
||||
socketId,
|
||||
);
|
||||
for (const place of result.places) {
|
||||
@@ -874,9 +848,85 @@ export class ToursService {
|
||||
this.logger.warn(`Committed GPX place ${place.id}: realtime notification failed`);
|
||||
}
|
||||
}
|
||||
// The taken-over places now read as tours; the other clients get the row again.
|
||||
await inOrder(adopted, async (id) => {
|
||||
try {
|
||||
const place = await this.places.get(tripId, String(id));
|
||||
if (place) this.places.broadcast(tripId, 'place:updated', { place }, socketId);
|
||||
} catch {
|
||||
this.logger.warn(`Committed GPX tour on place ${id}: realtime notification failed`);
|
||||
}
|
||||
});
|
||||
return { tours, caution: tours.some((t) => t.caution), skipped: result.skipped };
|
||||
}
|
||||
|
||||
/**
|
||||
* The `tours` row for one place of a GPX import, with its metrics read off
|
||||
* `geometry` and the recorded times, and the list item the import answers
|
||||
* with. A new place and a track taken over from before Tours (#2810) get the
|
||||
* same row.
|
||||
*/
|
||||
private async insertImportedTour(
|
||||
place: { id: number; name: string; description?: string | null; website?: string | null },
|
||||
geometry: string | null,
|
||||
recorded: ReturnType<typeof recordedTimesOf> | undefined,
|
||||
fields: TourGpxImportFields,
|
||||
typeFields: ReturnType<typeof importedTypeFields>,
|
||||
fileName: string | undefined,
|
||||
): Promise<TourListItem> {
|
||||
const metrics = computeTourMetrics(parseRouteGeometry(geometry));
|
||||
const matchConfidence = metrics.hasElevation ? 1 : 0.3;
|
||||
await this.toursRepo.insertTour({
|
||||
place_id: place.id,
|
||||
tour_type: fields.tour_type,
|
||||
...typeFields,
|
||||
distance: metrics.distanceKm,
|
||||
elevation_gain: metrics.elevationGainM,
|
||||
elevation_loss: metrics.elevationLossM,
|
||||
duration: null,
|
||||
planned_duration_minutes: null,
|
||||
break_additional_minutes: null,
|
||||
match_confidence: matchConfidence,
|
||||
max_hiking_difficulty: null,
|
||||
origin: 'gpx',
|
||||
origin_file_name: importFileName(fileName),
|
||||
track_started_at: recorded?.started ?? null,
|
||||
track_ended_at: recorded?.ended ?? null,
|
||||
});
|
||||
return tourItemOf({
|
||||
place_id: place.id,
|
||||
name: place.name,
|
||||
description: place.description ?? null,
|
||||
website: place.website ?? null,
|
||||
tour_type: fields.tour_type,
|
||||
...typeFields,
|
||||
distance: metrics.distanceKm,
|
||||
elevation_gain: metrics.elevationGainM,
|
||||
elevation_loss: metrics.elevationLossM,
|
||||
duration: null,
|
||||
planned_duration_minutes: null,
|
||||
break_additional_minutes: null,
|
||||
difficulty: null,
|
||||
wanderer_ref: null,
|
||||
match_confidence: matchConfidence,
|
||||
max_hiking_difficulty: null,
|
||||
derived_from_place_id: null,
|
||||
origin: 'gpx',
|
||||
portage_speed_kmh: null,
|
||||
paddle_lake_style: null,
|
||||
track_marks: null,
|
||||
has_recorded_track: 0,
|
||||
planned: 0,
|
||||
has_waypoints: 0,
|
||||
stage_ends: 0,
|
||||
route_missing: 0,
|
||||
revision: 1,
|
||||
hiking_preferences: null,
|
||||
track_started_at: recorded?.started ?? null,
|
||||
track_ended_at: recorded?.ended ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* PAD-02: what a file would import, read with the import's own parser and
|
||||
* duplicate rule and written nowhere. Null when the file holds no track or
|
||||
@@ -887,6 +937,7 @@ export class ToursService {
|
||||
const { rows, leftOut } = await readTourFile(this.placeImport, fileBuffer, fileName);
|
||||
if (rows.length === 0) return null;
|
||||
const duplicates = await this.places.gpxDuplicates(tripId, rows);
|
||||
const adopt = await this.places.tracksToAdopt(tripId, rows);
|
||||
return {
|
||||
tracks: rows.map((row, index) => {
|
||||
const geometry = parseRouteGeometry(row.routeGeometry);
|
||||
@@ -900,7 +951,8 @@ export class ToursService {
|
||||
elevation_loss_m: metrics.elevationLossM,
|
||||
started_at: row.trackTimes?.startedAt ?? null,
|
||||
ended_at: row.trackTimes?.endedAt ?? null,
|
||||
duplicate: duplicates[index] ?? false,
|
||||
duplicate: !adopt.has(index) && (duplicates[index] ?? false),
|
||||
...(adopt.has(index) ? { adopts_track: true } : {}),
|
||||
};
|
||||
}),
|
||||
...(leftOut ? { left_out: leftOut } : {}),
|
||||
|
||||
@@ -535,6 +535,36 @@ describe('Tours e2e (real guards + temp SQLite)', () => {
|
||||
expect(await countRows(orm, Tours)).toBe(1);
|
||||
});
|
||||
|
||||
it('takes over a track from before Tours with the same name instead of skipping it (#2810)', async () => {
|
||||
// 4.x stored a GPX track as a plain place: a line, no tours row.
|
||||
const line = '[[49,12,100],[49.01,12.01,150],[49.02,12.02,120]]';
|
||||
const legacy = (await makePlace(orm, 5, { name: 'Alpine Loop ', lat: 49, lng: 12, route_geometry: line })).id;
|
||||
const elsewhere = (await makePlace(orm, 6, { name: 'Alpine loop', lat: 49, lng: 12, route_geometry: line })).id;
|
||||
|
||||
const preview = await previewGpx(OWNER, TRACK_GPX);
|
||||
expect(preview.status).toBe(200);
|
||||
expect(preview.body.tracks[0]).toMatchObject({ duplicate: false, adopts_track: true });
|
||||
expect(await countRows(orm, Tours)).toBe(0);
|
||||
|
||||
const res = await importGpx(OWNER, TRACK_GPX);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body).toMatchObject({ caution: false, skipped: 0 });
|
||||
expect(res.body.tours.map((tour: { place_id: number }) => tour.place_id)).toEqual([legacy]);
|
||||
expect(await countRows(orm, Places, { trip: 5 })).toBe(1);
|
||||
expect(await placeColumns(legacy, 'name', 'route_geometry')).toEqual({
|
||||
name: 'Alpine Loop ',
|
||||
route_geometry: line,
|
||||
});
|
||||
expect(await findRow(orm, Tours, { place: legacy })).toMatchObject({ tour_type: 'hike', origin: 'gpx' });
|
||||
expect(await findRow(orm, Tours, { place: elsewhere })).toBeNull();
|
||||
expect(broadcast.mock.calls.map((c) => c[1])).toEqual(expect.arrayContaining(['tours:changed', 'place:updated']));
|
||||
expect(broadcast.mock.calls.map((c) => c[1])).not.toContain('place:created');
|
||||
|
||||
// Now a tour, the same file is a duplicate again.
|
||||
expect((await previewGpx(OWNER, TRACK_GPX)).body.tracks[0]).toMatchObject({ duplicate: true });
|
||||
expect((await importGpx(OWNER, TRACK_GPX)).body).toEqual({ tours: [], caution: false, skipped: 1 });
|
||||
});
|
||||
|
||||
it('400 without a file, and for a file with no track or route', async () => {
|
||||
const missing = await importGpx(OWNER, null);
|
||||
expect(missing.status).toBe(400);
|
||||
|
||||
@@ -1587,4 +1587,27 @@ describe('PlacesRepository.isTour / listForTrip tour_place_id', () => {
|
||||
expect(byId.get(tour.id)).toBe(tour.id);
|
||||
expect(byId.get(plain.id)).toBeNull();
|
||||
});
|
||||
|
||||
it("PLACEREPO-TOUR-005: listTracksWithoutTour lists the trip's tracks that are no tour yet, oldest first (#2810)", async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const other = createTrip(testDb, user.id);
|
||||
const line = '[[49,12,100],[49.01,12.01,150]]';
|
||||
const track = (tripId: number, name: string) => {
|
||||
const place = createPlace(testDb, tripId, { name });
|
||||
testDb.prepare('UPDATE places SET route_geometry = ? WHERE id = ?').run(line, place.id);
|
||||
return place;
|
||||
};
|
||||
const first = track(trip.id, 'Garmin hike');
|
||||
const second = track(trip.id, 'Garmin hike');
|
||||
const toured = track(trip.id, 'Ridge walk');
|
||||
createTour(testDb, toured.id);
|
||||
createPlace(testDb, trip.id, { name: 'Cafe' });
|
||||
track(other.id, 'Garmin hike');
|
||||
|
||||
expect(await places.listTracksWithoutTour(trip.id)).toEqual([
|
||||
{ id: first.id, name: 'Garmin hike', route_geometry: line },
|
||||
{ id: second.id, name: 'Garmin hike', route_geometry: line },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1385,6 +1385,24 @@ describe('searchImage', () => {
|
||||
// ── Import deduplication ──────────────────────────────────────────────────────
|
||||
|
||||
describe('importGpx deduplication', () => {
|
||||
it('PLACE-SVC-033b — tracksToAdopt pairs each named row with one track of that name that is no tour (#2810)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const line = '[[46.1,11.1,1200],[46.2,11.2,1300]]';
|
||||
const ids = ['Garmin Hike', 'garmin hike ', ' '].map((name) => {
|
||||
const id = createPlace(testDb, trip.id, { name }).id;
|
||||
testDb.prepare('UPDATE places SET route_geometry = ? WHERE id = ?').run(line, id);
|
||||
return id;
|
||||
});
|
||||
const row = (name: string) => ({ name, lat: 46.1, lng: 11.1, routeGeometry: line }) as any;
|
||||
|
||||
const adopt = await svc.tracksToAdopt(String(trip.id), [row('GARMIN HIKE'), row(''), row('Garmin hike'), row('garmin hike')]);
|
||||
expect([...adopt.entries()]).toEqual([
|
||||
[0, { id: ids[0], route_geometry: line }],
|
||||
[2, { id: ids[1], route_geometry: line }],
|
||||
]);
|
||||
});
|
||||
|
||||
it('PLACE-SVC-033 — skips waypoints already in trip by name', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
|
||||
@@ -27,7 +27,7 @@ import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
|
||||
import { ToursService } from '../../../src/nest/tours/tours.service';
|
||||
import { UnsplashService } from '../../../src/nest/unsplash/unsplash.service';
|
||||
import { accommodationsOver } from '../../helpers/accommodations-service';
|
||||
import { createTrip, createUser } from '../../helpers/factories';
|
||||
import { createPlace, createTrip, createUser } from '../../helpers/factories';
|
||||
import { countRows, findRows } from '../../helpers/factories/rows';
|
||||
import { noPaddleChecks } from '../../helpers/fake-paddle-checks';
|
||||
import { tourStageDays } from '../../helpers/fake-tour-stage-days';
|
||||
@@ -86,7 +86,7 @@ const mixedGpx = Buffer.from(`<gpx>
|
||||
</trkseg><trkseg><trkpt lat="49.02" lon="12.02"><ele>120</ele></trkpt></trkseg></trk>
|
||||
</gpx>`);
|
||||
|
||||
const TRIGGERS = ['fail_facet', 'fail_place', 'fail_color'];
|
||||
const TRIGGERS = ['fail_facet', 'fail_place', 'fail_color', 'fail_adopt'];
|
||||
|
||||
/** The collaborator set the container hands PlacesService (the places.service.test.ts builder). */
|
||||
async function makePlacesService(): Promise<PlacesService> {
|
||||
@@ -314,6 +314,16 @@ describe('Tours GPX atomic persistence and postcommit publication', () => {
|
||||
await expectEmpty();
|
||||
});
|
||||
|
||||
it('rolls the new places back too when taking over a track from before Tours fails (#2810)', async () => {
|
||||
const legacy = createPlace(testDb, Number(tripId), { name: 'Ridge' }).id;
|
||||
testDb.prepare('UPDATE places SET route_geometry = ? WHERE id = ?').run('[[49,12,100],[49.01,12.01,150]]', legacy);
|
||||
testDb.exec(`CREATE TRIGGER fail_adopt BEFORE INSERT ON tours WHEN NEW.place_id = ${legacy}
|
||||
BEGIN SELECT RAISE(ABORT, 'adopt failure'); END;`);
|
||||
await expect(tours.importGpxAsTour(tripId, mixedGpx)).rejects.toThrow('adopt failure');
|
||||
expect(await Promise.all([count('places'), count('tours')])).toEqual([1, 0]);
|
||||
expect(broadcast).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('rolls back carriers and earlier colors when later coloring fails', async () => {
|
||||
testDb.exec(`CREATE TRIGGER fail_color BEFORE UPDATE OF route_color ON places WHEN NEW.name = 'Ridge'
|
||||
BEGIN SELECT RAISE(ABORT, 'color failure'); END;`);
|
||||
|
||||
@@ -969,6 +969,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'لم يُعثر على ملف KML في {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} كبير جدًا بعد فك الضغط',
|
||||
'tours.import.previewDuplicate': 'موجود بالفعل في الرحلة',
|
||||
'tours.import.previewAdopts': 'مسار موجود في الرحلة، سيصبح جولة',
|
||||
'tours.import.previewAllDuplicates': 'كل المسارات موجودة بالفعل في الرحلة، فلا شيء للاستيراد.',
|
||||
'tours.import.previewAs': 'الاستيراد كـ',
|
||||
'tours.import.previewConfirm': 'استيراد {count} جولة',
|
||||
|
||||
@@ -958,6 +958,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name} içində KML faylı tapılmadı',
|
||||
'tours.import.archiveTooLargeIn': '{name} açıldıqdan sonra çox böyükdür',
|
||||
'tours.import.previewDuplicate': 'Artıq səyahətdədir',
|
||||
'tours.import.previewAdopts': 'Artıq səyahətdə trek kimi var, tura çevriləcək',
|
||||
'tours.import.previewAllDuplicates': 'Bütün treklər artıq səyahətdədir, idxal ediləcək heç nə yoxdur.',
|
||||
'tours.import.previewAs': 'Bu kimi idxal et',
|
||||
'tours.import.previewConfirm': '{count} tur idxal et',
|
||||
|
||||
@@ -964,6 +964,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Nenhum arquivo KML encontrado em {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} é grande demais depois de descompactado',
|
||||
'tours.import.previewDuplicate': 'Já está na viagem',
|
||||
'tours.import.previewAdopts': 'Já é uma trilha na viagem, vira um passeio',
|
||||
'tours.import.previewAllDuplicates': 'Todas as trilhas já estão na viagem, não há nada para importar.',
|
||||
'tours.import.previewAs': 'Importar como',
|
||||
'tours.import.previewConfirm': 'Importar {count} passeios',
|
||||
|
||||
@@ -966,6 +966,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': "No s'ha trobat cap fitxer KML a {name}",
|
||||
'tours.import.archiveTooLargeIn': '{name} és massa gran un cop descomprimit',
|
||||
'tours.import.previewDuplicate': 'Ja és al viatge',
|
||||
'tours.import.previewAdopts': 'Ja és una traça al viatge, es converteix en excursió',
|
||||
'tours.import.previewAllDuplicates': 'Tots els tracks ja són al viatge, no hi ha res a importar.',
|
||||
'tours.import.previewAs': 'Importa com a',
|
||||
'tours.import.previewConfirm': 'Importa {count} rutes',
|
||||
|
||||
@@ -952,6 +952,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'V souboru {name} není žádný soubor KML',
|
||||
'tours.import.archiveTooLargeIn': 'Soubor {name} je po rozbalení příliš velký',
|
||||
'tours.import.previewDuplicate': 'Už je v cestě',
|
||||
'tours.import.previewAdopts': 'Už je v cestě jako trasa, stane se výletem',
|
||||
'tours.import.previewAllDuplicates': 'Všechny trasy už v cestě jsou, není co importovat.',
|
||||
'tours.import.previewAs': 'Importovat jako',
|
||||
'tours.import.previewConfirm': 'Importovat {count} túr',
|
||||
|
||||
@@ -975,6 +975,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Keine KML-Datei in {name} gefunden',
|
||||
'tours.import.archiveTooLargeIn': '{name} ist entpackt zu groß',
|
||||
'tours.import.previewDuplicate': 'Schon in der Reise',
|
||||
'tours.import.previewAdopts': 'Schon als Track in der Reise, wird zur Tour',
|
||||
'tours.import.previewAllDuplicates': 'Alle Tracks sind schon in der Reise, es gibt nichts zu importieren.',
|
||||
'tours.import.previewAs': 'Importieren als',
|
||||
'tours.import.previewConfirm': '{count} Touren importieren',
|
||||
|
||||
@@ -946,6 +946,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'No KML file found in {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} is too large once unpacked',
|
||||
'tours.import.previewDuplicate': 'Already in the trip',
|
||||
'tours.import.previewAdopts': 'Already a track in the trip, becomes a tour',
|
||||
'tours.import.previewAllDuplicates': 'Every track is already in the trip, so there is nothing to import.',
|
||||
'tours.import.previewAs': 'Import as',
|
||||
'tours.import.previewConfirm': 'Import {count} tours',
|
||||
|
||||
@@ -963,6 +963,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'No hay ningún archivo KML en {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} es demasiado grande una vez descomprimido',
|
||||
'tours.import.previewDuplicate': 'Ya está en el viaje',
|
||||
'tours.import.previewAdopts': 'Ya es un track en el viaje, pasa a ser una excursión',
|
||||
'tours.import.previewAllDuplicates': 'Todos los tracks ya están en el viaje, no hay nada que importar.',
|
||||
'tours.import.previewAs': 'Importar como',
|
||||
'tours.import.previewConfirm': 'Importar {count} rutas',
|
||||
|
||||
@@ -948,6 +948,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Failis {name} pole KML-faili',
|
||||
'tours.import.archiveTooLargeIn': 'Fail {name} on lahtipakituna liiga suur',
|
||||
'tours.import.previewDuplicate': 'Juba reisil',
|
||||
'tours.import.previewAdopts': 'Juba reisil rajana, muutub retkeks',
|
||||
'tours.import.previewAllDuplicates': 'Kõik rajad on juba reisil, pole midagi importida.',
|
||||
'tours.import.previewAs': 'Impordi kui',
|
||||
'tours.import.previewConfirm': 'Impordi {count} matka',
|
||||
|
||||
@@ -981,6 +981,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Aucun fichier KML trouvé dans {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} est trop volumineux une fois décompressé',
|
||||
'tours.import.previewDuplicate': 'Déjà dans le voyage',
|
||||
'tours.import.previewAdopts': 'Déjà une trace dans le voyage, devient une sortie',
|
||||
'tours.import.previewAllDuplicates': 'Toutes les traces sont déjà dans le voyage : il n’y a rien à importer.',
|
||||
'tours.import.previewAs': 'Importer comme',
|
||||
'tours.import.previewConfirm': 'Importer {count} sorties',
|
||||
|
||||
@@ -986,6 +986,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Δεν βρέθηκε αρχείο KML στο {name}',
|
||||
'tours.import.archiveTooLargeIn': 'Το {name} είναι πολύ μεγάλο μετά την αποσυμπίεση',
|
||||
'tours.import.previewDuplicate': 'Υπάρχει ήδη στο ταξίδι',
|
||||
'tours.import.previewAdopts': 'Υπάρχει ήδη ως διαδρομή στο ταξίδι, γίνεται εκδρομή',
|
||||
'tours.import.previewAllDuplicates': 'Όλα τα ίχνη υπάρχουν ήδη στο ταξίδι, δεν υπάρχει τίποτα για εισαγωγή.',
|
||||
'tours.import.previewAs': 'Εισαγωγή ως',
|
||||
'tours.import.previewConfirm': 'Εισαγωγή {count} διαδρομών',
|
||||
|
||||
@@ -963,6 +963,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'A(z) {name} nem tartalmaz KML-fájlt',
|
||||
'tours.import.archiveTooLargeIn': 'A(z) {name} kicsomagolva túl nagy',
|
||||
'tours.import.previewDuplicate': 'Már az utazásban van',
|
||||
'tours.import.previewAdopts': 'Már nyomvonalként szerepel az utazásban, túra lesz belőle',
|
||||
'tours.import.previewAllDuplicates': 'Minden nyomvonal már az utazásban van, nincs mit importálni.',
|
||||
'tours.import.previewAs': 'Importálás mint',
|
||||
'tours.import.previewConfirm': '{count} túra importálása',
|
||||
|
||||
@@ -954,6 +954,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Tidak ada berkas KML di {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} terlalu besar setelah diekstrak',
|
||||
'tours.import.previewDuplicate': 'Sudah ada di perjalanan',
|
||||
'tours.import.previewAdopts': 'Sudah ada sebagai jalur di perjalanan, menjadi tur',
|
||||
'tours.import.previewAllDuplicates': 'Semua jejak sudah ada di perjalanan, tidak ada yang perlu diimpor.',
|
||||
'tours.import.previewAs': 'Impor sebagai',
|
||||
'tours.import.previewConfirm': 'Impor {count} tur',
|
||||
|
||||
@@ -970,6 +970,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Nessun file KML trovato in {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} è troppo grande una volta decompresso',
|
||||
'tours.import.previewDuplicate': 'Già nel viaggio',
|
||||
'tours.import.previewAdopts': 'Già una traccia nel viaggio, diventa un’escursione',
|
||||
'tours.import.previewAllDuplicates': 'Tutte le tracce sono già nel viaggio, non c’è nulla da importare.',
|
||||
'tours.import.previewAs': 'Importa come',
|
||||
'tours.import.previewConfirm': 'Importa {count} tour',
|
||||
|
||||
@@ -930,6 +930,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name}にKMLファイルが見つかりません',
|
||||
'tours.import.archiveTooLargeIn': '{name}は展開すると大きすぎます',
|
||||
'tours.import.previewDuplicate': 'すでに旅行にあります',
|
||||
'tours.import.previewAdopts': '旅行にトラックとしてあります。ツアーになります',
|
||||
'tours.import.previewAllDuplicates': 'すべてのトラックがすでに旅行にあるため、取り込むものはありません。',
|
||||
'tours.import.previewAs': '取り込む種類',
|
||||
'tours.import.previewConfirm': '{count} 件のツアーを取り込む',
|
||||
|
||||
@@ -922,6 +922,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name}에 KML 파일이 없습니다',
|
||||
'tours.import.archiveTooLargeIn': '{name}은(는) 압축을 풀면 너무 큽니다',
|
||||
'tours.import.previewDuplicate': '이미 여행에 있음',
|
||||
'tours.import.previewAdopts': '이미 여행에 트랙으로 있음, 투어가 됩니다',
|
||||
'tours.import.previewAllDuplicates': '모든 트랙이 이미 여행에 있어 가져올 것이 없습니다.',
|
||||
'tours.import.previewAs': '가져올 유형',
|
||||
'tours.import.previewConfirm': '투어 {count}개 가져오기',
|
||||
|
||||
@@ -967,6 +967,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Geen KML-bestand gevonden in {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} is uitgepakt te groot',
|
||||
'tours.import.previewDuplicate': 'Al in de reis',
|
||||
'tours.import.previewAdopts': 'Al een track in de reis, wordt een tocht',
|
||||
'tours.import.previewAllDuplicates': 'Alle tracks staan al in de reis, er is niets te importeren.',
|
||||
'tours.import.previewAs': 'Importeren als',
|
||||
'tours.import.previewConfirm': '{count} tochten importeren',
|
||||
|
||||
@@ -986,6 +986,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'W pliku {name} nie ma pliku KML',
|
||||
'tours.import.archiveTooLargeIn': 'Plik {name} po rozpakowaniu jest za duży',
|
||||
'tours.import.previewDuplicate': 'Już jest w podróży',
|
||||
'tours.import.previewAdopts': 'Już jest śladem w podróży, stanie się wycieczką',
|
||||
'tours.import.previewAllDuplicates': 'Wszystkie ślady są już w podróży, nie ma czego importować.',
|
||||
'tours.import.previewAs': 'Importuj jako',
|
||||
'tours.import.previewConfirm': 'Importuj {count} wycieczki',
|
||||
|
||||
@@ -989,6 +989,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'В {name} не найден файл KML',
|
||||
'tours.import.archiveTooLargeIn': '{name} слишком велик после распаковки',
|
||||
'tours.import.previewDuplicate': 'Уже в поездке',
|
||||
'tours.import.previewAdopts': 'Уже есть в поездке как трек, станет туром',
|
||||
'tours.import.previewAllDuplicates': 'Все треки уже в поездке, импортировать нечего.',
|
||||
'tours.import.previewAs': 'Импортировать как',
|
||||
'tours.import.previewConfirm': 'Импортировать {count} тура',
|
||||
|
||||
@@ -954,6 +954,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'V súbore {name} nie je žiadny súbor KML',
|
||||
'tours.import.archiveTooLargeIn': 'Súbor {name} je po rozbalení príliš veľký',
|
||||
'tours.import.previewDuplicate': 'Už je v ceste',
|
||||
'tours.import.previewAdopts': 'Už je v ceste ako trasa, stane sa túrou',
|
||||
'tours.import.previewAllDuplicates': 'Všetky trasy už v ceste sú, nie je čo importovať.',
|
||||
'tours.import.previewAs': 'Importovať ako',
|
||||
'tours.import.previewConfirm': 'Importovať {count} túr',
|
||||
|
||||
@@ -945,6 +945,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Ingen KML-fil hittades i {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} är för stor när den packats upp',
|
||||
'tours.import.previewDuplicate': 'Finns redan i resan',
|
||||
'tours.import.previewAdopts': 'Finns redan som spår i resan, blir en tur',
|
||||
'tours.import.previewAllDuplicates': 'Alla spår finns redan i resan, det finns inget att importera.',
|
||||
'tours.import.previewAs': 'Importera som',
|
||||
'tours.import.previewConfirm': 'Importera {count} turer',
|
||||
|
||||
@@ -907,6 +907,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'ไม่พบไฟล์ KML ใน {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} ใหญ่เกินไปเมื่อแตกไฟล์',
|
||||
'tours.import.previewDuplicate': 'มีอยู่ในทริปแล้ว',
|
||||
'tours.import.previewAdopts': 'มีอยู่ในทริปเป็นเส้นทางแล้ว จะกลายเป็นทัวร์',
|
||||
'tours.import.previewAllDuplicates': 'ทุกแทร็กมีอยู่ในทริปแล้ว จึงไม่มีอะไรให้นำเข้า',
|
||||
'tours.import.previewAs': 'นำเข้าเป็น',
|
||||
'tours.import.previewConfirm': 'นำเข้า {count} ทริป',
|
||||
|
||||
@@ -956,6 +956,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name} içinde KML dosyası bulunamadı',
|
||||
'tours.import.archiveTooLargeIn': '{name} açıldığında çok büyük',
|
||||
'tours.import.previewDuplicate': 'Zaten seyahatte',
|
||||
'tours.import.previewAdopts': 'Seyahatte iz olarak zaten var, tura dönüşecek',
|
||||
'tours.import.previewAllDuplicates': 'Tüm izler zaten seyahatte, içe aktarılacak bir şey yok.',
|
||||
'tours.import.previewAs': 'Şu olarak içe aktar',
|
||||
'tours.import.previewConfirm': '{count} turu içe aktar',
|
||||
|
||||
@@ -980,6 +980,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'У {name} не знайдено файлу KML',
|
||||
'tours.import.archiveTooLargeIn': '{name} завеликий після розпакування',
|
||||
'tours.import.previewDuplicate': 'Уже в подорожі',
|
||||
'tours.import.previewAdopts': 'Уже є в подорожі як трек, стане туром',
|
||||
'tours.import.previewAllDuplicates': 'Усі треки вже в подорожі, імпортувати нічого.',
|
||||
'tours.import.previewAs': 'Імпортувати як',
|
||||
'tours.import.previewConfirm': 'Імпортувати {count} туру',
|
||||
|
||||
@@ -941,6 +941,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': 'Không tìm thấy tệp KML trong {name}',
|
||||
'tours.import.archiveTooLargeIn': '{name} quá lớn sau khi giải nén',
|
||||
'tours.import.previewDuplicate': 'Đã có trong chuyến đi',
|
||||
'tours.import.previewAdopts': 'Đã có trong chuyến đi dưới dạng tuyến, sẽ thành chuyến tham quan',
|
||||
'tours.import.previewAllDuplicates': 'Mọi vết đã có trong chuyến đi, không có gì để nhập.',
|
||||
'tours.import.previewAs': 'Nhập dưới dạng',
|
||||
'tours.import.previewConfirm': 'Nhập {count} chuyến',
|
||||
|
||||
@@ -875,6 +875,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name} 中沒有 KML 檔案',
|
||||
'tours.import.archiveTooLargeIn': '{name} 解壓縮後過大',
|
||||
'tours.import.previewDuplicate': '已在旅程中',
|
||||
'tours.import.previewAdopts': '已作為軌跡在旅程中,將變成遊程',
|
||||
'tours.import.previewAllDuplicates': '所有軌跡都已在旅程中,沒有可匯入的內容。',
|
||||
'tours.import.previewAs': '匯入為',
|
||||
'tours.import.previewConfirm': '匯入 {count} 條路線',
|
||||
|
||||
@@ -876,6 +876,7 @@ const tours: TranslationStrings = {
|
||||
'tours.import.archiveNoKmlIn': '{name} 中没有 KML 文件',
|
||||
'tours.import.archiveTooLargeIn': '{name} 解压后过大',
|
||||
'tours.import.previewDuplicate': '已在行程中',
|
||||
'tours.import.previewAdopts': '已作为轨迹在行程中,将变为游览',
|
||||
'tours.import.previewAllDuplicates': '所有轨迹都已在行程中,没有可导入的内容。',
|
||||
'tours.import.previewAs': '导入为',
|
||||
'tours.import.previewConfirm': '导入 {count} 条路线',
|
||||
|
||||
@@ -54,6 +54,24 @@ describe('Tours GPX preview', () => {
|
||||
};
|
||||
expect(tourGpxPreviewResponseSchema.parse(preview)).toEqual(preview);
|
||||
});
|
||||
|
||||
it('carries a track taken over from before Tours, and nothing but a boolean for it (#2810)', () => {
|
||||
const track = {
|
||||
name: 'Garmin hike',
|
||||
geometry: [
|
||||
[46.1, 11.1, 1200],
|
||||
[46.2, 11.2, 1300],
|
||||
],
|
||||
point_count: 2,
|
||||
distance_km: 13.6,
|
||||
elevation_gain_m: 100,
|
||||
elevation_loss_m: 0,
|
||||
duplicate: false,
|
||||
adopts_track: true,
|
||||
};
|
||||
expect(tourGpxPreviewResponseSchema.parse({ tracks: [track] })).toEqual({ tracks: [track] });
|
||||
expect(tourGpxPreviewResponseSchema.safeParse({ tracks: [{ ...track, adopts_track: 'yes' }] }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tours KML preview (IO-02)', () => {
|
||||
|
||||
@@ -40,6 +40,12 @@ export const tourGpxPreviewTrackSchema = z.object({
|
||||
ended_at: z.string().nullable().optional(),
|
||||
/** Already in the trip under the same name and start: the import skips it, as it always has. */
|
||||
duplicate: z.boolean(),
|
||||
/**
|
||||
* A track of the same name already in the trip that is not a tour yet (one
|
||||
* imported before Tours, #2810): the import makes that place the tour
|
||||
* instead of skipping it. Never set together with `duplicate`.
|
||||
*/
|
||||
adopts_track: z.boolean().optional(),
|
||||
});
|
||||
export type TourGpxPreviewTrack = z.infer<typeof tourGpxPreviewTrackSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user