This commit is contained in:
fuenmao
2026-11-13 14:03:38 +08:00
parent db0c578890
commit 09e8bded7e
22 changed files with 1309 additions and 607 deletions
+24
View File
@@ -303,6 +303,30 @@ test('fragrance detail retains separate nightlight and unavailable quick-release
assert.ok(!html.includes('演示智能床垫'))
})
test('wake and sleep fragrance details share controls and show their own readings', async () => {
const sleepDuration = reading('number.sleep_duration', 'number', '3')
const wakeDuration = reading('number.wake_duration', 'number', '5')
const wakeButton = reading('button.wake_release', 'button', 'unknown')
const sleep = { ...devices[2], entities: [...devices[2].entities, sleepDuration] }
const wake = device('wake', '香氛机 唤醒', 'wake-fragrance', 'Fragrance',
[reading('switch.wake', 'switch', 'on'), wakeDuration, wakeButton], { primaryControlEntityId: 'switch.wake' })
const haStatus = ref({ connected: true, devices: [sleep, wake], controlParameters: {
fragrance_duration: sleepDuration, wake_fragrance_duration: wakeDuration, wake_fragrance_quick_release: wakeButton,
} })
const sleepHtml = (await render('/device-control/fragrance', { haStatus })).html
const wakeHtml = (await render('/device-control/wake', { haStatus })).html
for (const label of ['单次出香时长', '自动出香间隔', '香薰氛围灯', '人来增香', '感应夜灯', '无人时自动关灯', '立即出香']) {
assert.ok(sleepHtml.includes(label), label)
assert.ok(wakeHtml.includes(label), label)
}
assert.match(sleepHtml, />3 秒</)
assert.doesNotMatch(sleepHtml, />5 秒</)
assert.match(wakeHtml, />5 秒</)
assert.doesNotMatch(wakeHtml, />3 秒</)
assert.match(wakeHtml, /快速出香/)
assert.doesNotMatch(wakeHtml, /查看全部能力/)
})
test('each registered device detail renders its own parameters without requesting the network', async () => {
const cases = [
[devices[0], ['灯光亮度', '灯光色温调节']],