Skip to content

Commit 89a22c6

Browse files
authored
fix: stablize test in flow-component (#22812)
Part of #22767 Similar to PR #22808. This PR fixes 1 flaky test in flow-html-component: HtmlComponentSmokeTest#testAllHtmlComponents. HtmlComponentSmokeTest#testAllHtmlComponents: Add check before testing each setter method to make sure isEnabled is set to true for any instance with this attribute.
1 parent 16d1c95 commit 89a22c6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

flow-html-components/src/test/java/com/vaadin/flow/component/html/HtmlComponentSmokeTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.junit.Test;
4141

4242
import com.vaadin.flow.component.Component;
43+
import com.vaadin.flow.component.HasEnabled;
4344
import com.vaadin.flow.component.HasText;
4445
import com.vaadin.flow.component.HtmlComponent;
4546
import com.vaadin.flow.component.HtmlContainer;
@@ -174,8 +175,12 @@ private static void testStringConstructor(
174175
private static void testSetters(HtmlComponent instance) {
175176
Arrays.stream(instance.getClass().getMethods())
176177
.filter(HtmlComponentSmokeTest::isSetter)
177-
.filter(m -> !isSpecialSetter(m))
178-
.forEach(m -> testSetter(instance, m));
178+
.filter(m -> !isSpecialSetter(m)).forEach(m -> {
179+
if (instance instanceof HasEnabled) {
180+
((HasEnabled) instance).setEnabled(true);
181+
}
182+
testSetter(instance, m);
183+
});
179184
}
180185

181186
private static boolean isSetter(Method method) {

0 commit comments

Comments
 (0)