mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 07:26:30 +00:00
31859651d7
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.
30 lines
1.4 KiB
TypeScript
30 lines
1.4 KiB
TypeScript
import type { APIRequestContext } from '@playwright/test';
|
|
|
|
/**
|
|
* Small API helpers the admin guides use to put the seed back after a guide
|
|
* changed something (a user it created, a default it set). Kept out of
|
|
* `fixtures.ts`, which every screen shares.
|
|
*/
|
|
|
|
/** Deletes the account with this username, if there is one. */
|
|
export async function deleteUser(api: APIRequestContext, username: string): Promise<void> {
|
|
const res = await api.get('/api/admin/users');
|
|
if (!res.ok()) throw new Error(`could not list the users: ${res.status()} ${await res.text()}`);
|
|
const body = (await res.json()) as { users?: { id: number; username: string }[] };
|
|
const user = (body.users ?? []).find((u) => u.username === username);
|
|
if (!user) return;
|
|
const del = await api.delete(`/api/admin/users/${user.id}`);
|
|
if (!del.ok()) throw new Error(`could not delete user "${username}": ${del.status()} ${await del.text()}`);
|
|
}
|
|
|
|
/**
|
|
* Returns these default user settings to TREK's built-in value, the way the
|
|
* reset link beside a field does (one field per request, as the page sends it).
|
|
*/
|
|
export async function resetDefaults(api: APIRequestContext, keys: string[]): Promise<void> {
|
|
for (const key of keys) {
|
|
const res = await api.put('/api/admin/default-user-settings', { data: { [key]: null } });
|
|
if (!res.ok()) throw new Error(`could not reset the default "${key}": ${res.status()} ${await res.text()}`);
|
|
}
|
|
}
|