mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(help): the collection helper belongs beside the scripts, not inside them
This commit is contained in:
@@ -113,6 +113,26 @@ const closeModal = async (page: Page): Promise<void> => {
|
||||
|
||||
const only = (target: (p: Page) => Locator) => ({ target })
|
||||
|
||||
/**
|
||||
* Take a place out of every collection it sits in.
|
||||
*
|
||||
* Run before the guide as well as after it: the Collections screen's own guides
|
||||
* run earlier in the suite and leave places saved, and a place that is already
|
||||
* in a list offers Saved where this guide's first step looks for Save to
|
||||
* Collection.
|
||||
*/
|
||||
async function unsaveEverywhere(page: Page, name: string): Promise<void> {
|
||||
const place = await findPlace(page, name)
|
||||
if (!place) return
|
||||
const query = new URLSearchParams({ name: place.name, lat: String(place.lat ?? ''), lng: String(place.lng ?? '') })
|
||||
const res = await page.request.get(`/api/addons/collections/membership?${query.toString()}`)
|
||||
if (!res.ok()) return
|
||||
const body = (await res.json()) as { lists?: { place_id: number }[] }
|
||||
for (const entry of body.lists ?? []) {
|
||||
await page.request.delete(`/api/addons/collections/places/${entry.place_id}`)
|
||||
}
|
||||
}
|
||||
|
||||
const SCRIPTS: Record<string, GuideScript> = {
|
||||
'read-place': {
|
||||
guide: guide('read-place'),
|
||||
@@ -384,26 +404,6 @@ const SCRIPTS: Record<string, GuideScript> = {
|
||||
only(p => footer(p).getByRole('button', { name: 'Open Website' })),
|
||||
],
|
||||
},
|
||||
/**
|
||||
* Take a place out of every collection it sits in.
|
||||
*
|
||||
* Run before the guide as well as after it: the Collections screen's own guides
|
||||
* run earlier in the suite and leave places saved, and a place that is already
|
||||
* in a list offers Saved where this guide's first step looks for Save to
|
||||
* Collection.
|
||||
*/
|
||||
async function unsaveEverywhere(page: Page, name: string): Promise<void> {
|
||||
const place = await findPlace(page, name)
|
||||
if (!place) return
|
||||
const query = new URLSearchParams({ name: place.name, lat: String(place.lat ?? ''), lng: String(place.lng ?? '') })
|
||||
const res = await page.request.get(`/api/addons/collections/membership?${query.toString()}`)
|
||||
if (!res.ok()) return
|
||||
const body = (await res.json()) as { lists?: { place_id: number }[] }
|
||||
for (const entry of body.lists ?? []) {
|
||||
await page.request.delete(`/api/addons/collections/places/${entry.place_id}`)
|
||||
}
|
||||
}
|
||||
|
||||
'place-to-collection': {
|
||||
guide: guide('place-to-collection'),
|
||||
start: async p => {
|
||||
|
||||
Reference in New Issue
Block a user