|
1 | | -from selenium.common.exceptions import NoSuchElementException |
2 | 1 | from wait_for import wait_for |
3 | 2 | from widgetastic.utils import ParametrizedLocator |
4 | 3 | from widgetastic.widget import Text, View |
5 | | -from widgetastic_patternfly import Button, Tab |
| 4 | +from widgetastic_patternfly import Tab |
6 | 5 | from widgetastic_patternfly4.switch import Switch |
7 | 6 | from widgetastic_patternfly5 import Button as PF5Button, Menu |
8 | 7 | from widgetastic_patternfly5.ouia import Text as PF5OUIAText |
@@ -44,73 +43,54 @@ class InventoryItemsView(Accordion): |
44 | 43 | DESCRIPTION_LOCATOR = ( |
45 | 44 | './/span[contains(@class, "pf-v5-c-label pf-m-blue pf-m-outline account-icon")]' |
46 | 45 | ) |
47 | | - STATUS_ELEMENTS = './/div[contains(@class, "status")]/div[contains(@class, "item")]' |
48 | | - |
49 | | - @View.nested |
50 | | - class generating(InventoryTab): |
51 | | - process = Text('.//div[contains(@class, "tab-header")]/div[1]') |
52 | | - generate = Button('contains', 'Generate') |
53 | | - download_report = Button('Download Report') |
54 | | - terminal = Text( |
55 | | - './/div[contains(@class, "report-generate")]//div[contains(@class, "terminal")]' |
56 | | - ) |
57 | | - scheduled_run = Text('.//div[contains(@class, "scheduled_run")]') |
58 | | - |
59 | | - @View.nested |
60 | | - class uploading(InventoryTab): |
61 | | - process = Text('.//div[contains(@class, "tab-header")]/div[1]') |
62 | | - terminal = Text( |
63 | | - './/div[contains(@class, "report-upload")]//div[contains(@class, "terminal")]' |
64 | | - ) |
65 | 46 |
|
66 | | - @property |
67 | | - def is_generating(self): |
68 | | - try: |
69 | | - self.parent_browser.element(f'{self.STATUS_ELEMENTS}[1]') |
70 | | - return True |
71 | | - except NoSuchElementException: |
72 | | - return False |
| 47 | + # Task action buttons |
| 48 | + generate_and_upload = PF5Button('Generate and upload report') |
| 49 | + generate_report = PF5Button('Generate report') |
| 50 | + download_report = PF5Button('Download report') |
73 | 51 |
|
74 | | - @property |
75 | | - def is_uploading(self): |
76 | | - try: |
77 | | - self.parent_browser.element(f'{self.STATUS_ELEMENTS}[2]') |
78 | | - return True |
79 | | - except NoSuchElementException: |
80 | | - return False |
81 | | - |
82 | | - @property |
83 | | - def status(self): |
84 | | - if self.is_generating: |
85 | | - return 'generating' |
86 | | - if self.is_uploading: |
87 | | - return 'uploading' |
88 | | - return 'idle' |
| 52 | + task_status = Text(locator='.//div[contains(@class, "pf-v5-c-progress__description")]') |
| 53 | + report_saved_to = Text( |
| 54 | + locator=( |
| 55 | + './/dt[.//span[contains(text(), "Report saved to")]]/following-sibling::dd[1]' |
| 56 | + '//div[contains(@class, "pf-v5-c-description-list__text")]' |
| 57 | + ) |
| 58 | + ) |
89 | 59 |
|
90 | 60 | @property |
91 | 61 | def is_active(self): |
| 62 | + """Check if this accordion item is expanded.""" |
92 | 63 | classes = self.browser.classes(self) |
93 | 64 | return any('expand-active' in class_ for class_ in classes) |
94 | 65 |
|
95 | 66 | def child_widget_accessed(self, widget): |
| 67 | + """Automatically expand the accordion when accessing child widgets.""" |
96 | 68 | if not self.is_active: |
97 | 69 | self.click() |
98 | 70 |
|
99 | 71 | def read(self, widget_names=None): |
100 | | - final_dict = { |
101 | | - 'generating': self.generating.read(), |
102 | | - 'status': self.status, |
| 72 | + """Read the current state of the view including all settings.""" |
| 73 | + result = { |
| 74 | + 'generate_and_upload_displayed': self.generate_and_upload.is_displayed, |
| 75 | + 'generate_report_displayed': self.generate_report.is_displayed, |
| 76 | + 'download_report_displayed': self.download_report.is_displayed, |
103 | 77 | 'obfuscate_hostnames': self.parent.obfuscate_hostnames.read(), |
104 | 78 | 'obfuscate_ips': self.parent.obfuscate_ips.read(), |
105 | 79 | 'exclude_packages': self.parent.exclude_packages.read(), |
106 | 80 | } |
107 | | - if self.uploading.is_displayed: |
108 | | - final_dict['uploading'] = self.uploading.read() |
| 81 | + |
| 82 | + # Include auto_update if it's displayed |
109 | 83 | if self.parent.auto_update.is_displayed: |
110 | | - final_dict['auto_update'] = self.parent.auto_update.read() |
111 | | - return final_dict |
| 84 | + result['auto_update'] = self.parent.auto_update.read() |
| 85 | + |
| 86 | + if self.report_saved_to.is_displayed: |
| 87 | + result['report_saved_to'] = self.report_saved_to.read() |
| 88 | + result['task_status'] = self.task_status.read() |
| 89 | + |
| 90 | + return result |
112 | 91 |
|
113 | 92 | def fill(self, values): |
| 93 | + """This view is read-only.""" |
114 | 94 | raise ReadOnlyWidgetError('View is read only, fill is prohibited') |
115 | 95 |
|
116 | 96 |
|
|
0 commit comments