test: Add a test harness for the built card (#2653)

Mounts the card from `dist/` the way Home Assistant does, by URL with a
HACS tag, and asserts the entry stays a facade, that no chunk imports
it, that the browser is served the file unmodified, and that the card
starts up and fetches a language chunk lazily.

Runs in Chromium, Firefox and WebKit, so a change of bundler or minifier
is checked against every engine.
This commit is contained in:
Dermot Duffy
2026-08-03 21:50:21 -07:00
committed by GitHub
parent 18ea725564
commit 2d124fe3cd
18 changed files with 483 additions and 50 deletions
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import type { RawAdvancedCameraCardConfig } from '../../../src/config/types';
import { MountedCard } from '../../browser/mounted-card';
import { MountedCardFactory, type MountedCard } from '../../browser/mounted-card';
import {
CARD_INITIALIZED_MESSAGE,
createInitializedAutomation,
@@ -24,7 +24,7 @@ const createConfig = (
const mount = async (
overrides?: Partial<RawAdvancedCameraCardConfig>,
): Promise<MountedCard> =>
await MountedCard.create(
await MountedCardFactory.createFromSource(
createConfig(overrides),
createStillCameraHASS({ cameras: [OTHER_CAMERA_ENTITY] }),
);