Files
TREK/client/e2e/help/fixtures-trip-collab.ts
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

73 lines
3.1 KiB
TypeScript

import type { APIRequestContext } from '@playwright/test';
import { seededTrip } from './fixtures';
/**
* What the two note guides of the Collab tab need beyond `ensureCollabFixtures`.
* Kept apart from the shared fixtures because nothing outside
* `trip-collab.guide.ts` reads it.
*/
/**
* The note `manage-notes` opens, pins, edits and finally deletes. It is made
* fresh at the start of that guide rather than in the seed, so no other picture
* of the tab (the hero among them) carries a note that is about to go.
*/
export const MANAGE_NOTE = {
title: 'Onsen etiquette',
category: 'Accommodation',
color: '#ef4444',
content:
'Wash at the stools **before** you get into the bath.\n\n- The small towel stays out of the water\n- No swimwear\n- Ask at the front desk about tattoos',
website: 'https://www.japan.travel/en/guide/onsen/',
};
/** The line the edit step adds to it. */
export const MANAGE_NOTE_EDIT = '- Drink water afterwards, the baths run hot';
/**
* The category and colour every seeded note had before `note-categories` renames
* and recolours them (`e2e/screenshots/seed.ts`, step 11b), by title.
*/
export const SEEDED_NOTE_CATEGORIES: Record<string, { category: string; color: string }> = {
'Rail passes': { category: 'Transport', color: '#3b82f6' },
'Ryokan etiquette': { category: 'Accommodation', color: '#ef4444' },
'Rainy-day alternatives': { category: 'Ideas', color: '#22c55e' },
};
const collab = (): string => `/api/trips/${seededTrip().tripId}/collab`;
async function notesOf(
api: APIRequestContext
): Promise<{ id: number; title: string; category: string | null; color: string | null }[]> {
const res = await api.get(`${collab()}/notes`);
const body = (await res.json()) as {
notes?: { id: number; title: string; category: string | null; color: string | null }[];
};
return body.notes ?? [];
}
/** Removes every note of that title. */
export async function removeNotes(api: APIRequestContext, title: string): Promise<void> {
for (const note of (await notesOf(api)).filter((n) => n.title === title)) {
await api.delete(`${collab()}/notes/${note.id}`);
}
}
/** One open, unpinned MANAGE_NOTE; a copy left by a run that stopped short is thrown away first. */
export async function ensureManageNote(api: APIRequestContext): Promise<void> {
await removeNotes(api, MANAGE_NOTE.title);
const created = await api.post(`${collab()}/notes`, { data: MANAGE_NOTE });
if (!created.ok())
throw new Error(`could not write the note "${MANAGE_NOTE.title}": ${created.status()} ${await created.text()}`);
}
/** Puts every seeded note back into its seeded category and colour. Safe to run when nothing changed. */
export async function restoreNoteCategories(api: APIRequestContext): Promise<void> {
for (const note of await notesOf(api)) {
const seeded = SEEDED_NOTE_CATEGORIES[note.title];
if (!seeded || (note.category === seeded.category && note.color === seeded.color)) continue;
const res = await api.put(`${collab()}/notes/${note.id}`, { data: seeded });
if (!res.ok()) throw new Error(`could not restore the note "${note.title}": ${res.status()} ${await res.text()}`);
}
}