Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable visual editor #42

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/horizonCard/HorizonCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/components/horizonCard/HorizonCard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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', () => {
Expand Down