mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(planner): steady satellite pill, responsive places rail, day-scoped add
The satellite toggle sat on an offset that included --day-panel-h, so it hopped every time the day panel was collapsed or expanded. On the desktop map that panel is a centred card between the sidebars and never reaches the pill at the left edge, so the lift only applies on a phone now. In the places rail the two add buttons split the width evenly once a day is open, and every button drops to its icon when the rail is dragged narrow. The filter tabs span the rail and keep their own text widths. The count is a badge across the rail; the search field got the outline the controls around it use. An empty day offers a button that opens the place form pointed at that day instead of only stating that nothing is planned. The day is cleared again when the form is opened to edit, which it was not before. The trip tab bar no longer carries a native title repeating its own label; the full name moved to aria-label for the tabs whose label is abbreviated. Three maps tests drove the index switch through app_settings, which no longer holds it, and now move TREK_PLACES_ENABLED instead.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* inside an offline sync, which is why every failure path here ends in null
|
||||
* rather than an exception.
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
const { mockArea } = vi.hoisted(() => ({
|
||||
mockArea: vi.fn(async (): Promise<unknown> => ({ results: [], truncated: false, count: 0 })),
|
||||
@@ -38,10 +38,20 @@ const PLACE = {
|
||||
hours: null,
|
||||
};
|
||||
|
||||
const ORIGINAL_TREK_PLACES = process.env.TREK_PLACES_ENABLED;
|
||||
|
||||
afterEach(() => {
|
||||
if (ORIGINAL_TREK_PLACES === undefined) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = ORIGINAL_TREK_PLACES;
|
||||
});
|
||||
|
||||
// The index is an operator switch, not an admin row, so switching it off means
|
||||
// moving the env rather than stubbing a settings lookup. The service reads the
|
||||
// flag per call, which is why the restore above belongs in afterEach.
|
||||
function make(enabled = true) {
|
||||
const database = {
|
||||
get: vi.fn(() => (enabled ? undefined : { value: 'false' })),
|
||||
} as unknown as DatabaseService;
|
||||
if (enabled) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = 'false';
|
||||
const database = { get: vi.fn(() => undefined) } as unknown as DatabaseService;
|
||||
return new MapsService(database, {} as PlacePhotoCacheService);
|
||||
}
|
||||
|
||||
@@ -69,7 +79,7 @@ describe('MapsService.placesInArea', () => {
|
||||
expect((await make().placesInArea(BOX))?.truncated).toBe(true);
|
||||
});
|
||||
|
||||
it('MAPS-AREA-003: returns null when the admin switched the index off', async () => {
|
||||
it('MAPS-AREA-003: returns null when the operator switched the index off', async () => {
|
||||
expect(await make(false).placesInArea(BOX)).toBeNull();
|
||||
expect(mockArea).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* admin leaves it on), and that a failure on either side ends as a coordinate
|
||||
* or a null rather than a half-answer the importer would store.
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
const { mockSearch, mockNominatim } = vi.hoisted(() => ({
|
||||
mockSearch: vi.fn(async (_query: string, _opts?: { limit?: number }): Promise<unknown> => []),
|
||||
@@ -51,10 +51,20 @@ const OSM_ROW = {
|
||||
|
||||
const osmAnswer = (rows: unknown[]) => ({ ok: true, json: async () => rows });
|
||||
|
||||
const ORIGINAL_TREK_PLACES = process.env.TREK_PLACES_ENABLED;
|
||||
|
||||
afterEach(() => {
|
||||
if (ORIGINAL_TREK_PLACES === undefined) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = ORIGINAL_TREK_PLACES;
|
||||
});
|
||||
|
||||
// The index is an operator switch, not an admin row, so switching it off means
|
||||
// moving the env rather than stubbing a settings lookup. The service reads the
|
||||
// flag per call, which is why the restore above belongs in afterEach.
|
||||
function make(enabled = true) {
|
||||
const database = {
|
||||
get: vi.fn(() => (enabled ? undefined : { value: 'false' })),
|
||||
} as unknown as DatabaseService;
|
||||
if (enabled) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = 'false';
|
||||
const database = { get: vi.fn(() => undefined) } as unknown as DatabaseService;
|
||||
return new MapsService(database, {} as PlacePhotoCacheService);
|
||||
}
|
||||
|
||||
@@ -106,7 +116,7 @@ describe('MapsService.geocodeQuery', () => {
|
||||
expect(console.warn).toHaveBeenCalledWith('TREK Places geocode failed, falling back:', 'places api down');
|
||||
});
|
||||
|
||||
it('MAPS-GEOCODE-006: the query never leaves for the index while the admin has it off', async () => {
|
||||
it('MAPS-GEOCODE-006: the query never leaves for the index while the operator has it off', async () => {
|
||||
// The index has an answer, and a different one: the OSM coordinate coming
|
||||
// back is what proves the gate held rather than the call merely being made.
|
||||
mockSearch.mockResolvedValue(indexHit(1.2345, 2.3456));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* already reads, and that everything which is not a hit still lands on Overpass
|
||||
* unchanged.
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
const { mockNearby } = vi.hoisted(() => ({
|
||||
mockNearby: vi.fn(
|
||||
@@ -95,10 +95,20 @@ const OVERPASS_ANSWER = {
|
||||
clamped: false,
|
||||
};
|
||||
|
||||
const ORIGINAL_TREK_PLACES = process.env.TREK_PLACES_ENABLED;
|
||||
|
||||
afterEach(() => {
|
||||
if (ORIGINAL_TREK_PLACES === undefined) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = ORIGINAL_TREK_PLACES;
|
||||
});
|
||||
|
||||
// The index is an operator switch, not an admin row, so switching it off means
|
||||
// moving the env rather than stubbing a settings lookup. The service reads the
|
||||
// flag per call, which is why the restore above belongs in afterEach.
|
||||
function make(enabled = true) {
|
||||
const database = {
|
||||
get: vi.fn(() => (enabled ? undefined : { value: 'false' })),
|
||||
} as unknown as DatabaseService;
|
||||
if (enabled) delete process.env.TREK_PLACES_ENABLED;
|
||||
else process.env.TREK_PLACES_ENABLED = 'false';
|
||||
const database = { get: vi.fn(() => undefined) } as unknown as DatabaseService;
|
||||
return new MapsService(database, {} as PlacePhotoCacheService);
|
||||
}
|
||||
|
||||
@@ -352,7 +362,7 @@ describe('MapsService.pois falls back to Overpass', () => {
|
||||
expect(mockNearby).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('MAPS-POIS-010: the admin switching the index off skips it entirely', async () => {
|
||||
it('MAPS-POIS-010: the operator switching the index off skips it entirely', async () => {
|
||||
const svc = make(false);
|
||||
const overpass = stubOverpass(svc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user