fix: label map object types
This commit is contained in:
parent
6c9323cdd8
commit
e3998acc12
@ -19,6 +19,14 @@ const DISPLAY_CONTROLS = [
|
||||
["showUnmapped", "Unmapped"],
|
||||
];
|
||||
|
||||
function formatObjectTypeLabel(type) {
|
||||
return String(type)
|
||||
.split(/[-_\s]+/)
|
||||
.filter(Boolean)
|
||||
.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
export default function LocationMapBottomSheet({
|
||||
mode,
|
||||
editorTool,
|
||||
@ -261,7 +269,7 @@ export default function LocationMapBottomSheet({
|
||||
onChange={(event) => onObjectField("type", event.target.value)}
|
||||
>
|
||||
{MAP_OBJECT_TYPES.map((type) => (
|
||||
<option key={type} value={type}>{type}</option>
|
||||
<option key={type} value={type}>{formatObjectTypeLabel(type)}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
@ -288,6 +288,10 @@ test("admin creates a map from zones, saves a draft, and publishes it", async ({
|
||||
const bakeryObject = page.locator(".location-map-object", { hasText: "Bakery" }).locator("rect").first();
|
||||
await bakeryObject.click();
|
||||
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bakery");
|
||||
const objectTypeSelect = page.getByLabel("Object type");
|
||||
await expect(objectTypeSelect).toHaveValue("zone");
|
||||
await expect(objectTypeSelect.locator('option[value="zone"]')).toHaveText("Zone");
|
||||
await expect(objectTypeSelect.locator('option[value="aisle"]')).toHaveText("Aisle");
|
||||
const moveBox = await bakeryObject.boundingBox();
|
||||
expect(moveBox).not.toBeNull();
|
||||
if (!moveBox) throw new Error("Bakery map object could not be moved");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user