From 97e3f651efa08b7ebbb64211a30868ee19640b39 Mon Sep 17 00:00:00 2001 From: Pavel Mihaylov Date: Tue, 28 Mar 2023 23:10:11 +0300 Subject: [PATCH] Disable visual editor Visual editor doesn't work since Home Assistant 2022.3, see https://developers.home-assistant.io/blog/2022/02/18/paper-elements/ --- src/components/horizonCard/HorizonCard.ts | 8 +++---- .../horizonCard/HorizonCard.spec.ts | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/horizonCard/HorizonCard.ts b/src/components/horizonCard/HorizonCard.ts index d60f3d1..15061dc 100644 --- a/src/components/horizonCard/HorizonCard.ts +++ b/src/components/horizonCard/HorizonCard.ts @@ -7,7 +7,6 @@ import { Constants } from '../../constants' import { EHorizonCardErrors, IHorizonCardConfig, THorizonCardData, THorizonCardTimes, TSunInfo } from '../../types' import { HelperFunctions } from '../../utils/HelperFunctions' import { I18N } from '../../utils/I18N' -import { HorizonCardEditor } from '../horizonCardEditor' import { HorizonErrorContent } from '../HorizonErrorContent' import { HorizonCardContent } from './HorizonCardContent' @@ -42,9 +41,10 @@ export class HorizonCard extends LitElement { this.processLastHass() } - static getConfigElement (): HTMLElement { - return document.createElement(HorizonCardEditor.cardType) - } + // Visual editor disabled because it's broken, see https://developers.home-assistant.io/blog/2022/02/18/paper-elements/ + // static getConfigElement (): HTMLElement { + // return document.createElement(HorizonCardEditor.cardType) + // } // called by HASS whenever config changes public setConfig (config: IHorizonCardConfig): void { diff --git a/tests/unit/components/horizonCard/HorizonCard.spec.ts b/tests/unit/components/horizonCard/HorizonCard.spec.ts index ce15048..2985100 100644 --- a/tests/unit/components/horizonCard/HorizonCard.spec.ts +++ b/tests/unit/components/horizonCard/HorizonCard.spec.ts @@ -2,7 +2,6 @@ import { HomeAssistant } from 'custom-card-helpers' import { css, CSSResult } from 'lit' import { HorizonCard } from '../../../../src/components/horizonCard' -import { HorizonCardEditor } from '../../../../src/components/horizonCardEditor' import { Constants } from '../../../../src/constants' import { EHorizonCardErrors, IHorizonCardConfig, THorizonCardData } from '../../../../src/types' import { CustomSnapshotSerializer, TemplateResultTestHelper } from '../../../helpers/TestHelpers' @@ -73,17 +72,18 @@ describe('HorizonCard', () => { }) }) - describe('getConfigElement', () => { - it('creates and return a horizon card config element', () => { - const expectedElement = document.createElement('div') - const createElementSpy = jest.spyOn(document, 'createElement').mockReturnValueOnce(expectedElement) - const result = HorizonCard.getConfigElement() - - expect(result).toEqual(expectedElement) - expect(createElementSpy).toHaveBeenCalledTimes(1) - expect(createElementSpy).toHaveBeenCalledWith(HorizonCardEditor.cardType) - }) - }) + // Visual editor disabled because it's broken, see https://developers.home-assistant.io/blog/2022/02/18/paper-elements/ + // describe('getConfigElement', () => { + // it('creates and return a horizon card config element', () => { + // const expectedElement = document.createElement('div') + // const createElementSpy = jest.spyOn(document, 'createElement').mockReturnValueOnce(expectedElement) + // const result = HorizonCard.getConfigElement() + // + // expect(result).toEqual(expectedElement) + // expect(createElementSpy).toHaveBeenCalledTimes(1) + // expect(createElementSpy).toHaveBeenCalledWith(HorizonCardEditor.cardType) + // }) + // }) describe('setConfig', () => { it('overrides old config with new values', () => {