1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-23 11:15:33 +00:00
Files
frontend/test/common/entity/context/context-mock.ts
Wendelin 0daf94e98f Quick bar: new design and area search (#28678)
* Add "Commands" title to quick bar translations in English

* Enhance QuickBar dialog handling and localize commands title

* add nav icons

* Add icons and styles and separate navigation from commands

* handle non admin

* Add areas

* Fix import and shortcuts

* Restructure

* remove area sort

* move keys

* area search keys review

* Fix adaptive dialog slots without header

* Design review

* Review marcin

* Fix safe area bottom

* Fix ios focus

* Make it clearable

---------

Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
2026-01-15 09:45:57 +02:00

114 lines
2.4 KiB
TypeScript

import type { HassEntity } from "home-assistant-js-websocket";
import type { AreaRegistryEntry } from "../../../../src/data/area/area_registry";
import type { DeviceRegistryEntry } from "../../../../src/data/device/device_registry";
import type {
EntityRegistryDisplayEntry,
EntityRegistryEntry,
} from "../../../../src/data/entity/entity_registry";
import type { FloorRegistryEntry } from "../../../../src/data/floor_registry";
export const mockStateObj = (partial: Partial<HassEntity>): HassEntity => ({
entity_id: "",
attributes: {},
state: "on",
last_changed: "",
last_updated: "",
context: {
id: "",
user_id: null,
parent_id: null,
},
...partial,
});
export const mockEntity = (
partial: Partial<EntityRegistryDisplayEntry>
): EntityRegistryDisplayEntry => ({
entity_id: "",
labels: [],
...partial,
});
export const mockEntityEntry = (
partial: Partial<EntityRegistryEntry>
): EntityRegistryEntry => ({
entity_id: "",
name: null,
icon: null,
platform: "",
config_entry_id: null,
config_subentry_id: null,
device_id: null,
area_id: null,
labels: [],
disabled_by: null,
hidden_by: null,
entity_category: null,
has_entity_name: false,
unique_id: "",
id: "",
options: null,
categories: {},
created_at: 0,
modified_at: 0,
...partial,
});
export const mockDevice = (
partial: Partial<DeviceRegistryEntry>
): DeviceRegistryEntry => ({
id: "",
config_entries: [],
config_entries_subentries: {},
connections: [],
identifiers: [],
manufacturer: null,
model: null,
model_id: null,
name: null,
labels: [],
sw_version: null,
hw_version: null,
serial_number: null,
via_device_id: null,
area_id: null,
name_by_user: null,
entry_type: null,
disabled_by: null,
configuration_url: null,
primary_config_entry: null,
created_at: 0,
modified_at: 0,
...partial,
});
export const mockArea = (
partial: Partial<AreaRegistryEntry>
): AreaRegistryEntry => ({
aliases: [],
area_id: "",
name: "",
floor_id: null,
created_at: 0,
modified_at: 0,
humidity_entity_id: null,
temperature_entity_id: null,
icon: null,
labels: [],
picture: null,
...partial,
});
export const mockFloor = (
partial: Partial<FloorRegistryEntry>
): FloorRegistryEntry => ({
aliases: [],
floor_id: "",
name: "",
created_at: 0,
modified_at: 0,
icon: null,
level: 0,
...partial,
});