mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 15:36:33 +00:00
1727732841
A new manifest capability poiCategories (up to 4, icon from an allow-list, strict #rrggbb color) and the hook poiCategoryProvider.getPois behind the hook:poi-category-provider permission. GET /api/plugin-pois in the plugin contributions module answers them in the /api/maps/pois shape, with search_plugin_pois as the MCP twin. plugin: ids no longer count as Google place ids. SDK 1.8.0 carries the types, validation and docs. On the map, one hook merges the built-in categories with the ones active plugins declare, and the pill shows the plugin chips after a divider on desktop and phone, scrolling sideways instead of shrinking a chip below its touch target. A plugin chip searches through a repo that refuses offline and parses the answer strictly. Its pins, on Leaflet and GL, use the category's own icon and color, both checked again before they reach any markup, and the hover card lists the plugin's details as escaped text. A plugin POI can be added as a place like any other. The admin panels on desktop and phone show a chip for the new permission and the categories a plugin would add, from one shared module. Addresses discussion #1781.
35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
// FE-COMP-PLUGINPOIICON-001 to FE-COMP-PLUGINPOIICON-004
|
|
import { describe, it, expect } from 'vitest'
|
|
import * as Lucide from 'lucide-react'
|
|
import { MapPin, Signpost } from 'lucide-react'
|
|
import { PLUGIN_POI_ICONS } from '@trek/shared'
|
|
import { POI_DEFAULT_COLOR, pluginPoiColor, resolvePluginPoiIcon } from './pluginPoiIcons'
|
|
|
|
describe('resolvePluginPoiIcon', () => {
|
|
it('FE-COMP-PLUGINPOIICON-001: every allow-listed name resolves to the lucide icon of that name', () => {
|
|
const lucide = Lucide as unknown as Record<string, unknown>
|
|
for (const name of PLUGIN_POI_ICONS) expect(resolvePluginPoiIcon(name)).toBe(lucide[name])
|
|
expect(resolvePluginPoiIcon('Signpost')).toBe(Signpost)
|
|
})
|
|
|
|
it('FE-COMP-PLUGINPOIICON-002: anything off the list is a pin, never a lucide export of that name', () => {
|
|
// Real lucide exports, just not on the list, and names that are not icons at all.
|
|
for (const name of ['Skull', 'Blocks', 'createLucideIcon', 'icons', 'toString', '', null, undefined, 42]) {
|
|
expect(resolvePluginPoiIcon(name)).toBe(MapPin)
|
|
}
|
|
})
|
|
})
|
|
|
|
describe('pluginPoiColor', () => {
|
|
it('FE-COMP-PLUGINPOIICON-003: a #rrggbb colour passes through unchanged', () => {
|
|
expect(pluginPoiColor('#2f855a')).toBe('#2f855a')
|
|
expect(pluginPoiColor('#2F855A')).toBe('#2F855A')
|
|
})
|
|
|
|
it('FE-COMP-PLUGINPOIICON-004: anything else is the default grey, markup included', () => {
|
|
for (const value of ['red', '#fff', '#2f855a;background:url(https://x)', 'url(https://x)', '"><script>', '', null, 7]) {
|
|
expect(pluginPoiColor(value)).toBe(POI_DEFAULT_COLOR)
|
|
}
|
|
})
|
|
})
|