Skip to content

Commit

Permalink
test: Check for uptime in confirmation dialogs
Browse files Browse the repository at this point in the history
This behaves differently depending on whether or not the session is
privileged to read the log file. Add an invisible span to the dialog so
that the test has something to wait for.
  • Loading branch information
martinpitt committed Jan 5, 2024
1 parent cd35e5a commit 8e04059
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/vm/confirmDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ export const ConfirmDialog = ({ idPrefix, actionsList, title, titleIcon, vm }) =
titleIconVariant={titleIcon}
isOpen
footer={actions}>
{uptime &&
<DescriptionList isHorizontal isFluid>
<DescriptionListGroup>
<DescriptionListTerm>{_("Uptime")}</DescriptionListTerm>
<DescriptionListDescription id="uptime">{distanceToNow(new Date(uptime))}</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>}
{uptime
? <DescriptionList isHorizontal isFluid>
<DescriptionListGroup>
<DescriptionListTerm>{_("Uptime")}</DescriptionListTerm>
<DescriptionListDescription id="uptime">{distanceToNow(new Date(uptime))}</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
/* for tests */
: <span className="uptime-not-available" />
}
</Modal>
);
};
6 changes: 6 additions & 0 deletions test/check-machines-lifecycle
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ class TestMachinesLifecycle(VirtualMachinesCase):
# Check uptime
b.click("#vm-subVmTest2-system-shutdown-button")
b.wait_visible("#vm-subVmTest2-system-confirm-action-modal")
# it starts with "less than a minute", so this should be reasonably race free
if superuser:
b.wait_in_text("#uptime", "minute")
else:
# unprivileged sessions can't read the log
b._wait_present(".uptime-not-available")
if run_pixel_tests:
b.assert_pixels("#vm-subVmTest2-system-confirm-action-modal", "shutdown-confirm-dialog")
b.click(".pf-v5-c-modal-box__footer button:contains(Cancel)")
Expand Down

0 comments on commit 8e04059

Please sign in to comment.