From 6191b7553eed8a5e1de1d7a384927e3016d046c2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 5 Oct 2026 21:07:37 -0500 Subject: [PATCH] [light] Cover get_effects() as published configs use it in the component test (#20203) --- tests/components/light/common.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/components/light/common.yaml b/tests/components/light/common.yaml index 3cf2c59223..64406afda8 100644 --- a/tests/components/light/common.yaml +++ b/tests/components/light/common.yaml @@ -28,6 +28,21 @@ esphome: ESP_LOGI("test", "Name length: %d", (int) name.size()); } + # get_effects() shapes used by published configs and external components + - lambda: |- + const auto &effects = id(test_monochromatic_light).get_effects(); + auto &same = id(test_monochromatic_light).get_effects(); + uint32_t total = effects.size(); + for (auto *effect : effects) { + ESP_LOGD("test", "Effect %s", effect->get_name().c_str()); + } + if (total > 0) { + ESP_LOGD("test", "First %s", effects.at(0)->get_name().c_str()); + // Raw pointer iterators on purpose: external code binds std::find's result to `const auto *` + auto *it = std::find(same.begin(), same.end(), effects[0]); + ESP_LOGD("test", "Index %d", (int) (it - same.begin())); + } + # Test LightState::get_effect_name() returns StringRef - lambda: |- // Test LightState::get_effect_name() returns StringRef