Skip to content

test(passworddialog): nine widget tests for the previously-untested API#1478

Merged
annejan merged 1 commit into
mainfrom
tests/passworddialog-gaps
May 13, 2026
Merged

test(passworddialog): nine widget tests for the previously-untested API#1478
annejan merged 1 commit into
mainfrom
tests/passworddialog-gaps

Conversation

@annejan
Copy link
Copy Markdown
Member

@annejan annejan commented May 13, 2026

Summary

`PasswordDialog` had decent `setPassword`/`getPassword` round-trip coverage in `tst_ui.cpp` (4 tests + the 2 named `passwordDialog*` ones) but its other public API was largely untested. This PR fills that gap.

Tests added

Case API exercised
`passwordDialogShowCheckboxTogglesEchoMode` `on_checkBoxShow_stateChanged` — flips `QLineEdit::echoMode` Password ↔ Normal
`passwordDialogSetLengthUpdatesSpinBox` `setLength(int)`
`passwordDialogSetPasswordCharTemplateUpdatesCombo` `setPasswordCharTemplate(int)`
`passwordDialogUsePwgenDisablesTemplateSelector` `usePwgen(bool)`
`passwordDialogSetPassPopulatesField` `setPass(output)`
`passwordDialogSetAvailableTemplatesAppliesDefault` `setAvailableTemplates(templates, defaultName)`
`passwordDialogCycleTemplateAdvancesToNext` `cycleTemplate()` — creditcard → login
`passwordDialogCycleTemplateWrapsToFirst` `cycleTemplate()` — login (last) wraps to creditcard
`passwordDialogCycleTemplateNoOpWhenEmpty` `cycleTemplate()` with no registered templates is a no-op

Each test instantiates a real PasswordDialog (no Pass-singleton required — the dialog is independent of QtPassSettings::getPass), drives an input, and asserts on observable widget state via `findChild<T*>`.

Test plan

  • `qmake6 -r && make -j4` clean
  • `tests/auto/ui/tst_ui` — 55/55 (was 46, +9)
  • clang-format applied

Includes

Added `QCheckBox`, `QComboBox`, `QHash`, `QLabel`, `QSpinBox` to the test file's include block for the newly addressed widget types.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for password dialog functionality, including show/hide password toggle, length synchronization, character template selection, template cycling behavior, and password field operations.

Review Change Stack

PasswordDialog had decent setPassword/getPassword round-trip coverage
in tst_ui.cpp but its other public API was largely untested. Fill the
gap:

- passwordDialogShowCheckboxTogglesEchoMode: the "Show password"
  checkbox flips QLineEdit::echoMode between Password and Normal.
- passwordDialogSetLengthUpdatesSpinBox: setLength() writes through to
  the QSpinBox.
- passwordDialogSetPasswordCharTemplateUpdatesCombo: setPasswordChar
  Template() selects the matching combo-box index.
- passwordDialogUsePwgenDisablesTemplateSelector: usePwgen(true) greys
  out the in-app template selector + label (pwgen takes over);
  usePwgen(false) restores them.
- passwordDialogSetPassPopulatesField: setPass() is a thin wrapper
  around setPassword(); first line lands in getPassword().
- passwordDialogSetAvailableTemplatesAppliesDefault: registering
  templates and naming a default triggers setTemplate() with that
  template's fields — visible as named QLineEdits in the form.
- passwordDialogCycleTemplateAdvancesToNext: Ctrl+T equivalent moves
  to the next alphabetical template (creditcard -> login).
- passwordDialogCycleTemplateWrapsToFirst: cycling past the last
  template wraps back (login -> creditcard).
- passwordDialogCycleTemplateNoOpWhenEmpty: cycleTemplate() with no
  templates registered is a no-op; no template fields appear.

Build clean, 55/55 ui tests pass (was 46, +9).

Plus three include additions for the widgets newly addressed by
findChild<T*>: QCheckBox, QComboBox, QHash, QLabel, QSpinBox.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0a6fe8d7-f6b6-42a8-93b3-11836d6fb45b

📥 Commits

Reviewing files that changed from the base of the PR and between bbc94a5 and ddfabf7.

📒 Files selected for processing (1)
  • tests/auto/ui/tst_ui.cpp

📝 Walkthrough

Walkthrough

This change expands the tst_ui test suite with nine new PasswordDialog UI test cases covering echo-mode toggling, widget state synchronization (length and template selection), pwgen mode behavior, password field population, available template application, and template cycling including wraparound and empty-list handling.

Changes

PasswordDialog UI Test Suite

Layer / File(s) Summary
PasswordDialog UI tests with headers and implementations
tests/auto/ui/tst_ui.cpp
Qt checkbox, label, line edit, spinbox, and hash headers are added to support widget lookup and state assertions. Nine test method declarations cover echo-mode, length sync, template selection, pwgen disabling, setPass behavior, available templates, and template cycling. Implementations use findChild to locate widgets by objectName and verify expected state transitions after calling PasswordDialog methods.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • IJHack/QtPass#1150: Adds new UI tests for PasswordDialog behaviors directly tied to PasswordDialog implementation changes (setPassword/getPassword/setTemplate and templateLines state).
  • IJHack/QtPass#867: Adds QtTest cases exercising PasswordDialog slot-driven UI behavior, aligned with PasswordDialog header syntax updates.
  • IJHack/QtPass#1082: Adds UI tests exercising PasswordDialog behaviors including template cycling and generated-password handling, overlapping with PasswordDialog code path changes.

Poem

🐰 A rabbit hops through dialog states,
Testing echo modes and checkbox fates,
Templates cycle, spin-boxes sync,
Each assertion brings code to the brink,
Nine tests now dance in QtPass delight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding nine widget tests for PasswordDialog's previously-untested API.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tests/passworddialog-gaps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 32.59% (+0.4%) from 32.144% — tests/passworddialog-gaps into main

@annejan annejan merged commit 46243a3 into main May 13, 2026
24 of 25 checks passed
@annejan annejan deleted the tests/passworddialog-gaps branch May 13, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants