mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 10:44:23 +00:00
Tours: save a tour as a new, independent tour (P2C-07)
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
tourSourceCheckResponseSchema,
|
||||
type TourProvenance,
|
||||
} from './tour-provenance.schema';
|
||||
import { tourCreateResponseSchema, tourListItemSchema } from './tours.schema';
|
||||
import { tourCopyRequestSchema, tourCreateResponseSchema, tourListItemSchema } from './tours.schema';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
@@ -109,3 +109,11 @@ describe('source check answer (MF-03)', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('save as new tour (P2C-07)', () => {
|
||||
it('takes a trimmed name and refuses an empty or overlong one', () => {
|
||||
expect(tourCopyRequestSchema.parse({ name: ' Ridge (copy) ' })).toEqual({ name: 'Ridge (copy)' });
|
||||
expect(tourCopyRequestSchema.safeParse({ name: ' ' }).success).toBe(false);
|
||||
expect(tourCopyRequestSchema.safeParse({ name: 'x'.repeat(256) }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
import { tourOriginSchema, tourProvenanceSchema } from './tour-provenance.schema';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* Tours contracts — the generalisation of "hike" into a domain of self-contained,
|
||||
* single-day, non-motorized activities that follow a track (hike, bike, run, ski,
|
||||
@@ -244,6 +245,16 @@ export const tourCreateResponseSchema = z.object({
|
||||
});
|
||||
export type TourCreateResponse = z.infer<typeof tourCreateResponseSchema>;
|
||||
|
||||
/**
|
||||
* P2C-07 "save as new tour": the name the copy gets. Everything else comes
|
||||
* from the tour it is copied from; the copy has its own id, line and control
|
||||
* points, and no days.
|
||||
*/
|
||||
export const tourCopyRequestSchema = z.object({
|
||||
name: z.string().trim().min(1).max(255),
|
||||
});
|
||||
export type TourCopyRequest = z.infer<typeof tourCopyRequestSchema>;
|
||||
|
||||
/** Saved-tour editor payload: list metadata plus its persisted routing controls. */
|
||||
export const tourDetailResponseSchema = tourCreateResponseSchema;
|
||||
export type TourDetailResponse = z.infer<typeof tourDetailResponseSchema>;
|
||||
|
||||
Reference in New Issue
Block a user