Skip to content

tst_mainwindow: look tree rows up in the model the tree shows now - #2422

Merged
annejan merged 2 commits into
mainfrom
test/tree-swap-waits
Nov 30, 2026
Merged

annejan merged 2 commits into
mainfrom
test/tree-swap-waits

Conversation

@annejan

@annejan annejan commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

The third macOS failure in tst_mainwindow since #2409, each around timing in the tree. This one was shareMenuReencryptAsksFirst on #2418: triggerShareAction() returned false right after the test created gone-folder.

Cause: since #2409 a change to the store makes StoreTree::reload() put a new QFileSystemModel under the proxy (swapInFresh()). The test helpers fetched the source model once and waited on it. When the swap came in between, they mapped an index of the retired model through the proxy, which gives an invalid index: no current row, so the helper gave up.

  • sourceIndexFor() / shownIndexFor(): read the model from the tree on every look.
  • selectEntry(), addEntry(), selectListed(), selectPath(), triggerShareAction(), the linked-Bank test and searchMatchesWordsLiterallyAndInOrder use them; the waits are 10 s instead of 5 s.
  • triggerShareAction() also waits after the search until the filtered tree shows the folder where a click lands, instead of checking once.
  • The waits stay on the source index, so a helper still returns false (without a test failure) for a row the tree hides on purpose, as deleteLinkedFolderRemovesOnlyTheLink expects for an entry behind a link.

Test-only; no product code changes.

Test plan

  • tst_mainwindow three times in a row: 148 passed, 0 failed
  • Six tst_mainwindow runs in parallel (load): all 148 passed
  • macOS (Qt 6.11) green on this PR

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test reliability by retrieving current tree indexes during selection and filter checks.
    • Extended certain waits to allow more time for items to become visible.
    • Added checks that a folder is visible and clickable before opening its context menu.

Since #2409 a change to the store makes StoreTree::reload() put a new
QFileSystemModel under the proxy. The tree helpers fetched the source
model once and waited on it, so a swap in between left them mapping an
index of the retired model through the proxy: an invalid current index,
and on a slow macOS runner shareMenuReencryptAsksFirst failed in
triggerShareAction() right after it made gone-folder.

sourceIndexFor() and shownIndexFor() read the model from the tree on
every look. selectEntry(), addEntry(), selectListed(), selectPath(),
triggerShareAction(), the linked-Bank test and the literal-search test
use them, and the waits are 10 s instead of 5 s. triggerShareAction()
also waits after the search until the filtered tree shows the folder
where a click lands, instead of checking once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ce9c3a40-2025-4b4e-a36c-ee004272ab53
Commits

Reviewing files that changed from the base of the PR and between d9c1ef8 and 65c4d96.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

MainWindow tests now look up source and displayed indexes from the tree’s current models. Several test waits increase from 5 to 10 seconds. The share-action helper also waits for the folder row to become visible and clickable.

Changes: MainWindow test lookup updates

Layer / File(s) Summary
Current-model index lookups
tests/auto/mainwindow/tst_mainwindow.cpp
Selection and search checks retrieve indexes from the current source and proxy models. The share-action helper waits for the folder row to appear and become clickable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • IJHack/QtPass#2409: It changes StoreTree model replacement behavior, which relates to the test updates that reacquire indexes from the current model.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · previous review d9c1e

This change only updates test helpers to look up the current models and extends some waits. It does not affect product behavior, and no merge-blocking issue was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test-only change: tst_mainwindow helpers now look up tree rows in the model the tree currently shows. The raw summary confirms the changes to sourceIndexFor/shownIndexFor helpers, …
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.
Full details: Title check

Explanation

The title names the test-only change: tst_mainwindow helpers now look up tree rows in the model the tree currently shows. The raw summary confirms the changes to sourceIndexFor/shownIndexFor helpers, selection and visibility checks, and waits in tst_mainwindow.cpp. The title is specific and matches the primary change. It does not mention the 10-second waits or the triggerShareAction change, which is acceptable because the title need not cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the tree anew,
For rows that shift from old to new.
It waits until the paths appear,
Then clicks the folder, calm and clear.
Fresh indexes guide the tests along,
While patient paws ensure they’re strong.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9ae25429-425f-4dc2-9a0d-e77f918a20cb
Commits

Reviewing files that changed from the base of the PR and between d2553bf and d9c1ef8.

Files selected for processing: 1

  • tests/auto/mainwindow/tst_mainwindow.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@coveralls

coveralls commented Nov 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 94.391%. remained the same — test/tree-swap-waits into main

@nogeenhenk nogeenhenk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at d9c1ef8. Test only. The diagnosis matches the three macOS failures since #2409 (aTreeMenuClosesWhenItsFolderIsGone, refreshAfterPushGivesWayToTheUser, shareMenuReencryptAsksFirst): a helper that fetched the source model once and waited on it could map an index of the model swapInFresh() had just retired. Reading the model from the tree on every look, and waiting in triggerShareAction() until the filtered tree shows the folder where a click lands, closes that.

Two notes, not blocking:

  • hideAllBut() and showLoaded() still set name filters on the source model of the moment. A reload swaps in a model from makeModel() with the *.gpg filter again, so a hide staged that way can come undone. The tests that use it detect that and QSKIP(kCannotStage), so it shows up as a skip, not a failure, but a skip on the slow macOS runner may hide what the test is for.
  • The negative checks right after a filter (!shown(notes), and both after "(") also pass while the tree is between models and shows nothing. They cannot fail spuriously, but they can pass without having looked.

CI: every check is green, the macOS test job included, which is the one this PR is about. Only macOS dmg was cancelled without a step result, a shortage of macOS runners at GitHub; the maintainer asked me not to count it.


Generated by Claude Code

@nogeenhenk nogeenhenk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at d9c1ef8; 65c4d96 only merges main (#2418) into it. Test only. The diagnosis matches the three macOS failures since #2409 (aTreeMenuClosesWhenItsFolderIsGone, refreshAfterPushGivesWayToTheUser, shareMenuReencryptAsksFirst): a helper that fetched the source model once and waited on it could map an index of the model swapInFresh() had just retired. Reading the model from the tree on every look, and waiting in triggerShareAction() until the filtered tree shows the folder where a click lands, closes that.

Two notes, not blocking:

  • hideAllBut() and showLoaded() still set name filters on the source model of the moment. A reload swaps in a model from makeModel() with the *.gpg filter again, so a hide staged that way can come undone. The tests that use it detect that and QSKIP(kCannotStage), so it shows up as a skip, not a failure, but a skip on the slow macOS runner may hide what the test is for.
  • The negative checks right after a filter (!shown(notes), and both after "(") also pass while the tree is between models and shows nothing. They cannot fail spuriously, but they can pass without having looked.

CI: every check is green, the macOS test job included, which is the one this PR is about. Only macOS dmg was cancelled without a step result, a shortage of macOS runners at GitHub; the maintainer asked me not to count it.


Generated by Claude Code

@annejan
annejan merged commit 041091b into main Nov 30, 2026
32 checks passed
@annejan
annejan deleted the test/tree-swap-waits branch November 30, 2026 22:59
annejan added a commit that referenced this pull request Nov 30, 2026
…es (#2423)

Follow-up to #2422, for the notes in its review, plus the fourth macOS
tree flake.

waitForQuietTree() waits until the store tree has been quiet for a
second: no reload queued, no fresh model being built, no listing still
under way after a swap. StoreTree names tst_mainwindow a friend for it.

- newSearchTextCancelsAWaitingOpen and acceptedSettingsCancelAWaitingOpen
  call it before staging a name filter, so a swap cannot undo the stage
  and turn the test into a kCannotStage skip.
- searchMatchesWordsLiterallyAndInOrder calls it first and checks at the
  end that the model it looked at is still the tree's, so its "not shown"
  checks cannot pass on a tree between two models.
- aTreeMenuClosesWhenItsFolderIsGone uses it instead of a fixed
  qWait(1000), and when the menu has to be closed the failure names the
  tree's state, so a next macOS failure shows which step stalled.

Test-only apart from the friend declaration.

Signed-off-by: Anne Jan Brouwer <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants