Skip to content

Commit 4a04bb8

Browse files
committed
fix(tests): fix two CI failures in plugin tests on offscreen platform
- test_plugin_system: force-enable plugin actions before triggering them, since QAction.trigger() is a no-op on disabled actions and the workspace has 0 objects (SelectCond.at_least_one disables them) - test_plugin_description_toggle: fix ExpandableTextWidget._get_text_width() to fall back to minimumWidth() when width() returns 0 on unshown widgets (offscreen QPA platform)
1 parent f104592 commit 4a04bb8

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

datalab/tests/features/plugins/test_plugins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ def test_plugin_system(): # pylint: disable=too-many-statements
260260
found_action = False
261261
for act in actions:
262262
if act.text() == "Action Plugin 2 Updated_common":
263+
# Force-enable the action: with 0 items in the workspace
264+
# it is disabled by SelectCond.at_least_one, and
265+
# QAction.trigger() is a no-op on disabled actions.
266+
act.setEnabled(True)
263267
act.trigger()
264268
found_action = True
265269
break
@@ -331,6 +335,7 @@ def test_plugin_system(): # pylint: disable=too-many-statements
331335
found_action = False
332336
for act in actions:
333337
if act.text() == "Action Plugin 2 Updated_common":
338+
act.setEnabled(True)
334339
act.trigger()
335340
found_action = True
336341
break

datalab/widgets/expandabletext.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ def _get_text_width(self) -> int:
212212
width = self.label.viewport().width()
213213
if width <= 0:
214214
margins = self.layout().contentsMargins()
215-
width = self.width() - margins.left() - margins.right()
215+
widget_width = self.width()
216+
if widget_width <= 0:
217+
# Widget not yet shown: honour setFixedWidth / setMinimumWidth
218+
widget_width = self.minimumWidth()
219+
width = widget_width - margins.left() - margins.right()
216220
return max(width, 0)
217221

218222
def _get_collapsed_height(self) -> int:

0 commit comments

Comments
 (0)