From 3353f4e9649e01b3f36511c849c5cb304b853338 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 25 Aug 2023 15:26:58 +0200 Subject: [PATCH 1/2] webui: do not reset validity of step id moving to the same step (#2233805) Resolves: rhbz#2233805 Related: rhbz#2231339 --- ui/webui/src/components/AnacondaWizard.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/webui/src/components/AnacondaWizard.jsx b/ui/webui/src/components/AnacondaWizard.jsx index 746b4b21de6..70c5e21bbd4 100644 --- a/ui/webui/src/components/AnacondaWizard.jsx +++ b/ui/webui/src/components/AnacondaWizard.jsx @@ -206,11 +206,12 @@ export const AnacondaWizard = ({ dispatch, isBootIso, osRelease, storageData, lo }; const steps = createSteps(stepsOrder); - const goToStep = (newStep) => { - // first reset validation state to default - setIsFormValid(false); - - cockpit.location.go([newStep.id]); + const goToStep = (newStep, prevStep) => { + if (prevStep.prevId !== newStep.id) { + // first reset validation state to default + setIsFormValid(false); + cockpit.location.go([newStep.id]); + } }; return ( From 13c99b1d84620ed360c47cfe46ac976c6c129aaa Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Mon, 28 Aug 2023 15:05:48 +0200 Subject: [PATCH 2/2] webui: add basic test for sidebar navigation (#2233805) Related: rhbz#2233805 Related: rhbz#2231339 --- ui/webui/test/check-basic | 29 +++++++++++++++++++++++++++++ ui/webui/test/helpers/installer.py | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/ui/webui/test/check-basic b/ui/webui/test/check-basic index c656d81fb1b..3b0624017ab 100755 --- a/ui/webui/test/check-basic +++ b/ui/webui/test/check-basic @@ -48,6 +48,35 @@ class TestBasic(anacondalib.VirtInstallMachineCase): # Ensure that the 'actual' UI process is running/ self.assertIn("/usr/libexec/webui-desktop", m.execute("ps aux")) + def testSidebarNavigation(self): + b = self.browser + m = self.machine + i = Installer(b, m) + + i.open() + + i.check_prerelease_info() + + # Test that clicking on current step does not break navigation + i.click_step_on_sidebar() + + i.reach(i.steps.REVIEW) + + # Test going back + steps = [ + i.steps.DISK_CONFIGURATION, + i.steps.DISK_ENCRYPTION, + i.steps.DISK_CONFIGURATION, + i.steps.INSTALLATION_METHOD, + i.steps.WELCOME, + i.steps.WELCOME, + ] + + for step in steps: + i.click_step_on_sidebar(step) + + i.reach(i.steps.REVIEW) + def testLanguageScreenHiddenLive(self): b = self.browser m = self.machine diff --git a/ui/webui/test/helpers/installer.py b/ui/webui/test/helpers/installer.py index ec42c47f856..19784456e02 100644 --- a/ui/webui/test/helpers/installer.py +++ b/ui/webui/test/helpers/installer.py @@ -23,6 +23,7 @@ class InstallerSteps(UserDict): WELCOME = "installation-language" INSTALLATION_METHOD = "installation-method" CUSTOM_MOUNT_POINT = "mount-point-mapping" + DISK_CONFIGURATION = "disk-configuration" DISK_ENCRYPTION = "disk-encryption" REVIEW = "installation-review" PROGRESS = "installation-progress" @@ -120,6 +121,10 @@ def open(self, step="installation-language"): self.browser.open(f"/cockpit/@localhost/anaconda-webui/index.html#/{step}") self.wait_current_page(step) + def click_step_on_sidebar(self, step=None): + step = step or self.get_current_page() + self.browser.click(f"#{step}") + def get_current_page(self): return self.browser.eval_js('window.location.hash;').replace('#/', '') or self.steps[0]