From 30e4a487d0c00364c0f9c09b3958c1b069183552 Mon Sep 17 00:00:00 2001 From: yunmingyang Date: Fri, 16 Dec 2022 02:50:19 +0800 Subject: [PATCH] test: Add checks for the middle page after VM creation --- test/check-machines-create | 85 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/test/check-machines-create b/test/check-machines-create index a72b481c7..c555ebaa5 100755 --- a/test/check-machines-create +++ b/test/check-machines-create @@ -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) @@ -1168,6 +1177,77 @@ 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 + print("---------Start for the first removing---------") + b.eval_js('window.debugging = "machines"') + 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\")") + print("---------End for the first removing---------") + 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) + + # debug + # It seems that the difference between removing success and failure is doUsagePolling and reducer "UPDATE_VM" action. + # Thus, try to reload the page to trigger these event manually to see whether it could resolve the problem + b.reload() + b.enter_page('/machines') + print("---------Start for the second removing---------") + 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\")") + print("---------End for the second removing---------") + 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 @@ -1913,6 +1993,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() \