Section support for data entry flows (#118369)
* Add expandable support for data entry form flows * Update config_validation.py * optional options * Adjust * Correct translations of data within sections * Update homeassistant/components/kitchen_sink/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Add missing import * Update tests/components/kitchen_sink/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Format code * Match frontend when serializing * Move section class to data_entry_flow * Correct serializing * Fix import in kitchen_sink * Move and update test --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
parent
3d1ff72a88
commit
0545ed8082
9 changed files with 222 additions and 1 deletions
|
@ -10,6 +10,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.util.decorator import Registry
|
||||
|
||||
from .common import (
|
||||
|
@ -1075,3 +1076,25 @@ def test_deprecated_constants(
|
|||
import_and_test_deprecated_constant_enum(
|
||||
caplog, data_entry_flow, enum, "RESULT_TYPE_", "2025.1"
|
||||
)
|
||||
|
||||
|
||||
def test_section_in_serializer() -> None:
|
||||
"""Test section with custom_serializer."""
|
||||
assert cv.custom_serializer(
|
||||
data_entry_flow.section(
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional("option_1", default=False): bool,
|
||||
vol.Required("option_2"): int,
|
||||
}
|
||||
),
|
||||
{"collapsed": False},
|
||||
)
|
||||
) == {
|
||||
"expanded": True,
|
||||
"schema": [
|
||||
{"default": False, "name": "option_1", "optional": True, "type": "boolean"},
|
||||
{"name": "option_2", "required": True, "type": "integer"},
|
||||
],
|
||||
"type": "expandable",
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue