Skip to content

Add GUI widget tests and fix notify calls in qtitem_store - #843

Merged
smathot merged 1 commit into
open-cogsci:nightingalefrom
hieudoanm:add-gui-webbrowser-tests
Dec 1, 2026
Merged

smathot merged 1 commit into
open-cogsci:nightingalefrom
hieudoanm:add-gui-webbrowser-tests

Conversation

@hieudoanm

Copy link
Copy Markdown
Contributor

Problem

libqtopensesame had almost no test coverage (~5%), and several recent GUI fixes shipped without regression tests — including the embedded-browser help commands (#838), the item-tree crash on rebuild (#836), and the item copy/paste insertion path. Writing these tests also exposed a real bug: QtItemStore.rename() called self.notify() on its failure paths, but QtItemStore has no notify attribute, so renaming a nonexistent item raised AttributeError instead of showing the intended notification.

Solution

Add three test modules to tests/gui/ that boot a real QtOpenSesame window offscreen (QT_QPA_PLATFORM=offscreen, analytics extension disabled, code-editor worker pool disabled) and exercise the widgets the application actually uses:

  • test_webbrowser.py — Webbrowser.command() for help plugin <name>, help extension <name> (the Fix help extension/plugin command in embedded browser #838 fix: folder resolution and .md loading) and help <topic> routing to open_help
  • test_tree_overview.py — overview tree population, item selection, rename through the itemChanged/text_edited path, fold state, unused items, copy→paste through drop_event_item_new (the same insertion code as drag-and-drop, adjacent to the Error when making an unlinked copy in the experiment tree #836 fix), child deletion with full tree rebuild, and permanent deletion
  • test_item_store.py — qtitem_store item creation (including the missing_item fallback for unloadable plugins), renaming with tree/experiment sync and unsaved flag, rename edge cases, and MarkdownParser.to_html()/highlight() used for .md help pages

Also fixes qtitem_store.py: self.notify(...) → self.main_window.notify(...) on the three rename-failure paths.

Coverage impact

  • libqtopensesame/misc/qtitem_store.py → 90%
  • libqtopensesame/misc/markdown_parser.py → 85%
  • libqtopensesame/widgets/webbrowser.py → 64%
  • libqtopensesame/widgets/tree_item_item.py → 63%
  • libqtopensesame/widgets/tree_overview.py → 40%

Why these tests?

  • They run the real application code paths: a real QtOpenSesame window, real plugin/extension managers, real item store and tree widgets — not mocks of the units under test.
  • They are deterministic: everything runs offscreen with the analytics extension disabled; modal dialogs (QMessageBox) are mocked where needed.
  • The code-editor worker pool is disabled in setUpClass (pyqt_code_editor.worker.manager.start_worker_pool), since the tests don't use the code editor and the spawned worker processes are unneeded.

Test plan

@hieudoanm
hieudoanm force-pushed the add-gui-webbrowser-tests branch from 98c23ee to 7cad9ad Compare November 24, 2026 11:28
@hieudoanm
hieudoanm force-pushed the add-gui-webbrowser-tests branch from a16018d to 2f75015 Compare November 29, 2026 10:29
@smathot

smathot commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for your work again! 👍 I've seen that you did some work on this PR after opening it. Is it ready to be reviewed/ merged?

(For future reference, it's best to open the PR only once you're satisfied that it's ready for review. Or alternatively, to open it with a clear indication that it's WIP and then give me a clear ping once it's ready.)

@hieudoanm

Copy link
Copy Markdown
Contributor Author

Yes, it is ready to be reviewed and merged, @smathot! I have to re-push because the CI failed the first time due to GitHub being flaky/inconsistency!

@smathot
smathot merged commit 0c83721 into open-cogsci:nightingale Dec 1, 2026
5 checks passed
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