Skip to content

Add regression test for clipped button labels across all UI languages #928

Description

@AgreeDK

Follow-up to #927 (Part 2).

Background

#927 fixed button labels being clipped in several dialogs, caused by
hardcoded setMaximumWidth() / setFixedWidth() on text buttons. The
problem only showed up in some languages (de, de_CH, pl, cs, es, fr, pt, nl),
so it went unnoticed until a user reported it. Nothing in CI would catch it if
it came back through a new dialog, a new language, or a longer translation.

Proposal

Add a test that, for every language in AVAILABLE_LANGUAGES, builds the
relevant dialogs and asserts that every QPushButton with a text label is at
least as wide as its sizeHint():

assert button.width() >= button.sizeHint().width()

The test should compare each button against its own sizeHint() rather than
against absolute pixel values. That way it stays valid regardless of platform,
font and display scaling.

Scope

At minimum, the dialogs touched by #927:

  • dialogs/database_dialog.py (New Database)
  • dialogs/gps_dialog.py
  • dialogs/widgets.py (path row with Browse button, used by the Welcome Wizard)
  • cache_detail.py (decode hint button)
  • dialogs/filter_dialog.py and dialogs/column_dialog.py (Save button)
  • dialogs/coord_converter_dialog.py, projection_dialog.py,
    midpoint_dialog.py, corrected_coords_dialog.py (Copy buttons)

A generic approach that walks all dialogs and collects every QPushButton
via findChildren() would be better, if it's practical to instantiate them in
a test.

Notes

  • Use the existing pytest-qt setup and the gui marker (see
    tests/unit-tests/test_dialog_widgets.py for an existing pattern).
  • Skip icon-only buttons (🗑, ▲/▼, ✕ etc.). They are intentionally narrow and
    have no translated text.
  • The dialogs must be shown or have their layout activated before measuring,
    otherwise width() doesn't reflect the actual layout.
  • Some dialogs may need a database or other fixtures to construct. The global
    isolation in tests/conftest.py (Test suite can leak into the real user profile if a test lacks its own install_dir/logging isolation #829) should keep this away from real user
    data.
  • Parametrize over languages so a failure names the exact language and
    button, e.g. test_buttons_not_clipped[de-database_dialog].

Acceptance criteria

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions