test: Add a browser based test harness (#2641)
This commit is contained in:
@@ -24,8 +24,11 @@ interface AdvancedCameraCardActionHandlerOptions extends ActionHandlerOptions {
|
||||
allowPropagation?: boolean;
|
||||
}
|
||||
|
||||
// How long a press must last to count as a hold rather than a tap.
|
||||
export const ACTION_HANDLER_HOLD_SECONDS = 0.4;
|
||||
|
||||
class ActionHandler extends HTMLElement implements ActionHandlerInterface {
|
||||
public holdTime = 0.4;
|
||||
public holdTime = ACTION_HANDLER_HOLD_SECONDS;
|
||||
|
||||
private holdTimer = new Timer();
|
||||
private doubleClickTimer = new Timer();
|
||||
|
||||
@@ -50,7 +50,7 @@ interface TargetError {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const MEDIA_LOADING_TIMEOUT_SECONDS = 10;
|
||||
export const MEDIA_LOADING_TIMEOUT_SECONDS = 10;
|
||||
|
||||
// The per-cause presentation (localization key + icon), shared by the
|
||||
// notification metadata and the reconnecting placeholder so each cause is
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ const advancedCameraCards: AdvancedCameraCard[] = (window.advancedCameraCards ??
|
||||
// ***************************************************************************
|
||||
|
||||
@customElement('advanced-camera-card')
|
||||
class AdvancedCameraCard extends LitElement {
|
||||
export class AdvancedCameraCard extends LitElement {
|
||||
protected _controller = new CardController(
|
||||
this,
|
||||
// Callback to scroll the main pane back to the top (example usecase: scrolling
|
||||
|
||||
@@ -11,39 +11,46 @@ class HomeAssistantElementsLoadError extends AdvancedCameraCardError {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Home Assistant elements this card renders and expects to already be
|
||||
* registered.
|
||||
*/
|
||||
export const SIDE_LOADED_ELEMENTS = [
|
||||
'ha-alert',
|
||||
'ha-button',
|
||||
'ha-camera-stream',
|
||||
'ha-card',
|
||||
'ha-combo-box',
|
||||
'ha-dropdown-item',
|
||||
'ha-dropdown',
|
||||
'ha-expansion-panel',
|
||||
'ha-form',
|
||||
'ha-hls-player',
|
||||
'ha-icon-button-prev',
|
||||
'ha-icon-button',
|
||||
'ha-icon',
|
||||
'ha-md-list-item',
|
||||
'ha-md-list',
|
||||
'ha-menu-button',
|
||||
'ha-selector',
|
||||
'ha-sortable',
|
||||
'ha-spinner',
|
||||
'ha-state-icon',
|
||||
'ha-web-rtc-player',
|
||||
|
||||
'hui-conditional-element',
|
||||
|
||||
'mwc-list-item',
|
||||
'state-badge',
|
||||
];
|
||||
|
||||
/**
|
||||
* Side loads the HA elements this card needs. This trickery is unfortunate
|
||||
* necessary, see:
|
||||
* - https://github.com/thomasloven/hass-config/wiki/PreLoading-Lovelace-Elements
|
||||
*/
|
||||
export const sideLoadHomeAssistantElements = async (): Promise<void> => {
|
||||
const neededElements = [
|
||||
'ha-alert',
|
||||
'ha-button',
|
||||
'ha-camera-stream',
|
||||
'ha-card',
|
||||
'ha-combo-box',
|
||||
'ha-dropdown-item',
|
||||
'ha-dropdown',
|
||||
'ha-expansion-panel',
|
||||
'ha-form',
|
||||
'ha-hls-player',
|
||||
'ha-icon-button-prev',
|
||||
'ha-icon-button',
|
||||
'ha-icon',
|
||||
'ha-md-list-item',
|
||||
'ha-md-list',
|
||||
'ha-menu-button',
|
||||
'ha-selector',
|
||||
'ha-sortable',
|
||||
'ha-spinner',
|
||||
'ha-state-icon',
|
||||
'ha-web-rtc-player',
|
||||
'mwc-list-item',
|
||||
'state-badge',
|
||||
];
|
||||
|
||||
if (neededElements.every((element) => customElements.get(element))) {
|
||||
if (SIDE_LOADED_ELEMENTS.every((element) => customElements.get(element))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user