mirror of
https://github.com/home-assistant/frontend.git
synced 2026-08-25 23:55:13 +01:00
Remove security panel rendering tests
This commit is contained in:
@@ -358,57 +358,6 @@ test.describe("Energy dashboard", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Security panel
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test.describe("Security panel", () => {
|
||||
test("hides the editor from non-admin users", async ({ page }) => {
|
||||
await goToPanel(page, "/?scenario=non-admin-security#/security");
|
||||
|
||||
await expect(page.locator("ha-panel-security")).toBeAttached({
|
||||
timeout: PANEL_TIMEOUT,
|
||||
});
|
||||
await expect(page.locator("ha-panel-security hui-view")).toBeAttached({
|
||||
timeout: PANEL_TIMEOUT,
|
||||
});
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Edit security and safety page" })
|
||||
).not.toBeAttached();
|
||||
});
|
||||
|
||||
test("renders configured active security alerts", async ({ page }) => {
|
||||
await goToPanel(page, "/?scenario=security-alerts#/security");
|
||||
|
||||
await expect(page.locator("ha-panel-security")).toBeAttached({
|
||||
timeout: PANEL_TIMEOUT,
|
||||
});
|
||||
|
||||
const alertCard = page.locator("hui-alert-card").first();
|
||||
await expect(alertCard).toBeAttached({ timeout: PANEL_TIMEOUT });
|
||||
|
||||
if (!(await alertCard.isVisible().catch(() => false))) {
|
||||
const activityTab = page.getByRole("radio", { name: "Activity" });
|
||||
if (await activityTab.isVisible().catch(() => false)) {
|
||||
await activityTab.dispatchEvent("click");
|
||||
}
|
||||
}
|
||||
|
||||
await expect(alertCard).toBeVisible({ timeout: QUICK_TIMEOUT });
|
||||
await expect(alertCard.locator("text=Front door")).toBeVisible({
|
||||
timeout: QUICK_TIMEOUT,
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
(window as any).__mockHass.mockEntities[
|
||||
"binary_sensor.front_door"
|
||||
].update({ state: "off" });
|
||||
});
|
||||
|
||||
await expect(alertCard).toBeHidden({ timeout: QUICK_TIMEOUT });
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// More-info dialog (light)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -109,13 +109,6 @@ export const e2eTestPanels: Record<string, E2ETestPanelInfo> = {
|
||||
url_path: "iframe",
|
||||
testSelector: "ha-panel-iframe",
|
||||
},
|
||||
security: {
|
||||
component_name: "security",
|
||||
icon: "mdi:shield-home",
|
||||
title: "security",
|
||||
config: null,
|
||||
url_path: "security",
|
||||
},
|
||||
config: {
|
||||
component_name: "config",
|
||||
icon: "mdi:cog",
|
||||
|
||||
@@ -3,7 +3,6 @@ import type {
|
||||
EntityRegistryEntry,
|
||||
ExtEntityRegistryEntry,
|
||||
} from "../../../../../src/data/entity/entity_registry";
|
||||
import type { SecurityFrontendSystemData } from "../../../../../src/data/frontend";
|
||||
import type { LovelaceRawConfig } from "../../../../../src/data/lovelace/config/types";
|
||||
import type { MediaPlayerItem } from "../../../../../src/data/media-player";
|
||||
import {
|
||||
@@ -31,11 +30,6 @@ const nonAdminScenario: Scenario = async (hass) => {
|
||||
});
|
||||
};
|
||||
|
||||
const nonAdminSecurityScenario: Scenario = async (hass) => {
|
||||
await nonAdminScenario(hass);
|
||||
hass.mockWS("frontend/get_system_data", () => ({ value: {} }));
|
||||
};
|
||||
|
||||
const darkThemeScenario: Scenario = async (hass) => {
|
||||
// Force dark mode by setting selectedTheme.dark = true.
|
||||
// _applyTheme() reads selectedTheme.dark to determine darkMode; setting
|
||||
@@ -295,33 +289,11 @@ const delayedMediaBrowseErrorScenario: Scenario = (hass) => {
|
||||
hass.mockWS("media_source/browse_media", () => browsePromise);
|
||||
};
|
||||
|
||||
const securityAlertsScenario: Scenario = async (hass) => {
|
||||
const securityData: SecurityFrontendSystemData = {
|
||||
alert_entities: [{ entity: "binary_sensor.front_door" }],
|
||||
};
|
||||
|
||||
hass.addEntities([
|
||||
{
|
||||
entity_id: "binary_sensor.front_door",
|
||||
state: "on",
|
||||
attributes: {
|
||||
friendly_name: "Front door",
|
||||
device_class: "door",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
hass.mockWS("frontend/get_system_data", (msg: { key: string }) => ({
|
||||
value: msg.key === "security" ? securityData : null,
|
||||
}));
|
||||
};
|
||||
|
||||
// ── Registry ──────────────────────────────────────────────────────────────
|
||||
|
||||
export const scenarios: Record<string, Scenario> = {
|
||||
default: defaultScenario,
|
||||
"non-admin": nonAdminScenario,
|
||||
"non-admin-security": nonAdminSecurityScenario,
|
||||
"dark-theme": darkThemeScenario,
|
||||
"custom-theme": customThemeScenario,
|
||||
"delayed-calendar": delayedCalendarScenario,
|
||||
@@ -333,5 +305,4 @@ export const scenarios: Record<string, Scenario> = {
|
||||
"weather-more-info": weatherMoreInfoScenario,
|
||||
"quick-search-assist": quickSearchAssistScenario,
|
||||
"delayed-lovelace": delayedLovelaceScenario,
|
||||
"security-alerts": securityAlertsScenario,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { nothing } from "lit";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { SecurityFrontendSystemData } from "../../../../src/data/frontend";
|
||||
import type { EditSecurityDialogParams } from "../../../../src/panels/security/dialogs/show-dialog-edit-security";
|
||||
@@ -8,13 +7,11 @@ import { createMockHass } from "../../../fixtures/hass";
|
||||
|
||||
interface TestEditSecurityDialog extends HTMLElement {
|
||||
params: EditSecurityDialogParams;
|
||||
_state?: SecurityFrontendSystemData;
|
||||
_i18n: HomeAssistantInternationalization;
|
||||
isDirtyState: boolean;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
performUpdate(): void;
|
||||
render(): unknown;
|
||||
}
|
||||
|
||||
const alertEntitiesChanged = (
|
||||
@@ -44,15 +41,6 @@ describe("dialog-edit-security", () => {
|
||||
return dialog;
|
||||
};
|
||||
|
||||
it("renders without a Home Assistant snapshot in dialog params", () => {
|
||||
const dialog = createDialog();
|
||||
|
||||
expect(dialog._state).toEqual({ alert_entities: [] });
|
||||
expect(dialog.render()).not.toBe(nothing);
|
||||
|
||||
dialog.disconnectedCallback();
|
||||
});
|
||||
|
||||
it("becomes clean after nested configuration is restored", () => {
|
||||
const alertEntities = [
|
||||
{ entity: "binary_sensor.window", severity: "warning" as const },
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { SecurityFrontendSystemData } from "../../../src/data/frontend";
|
||||
import { fetchFrontendSystemData } from "../../../src/data/frontend";
|
||||
import type { HomeAssistant } from "../../../src/types";
|
||||
import "../../../src/panels/security/ha-panel-security";
|
||||
import { createMockHass } from "../../fixtures/hass";
|
||||
|
||||
vi.hoisted(() => {
|
||||
Object.assign(globalThis, {
|
||||
__STATIC_PATH__: "/",
|
||||
__BUILD__: "modern",
|
||||
__VERSION__: "test",
|
||||
__BACKWARDS_COMPAT__: false,
|
||||
__SUPERVISOR__: false,
|
||||
__NAMESPACE__: "frontend",
|
||||
});
|
||||
});
|
||||
|
||||
vi.mock("../../../src/data/frontend", async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
fetchFrontendSystemData: vi.fn(),
|
||||
}));
|
||||
|
||||
interface TestPanelSecurity extends HTMLElement {
|
||||
hass: HomeAssistant;
|
||||
_config?: SecurityFrontendSystemData;
|
||||
}
|
||||
|
||||
const loadConfig = (panel: TestPanelSecurity) =>
|
||||
(panel as unknown as Record<"_loadConfig", () => Promise<void>>)[
|
||||
"_loadConfig"
|
||||
]();
|
||||
|
||||
describe("ha-panel-security", () => {
|
||||
it("ignores a stale configuration response after retrying", async () => {
|
||||
let resolveInitial!: (value: SecurityFrontendSystemData) => void;
|
||||
let resolveRetry!: (value: SecurityFrontendSystemData) => void;
|
||||
vi.mocked(fetchFrontendSystemData)
|
||||
.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
resolveInitial = resolve;
|
||||
})
|
||||
)
|
||||
.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
resolveRetry = resolve;
|
||||
})
|
||||
);
|
||||
const panel = document.createElement(
|
||||
"ha-panel-security"
|
||||
) as unknown as TestPanelSecurity;
|
||||
panel.hass = createMockHass();
|
||||
|
||||
const initialLoad = loadConfig(panel);
|
||||
const retryLoad = loadConfig(panel);
|
||||
const retryConfig = {
|
||||
alert_entities: [{ entity: "binary_sensor.new" }],
|
||||
};
|
||||
resolveRetry(retryConfig);
|
||||
await retryLoad;
|
||||
resolveInitial({
|
||||
alert_entities: [{ entity: "binary_sensor.old" }],
|
||||
});
|
||||
await initialLoad;
|
||||
|
||||
expect(panel._config).toEqual(retryConfig);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user