mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
fix(help): three more the whole suite showed up
- place-to-collection found the place already in a list, because the Collections screen's guides run earlier and leave it there. It clears the place first now, with the same helper its cleanup uses. - The road trip rail leaves out a day with nothing to drive, which its own helper says, and the fold step was the last place still pointing at day 1. - The transport form's location search took whatever the geocoder ranked first, and for a landmark that is as often a shop down the road. It picks the suggestion that answers the query.
This commit is contained in:
@@ -384,9 +384,30 @@ 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 => {
|
||||
await unsaveEverywhere(p, 'Senso-ji Temple')
|
||||
await openTrip(p, { day: null })
|
||||
await openPlace(p, 'Senso-ji Temple')
|
||||
},
|
||||
@@ -417,16 +438,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
||||
},
|
||||
},
|
||||
],
|
||||
cleanup: async p => {
|
||||
const place = await findPlace(p, 'Senso-ji Temple')
|
||||
if (!place) return
|
||||
const query = new URLSearchParams({ name: place.name, lat: String(place.lat ?? ''), lng: String(place.lng ?? '') })
|
||||
const res = await p.request.get(`/api/addons/collections/membership?${query.toString()}`)
|
||||
const body = (await res.json()) as { lists?: { place_id: number }[] }
|
||||
for (const entry of body.lists ?? []) {
|
||||
await p.request.delete(`/api/addons/collections/places/${entry.place_id}`)
|
||||
}
|
||||
},
|
||||
cleanup: p => unsaveEverywhere(p, 'Senso-ji Temple'),
|
||||
},
|
||||
'place-track': {
|
||||
guide: guide('place-track'),
|
||||
|
||||
@@ -218,15 +218,17 @@ const SCRIPTS: Record<string, GuideScript> = {
|
||||
only(p => dayCard(p, 2).locator('header')),
|
||||
only(p => dayCard(p, 2).getByRole('list').first()),
|
||||
{
|
||||
target: p => dayCard(p, 1).locator('header'),
|
||||
// Day 2, like the two steps above: the rail leaves out a day with
|
||||
// nothing to drive, and day 1 is one of them.
|
||||
target: p => dayCard(p, 2).locator('header'),
|
||||
act: async p => {
|
||||
await dayCard(p, 1).locator('header').click()
|
||||
await expect(dayCard(p, 1).locator('header')).toHaveAttribute('aria-expanded', 'false')
|
||||
await dayCard(p, 2).locator('header').click()
|
||||
await expect(dayCard(p, 2).locator('header')).toHaveAttribute('aria-expanded', 'false')
|
||||
await settle(p)
|
||||
// Folded is not the state to leave the trip in, and the result picture
|
||||
// is of the whole drive rather than of one card shut.
|
||||
await dayCard(p, 1).locator('header').click()
|
||||
await expect(dayCard(p, 1).locator('header')).toHaveAttribute('aria-expanded', 'true')
|
||||
await dayCard(p, 2).locator('header').click()
|
||||
await expect(dayCard(p, 2).locator('header')).toHaveAttribute('aria-expanded', 'true')
|
||||
await settle(p)
|
||||
},
|
||||
},
|
||||
@@ -395,7 +397,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
||||
// Which day the click landed on is the router's answer, not ours.
|
||||
target: p => {
|
||||
const day = seededTrip().dayIds.indexOf(viaDayId) + 1
|
||||
return dayCard(p, day > 0 ? day : 1).locator('header')
|
||||
// Fall back to day 2, not day 1: the rail has no card for a day
|
||||
// with nothing to drive.
|
||||
return dayCard(p, day > 0 ? day : 2).locator('header')
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -68,9 +68,14 @@ const transportSheet = (page: Page) => portalDialog(page, page.getByRole('button
|
||||
async function searchLocation(page: Page, box: Locator, query: string, match: RegExp): Promise<void> {
|
||||
await box.click()
|
||||
await typeInto(page, box, query)
|
||||
const first = suggestions(box).locator('button').first()
|
||||
await expect(first).toBeVisible({ timeout: 25_000 })
|
||||
await first.click()
|
||||
const options = suggestions(box).locator('button')
|
||||
await expect(options.first()).toBeVisible({ timeout: 25_000 })
|
||||
// The suggestion that answers the query, not whatever came back first: this
|
||||
// list is a live geocoder and its top hit for a landmark is as often a shop
|
||||
// down the road, which then travels into the picture as the wrong address.
|
||||
const wanted = options.filter({ hasText: match }).first()
|
||||
await expect(wanted, `no suggestion for "${query}" matching ${match}`).toBeVisible({ timeout: 25_000 })
|
||||
await wanted.click()
|
||||
await expect(box).toHaveValue(match, { timeout: 15_000 })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user