Minor - improve behat tests + format code

pull/3174/head
Julio Montoya 6 years ago
parent 88c447d704
commit 1500395d1f
  1. 3
      tests/behat/README.md
  2. 7
      tests/behat/features/bootstrap/FeatureContext.php
  3. 10
      tests/behat/features/createUser.feature

@ -8,7 +8,10 @@ http://www.seleniumhq.org/download/
And run it with the following command: And run it with the following command:
``` ```
Example:
wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
java -jar /my-dir/selenium-server-standalone-3.1.0.jar java -jar /my-dir/selenium-server-standalone-3.1.0.jar
``` ```
- Download the Chrome driver, unzip and copy into /usr/bin - Download the Chrome driver, unzip and copy into /usr/bin

@ -21,7 +21,6 @@ class FeatureContext extends MinkContext
*/ */
public function iAmAPlatformAdministrator() public function iAmAPlatformAdministrator()
{ {
$this->visit('/index.php?logout=logout&uid=1');
$this->iAmOnHomepage(); $this->iAmOnHomepage();
$this->fillField('login', 'admin'); $this->fillField('login', 'admin');
$this->fillField('password', 'admin'); $this->fillField('password', 'admin');
@ -315,7 +314,7 @@ class FeatureContext extends MinkContext
$this->getSession()->executeScript( $this->getSession()->executeScript(
" "
var textarea = $('textarea'); var textarea = $('textarea');
var id = textarea.attr('id'); var id = textarea.attr('id');
CKEDITOR.instances[id].setData(\"$value\"); CKEDITOR.instances[id].setData(\"$value\");
" "
); );
@ -409,7 +408,7 @@ class FeatureContext extends MinkContext
$('$field > option').each(function(index, option) { $('$field > option').each(function(index, option) {
if (option.text == '$value') { if (option.text == '$value') {
$('$field').selectpicker('val', option.value); $('$field').selectpicker('val', option.value);
} }
}); });
"); ");
} }
@ -423,7 +422,7 @@ class FeatureContext extends MinkContext
$this->getSession()->executeScript(" $this->getSession()->executeScript("
var input = $('$field').filter('$class'); var input = $('$field').filter('$class');
var id = input.attr('id'); var id = input.attr('id');
var input = $('#'+id); var input = $('#'+id);
input.val($value); input.val($value);
"); ");
} }

@ -4,18 +4,18 @@ Feature: Users management as admin
As an administrator As an administrator
I need to be able to create new users I need to be able to create new users
Scenario: See the users list link on the admin page Background:
Given I am a platform administrator Given I am a platform administrator
And I am on "/main/admin/index.php"
Scenario: See the users list link on the admin page
Given I am on "/main/admin/index.php"
Then I should see "Users list" Then I should see "Users list"
Scenario: See the user creation link on the admin page Scenario: See the user creation link on the admin page
Given I am a platform administrator
And I am on "/main/admin/index.php" And I am on "/main/admin/index.php"
Then I should see "Add a user" Then I should see "Add a user"
Scenario: Create a user with only basic info Scenario: Create a user with only basic info
Given I am a platform administrator
And I am on "/main/admin/user_add.php" And I am on "/main/admin/user_add.php"
And I fill in the following: And I fill in the following:
| firstname | Sammy | | firstname | Sammy |
@ -24,10 +24,10 @@ Feature: Users management as admin
| username | smarshall | | username | smarshall |
| password | smarshall | | password | smarshall |
And I press "submit" And I press "submit"
And wait for the page to be loaded
Then I should see "The user has been added" Then I should see "The user has been added"
Scenario: Search and delete a user Scenario: Search and delete a user
Given I am a platform administrator
And Admin top bar is disabled And Admin top bar is disabled
And I am on "/main/admin/user_list.php" And I am on "/main/admin/user_list.php"
And I fill in "keyword" with "smarshall" And I fill in "keyword" with "smarshall"

Loading…
Cancel
Save