From 3ea6801db6da2fac229dccd48774cd52c07494b3 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 16 Sep 2020 16:21:19 +0200 Subject: [PATCH] Internal - Fix behat test --- public/main/admin/user_add.php | 4 ++-- tests/behat/features/bootstrap/FeatureContext.php | 14 ++++++++++++++ tests/behat/features/createUser.feature | 13 +++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/public/main/admin/user_add.php b/public/main/admin/user_add.php index 692124b542..944a2cf9b3 100644 --- a/public/main/admin/user_add.php +++ b/public/main/admin/user_add.php @@ -259,8 +259,8 @@ $form->addSelectLanguage('language', get_lang('Language'), null); // Send email $group = []; -$group[] = $form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1); -$group[] = $form->createElement('radio', 'send_mail', null, get_lang('No'), 0); +$group[] = $form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1, ['id' => 'send_mail_yes']); +$group[] = $form->createElement('radio', 'send_mail', null, get_lang('No'), 0, ['id' => 'send_mail_no']); $form->addGroup($group, 'mail', get_lang('Send mail to new user')); // Expiration Date $form->addElement('radio', 'radio_expiration_date', get_lang('Expiration date'), get_lang('Never expires'), 0); diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 7c72a67f37..ae40800fc9 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -498,6 +498,20 @@ class FeatureContext extends MinkContext return true; } + /** + * @Given /^I check the "([^"]*)" radio button selector$/ + */ + public function iCheckTheRadioButtonBasedInSelector($element) + { + $this->getSession()->executeScript(" + $(function() { + $('$element').prop('checked', true); + }); + "); + + return true; + } + /** * @Then /^I should see an icon with title "([^"]*)"$/ */ diff --git a/tests/behat/features/createUser.feature b/tests/behat/features/createUser.feature index 79a4e29700..15e1d8f85f 100644 --- a/tests/behat/features/createUser.feature +++ b/tests/behat/features/createUser.feature @@ -10,10 +10,7 @@ Feature: Users management as admin Scenario: See the users list link on the admin page Given I am on "/main/admin/index.php" Then I should see "Users list" - - Scenario: See the user creation link on the admin page - And I am on "/main/admin/index.php" - Then I should see "Add a user" + And I should see "Add a user" Scenario: Create a user with only basic info And I am on "/main/admin/user_add.php" @@ -25,6 +22,7 @@ Feature: Users management as admin | password | smarshall | And I check the "#send_mail_no" radio button selector And I press "submit" + And wait very long for the page to be loaded Then I should see "The user has been added" Scenario: Create a user with wrong username @@ -37,6 +35,7 @@ Feature: Users management as admin | password | smarshall | And I check the "#send_mail_no" radio button selector And I press "submit" + And wait very long for the page to be loaded Then I should see "Only letters and numbers allowed" Scenario: Create a user with wrong email @@ -49,6 +48,7 @@ Feature: Users management as admin | password | Juls | And I check the "#send_mail_no" radio button selector And I press "submit" + And wait very long for the page to be loaded Then I should see "The email address is not complete or contains some invalid characters" Scenario: Search and delete a user @@ -71,6 +71,7 @@ Feature: Users management as admin And I check the "#send_mail_no" radio button selector And I fill in select bootstrap static input "#status_select" select "4" And I press "submit" + And wait very long for the page to be loaded Then I should see "The user has been added" Scenario: Create a teacher user @@ -84,6 +85,7 @@ Feature: Users management as admin And I fill in select bootstrap static input "#status_select" select "1" And I check the "#send_mail_no" radio button selector And I press "submit" + And wait very long for the page to be loaded Then I should see "The user has been added" Scenario: Create a student user @@ -97,6 +99,7 @@ Feature: Users management as admin And I fill in select bootstrap static input "#status_select" select "5" And I check the "#send_mail_no" radio button selector And I press "submit" + And wait very long for the page to be loaded Then I should see "The user has been added" Scenario: HRM follows teacher @@ -107,6 +110,7 @@ Feature: Users management as admin And I select "teacher firstname teacher lastname" from "NoAssignedUsersList[]" And I press "add_user_button" And I press "assign_user" + And wait very long for the page to be loaded Then I should see "The assigned users have been updated" Scenario: HRM follows student @@ -117,6 +121,7 @@ Feature: Users management as admin And I select "student firstname student lastname" from "NoAssignedUsersList[]" And I press "add_user_button" And I press "assign_user" + And wait very long for the page to be loaded Then I should see "The assigned users have been updated" Scenario: HRM logs as teacher