diff --git a/homeassistant/components/workday/config_flow.py b/homeassistant/components/workday/config_flow.py index 20d9040e527..f3b139b27c0 100644 --- a/homeassistant/components/workday/config_flow.py +++ b/homeassistant/components/workday/config_flow.py @@ -155,6 +155,7 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None: subdiv=province, years=year, language=language, + categories=[PUBLIC, *user_input.get(CONF_CATEGORY, [])], ) else: diff --git a/tests/components/workday/test_config_flow.py b/tests/components/workday/test_config_flow.py index c618c5fd830..b9cbde31e54 100644 --- a/tests/components/workday/test_config_flow.py +++ b/tests/components/workday/test_config_flow.py @@ -14,6 +14,7 @@ from homeassistant.components.workday.const import ( CONF_CATEGORY, CONF_EXCLUDES, CONF_OFFSET, + CONF_PROVINCE, CONF_REMOVE_HOLIDAYS, CONF_WORKDAYS, DEFAULT_EXCLUDES, @@ -702,6 +703,53 @@ async def test_form_with_categories(hass: HomeAssistant) -> None: } +async def test_form_with_categories_can_remove_day(hass: HomeAssistant) -> None: + """Test optional categories, days can be removed.""" + + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + assert result["type"] is FlowResultType.FORM + + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + { + CONF_NAME: "Workday Sensor", + CONF_COUNTRY: "CH", + }, + ) + await hass.async_block_till_done() + result3 = await hass.config_entries.flow.async_configure( + result2["flow_id"], + { + CONF_PROVINCE: "FR", + CONF_EXCLUDES: DEFAULT_EXCLUDES, + CONF_OFFSET: DEFAULT_OFFSET, + CONF_WORKDAYS: DEFAULT_WORKDAYS, + CONF_ADD_HOLIDAYS: [], + CONF_REMOVE_HOLIDAYS: ["Berchtoldstag"], + CONF_LANGUAGE: "de", + CONF_CATEGORY: [OPTIONAL], + }, + ) + await hass.async_block_till_done() + + assert result3["type"] is FlowResultType.CREATE_ENTRY + assert result3["title"] == "Workday Sensor" + assert result3["options"] == { + "name": "Workday Sensor", + "country": "CH", + "excludes": ["sat", "sun", "holiday"], + "days_offset": 0, + "workdays": ["mon", "tue", "wed", "thu", "fri"], + "add_holidays": [], + "province": "FR", + "remove_holidays": ["Berchtoldstag"], + "language": "de", + "category": ["optional"], + } + + async def test_options_form_removes_subdiv(hass: HomeAssistant) -> None: """Test we get the form in options when removing a configured subdivision."""