Skip to content

LoginOverlayTester.notUsableReasons() has an inverted isOpened() check #114

Description

@mcollovati

Summary

LoginOverlayTester.notUsableReasons(Consumer<String>) has an inverted condition: it reports the "not opened" reason exactly when the overlay is opened, and reports no reason when the overlay is closed (which is precisely when the component is not usable).

Location

shared/src/main/java/com/vaadin/flow/component/login/LoginOverlayTester.java

@Override
public boolean isUsable() {
    return super.isUsable() && getComponent().isOpened();   // not usable when NOT opened
}

@Override
protected void notUsableReasons(Consumer<String> collector) {
    super.notUsableReasons(collector);
    if (getComponent().isOpened()) {        // <-- inverted
        collector.accept("not opened");
    }
}

Impact

isUsable() returns false when the overlay is not opened, but notUsableReasons() only adds "not opened" when it is opened. As a result, ensureComponentIsUsable() on a closed LoginOverlay throws an IllegalStateException whose reason list is missing the actual cause ("not opened"), producing a misleading "... is not usable" message with no explanation. Conversely, a reason is collected in the case where the component is usable.

Expected

The condition should be negated so the reason matches the isUsable() logic:

if (!getComponent().isOpened()) {
    collector.accept("not opened");
}

🤖 Filed with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions