Skip to content

Commit

Permalink
test: Add checks for the middle page after VM creation
Browse files Browse the repository at this point in the history
  • Loading branch information
yunmingyang committed Mar 24, 2024
1 parent ae6eaab commit 79bf1a9
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):

dialog.cancel()

# Check the details in the middle page after the VM creation
runner.checkMiddlePageWhenCreatingTest(TestMachinesCreate.VmDialog(self, sourceType="file", location=config.NOVELL_MOCKUP_ISO_PATH))

runner.checkMiddlePageWhenCreatingTest(TestMachinesCreate.VmDialog(self, sourceType="disk_image", location=config.NOVELL_MOCKUP_ISO_PATH))

runner.checkMiddlePageWhenCreatingTest(TestMachinesCreate.VmDialog(self, sourceType="file", location=config.NOVELL_MOCKUP_ISO_PATH, create_and_run=True))

runner.checkMiddlePageWhenCreatingTest(TestMachinesCreate.VmDialog(self, sourceType="disk_image", location=config.NOVELL_MOCKUP_ISO_PATH, create_and_run=True))

def testCreateNameGeneration(self):
config = TestMachinesCreate.TestCreateConfig
runner = TestMachinesCreate.CreateVmRunner(self)
Expand Down Expand Up @@ -1168,6 +1177,67 @@ vnc_password= "{vnc_passwd}"

return self

def checkMiddlePageWhenCreating(self):
b = self.browser

buttonSelector = "#create-and-run" if self.create_and_run else "#create-and-edit"
b.click(buttonSelector)

if not self.create_and_run:
b.wait_visible(f"h1:contains(\"Creating VM {self.name}\")")
b.click("button:contains(\"Go to VMs list\")")
b.wait_visible("#virtual-machines-listing")
b.wait_in_text(f"#vm-{self.name}-system-state", "Creating VM")

b.click(f"#vm-{self.name}-system-name")
b.wait_visible(f"h1:contains(\"Creating VM {self.name}\")")
b.click("button:contains(\"Go to VMs list\")")
b.wait_visible("#virtual-machines-listing")
b.wait_in_text(
f"#vm-{self.name}-system-state",
"Running" if self.create_and_run else "Shut off")

b.click(f"#vm-{self.name}-system-name")
b.wait_visible("#vm-details")
b.wait_in_text("h2.vm-name", self.name)
# debug
time.sleep(5)

b.click(f"#vm-{self.name}-system-action-kebab")
b.wait_visible(f"#vm-{self.name}-system-action-kebab + .pf-v5-c-menu")
b.click(f"#vm-{self.name}-system-delete")
b.wait_visible(f"#vm-{self.name}-delete-modal-dialog")
b.set_checked(f"#vm-{self.name}-delete-modal-dialog input[name=check-action-vda]", False)
b.click(f"#vm-{self.name}-delete-modal-dialog button:contains(\"Delete\")")
b.wait_not_present(f"#vm-{self.name}-delete-modal-dialog")
b.wait_visible("#virtual-machines-listing")
b.wait_not_present(f"#vm-{self.name}-system-name")

self.open().fill()
b.click(buttonSelector)

if not self.create_and_run:
b.wait_visible(f"h1:contains(\"Creating VM {self.name}\")")
b.wait_visible("button:contains(\"Go to VMs list\")")
else:
b.wait_in_text(f"#vm-{self.name}-system-state", "Creating VM")
testlib.wait(lambda: "Running" in b.text(f"#vm-{self.name}-system-state"))
b.click(f"#vm-{self.name}-system-name")
b.wait_visible("#vm-details")
b.wait_in_text("h2.vm-name", self.name)

b.click(f"#vm-{self.name}-system-action-kebab")
b.wait_visible(f"#vm-{self.name}-system-action-kebab + .pf-v5-c-menu")
b.click(f"#vm-{self.name}-system-delete")
b.wait_visible(f"#vm-{self.name}-delete-modal-dialog")
b.set_checked(f"#vm-{self.name}-delete-modal-dialog input[name=check-action-vda]", False)
b.click(f"#vm-{self.name}-delete-modal-dialog button:contains(\"Delete\")")
b.wait_not_present(f"#vm-{self.name}-delete-modal-dialog")
b.wait_visible("#virtual-machines-listing")
b.wait_not_present(f"#vm-{self.name}-system-name")

return self

def checkOsFiltered(self, present=False):
b = self.browser

Expand Down Expand Up @@ -1913,6 +1983,11 @@ vnc_password= "{vnc_passwd}"

self._assertScriptFinished().checkEnvIsEmpty()

def checkMiddlePageWhenCreatingTest(self, dialog):
dialog.open().fill().checkMiddlePageWhenCreating()

self._assertScriptFinished().checkEnvIsEmpty()

# Many of testCreate* tests use these helpers - let's keep them here to avoid repetition
def checkDialogFormValidationTest(self, dialog, errors, create=True, is_warning=False):
dialog.open() \
Expand Down

0 comments on commit 79bf1a9

Please sign in to comment.