From 2789a4c7f68126197544f85895ecb21ed9d9a719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 27 Mar 2024 13:05:21 +0100 Subject: [PATCH] Fix wizard form submit --- demos/_unit-test/wizard.php | 28 ++++++++++++++++++++++++++++ src/Wizard.php | 1 + tests-behat/wizard.feature | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 demos/_unit-test/wizard.php create mode 100644 tests-behat/wizard.feature diff --git a/demos/_unit-test/wizard.php b/demos/_unit-test/wizard.php new file mode 100644 index 0000000000..7d52557499 --- /dev/null +++ b/demos/_unit-test/wizard.php @@ -0,0 +1,28 @@ +addControl('city', [], ['required' => true]); + $form->onSubmit(static function (Form $form) use ($wizard) { + return $wizard->jsNext(); + }); +}; +$wizard->addStep(['Step 1'], $stepFx); +$wizard->addStep(['Step 2'], $stepFx); + +$wizard->addFinish(static function (Wizard $wizard) { + Header::addTo($wizard, ['Wizard completed']); +}); diff --git a/src/Wizard.php b/src/Wizard.php index 530441a601..67659ed957 100644 --- a/src/Wizard.php +++ b/src/Wizard.php @@ -141,6 +141,7 @@ public function add($seed, $region = null): AbstractView } $this->buttonNext->on('click', $result->js()->submit()); + $this->buttonFinish->on('click', $result->js()->submit()); } return $result; diff --git a/tests-behat/wizard.feature b/tests-behat/wizard.feature new file mode 100644 index 0000000000..a52455ef80 --- /dev/null +++ b/tests-behat/wizard.feature @@ -0,0 +1,18 @@ +Feature: Wizard + + Scenario: test form submit + Given I am on "_unit-test/wizard.php" + Then I check if text in "//div.ui.two.steps//div.ui.step.active" match text "Step 1" + Then I should not see "Must not be empty" + When I click using selector "//a[text()='Next']" + Then I should see "Must not be empty" + When I fill in "city" with "Prague" + When I click using selector "//a[text()='Next']" + Then I check if text in "//div.ui.two.steps//div.ui.step.active" match text "Step 2" + Then I should not see "Must not be empty" + When I click using selector "//a[text()='Finish']" + Then I should see "Must not be empty" + When I fill in "city" with "London" + Then I should not see "Wizard completed" + When I click using selector "//a[text()='Finish']" + Then I should see "Wizard completed"