Skip to content

Commit

Permalink
MDL-58052 behat: user session function - use to edit current profile
Browse files Browse the repository at this point in the history
  • Loading branch information
gthomas2 committed Mar 3, 2017
1 parent 29cdf58 commit 0b5f9f6
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 83 deletions.
3 changes: 1 addition & 2 deletions admin/tool/behat/tests/behat/manipulate_forms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Feature: Forms manipulation
@javascript
Scenario: Basic forms manipulation
Given I log in as "admin"
And I follow "Preferences" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
When I set the field "First name" to "Field value"
And I set the field "Select a country" to "Japan"
And I set the field "New password" to "TestPass"
Expand Down
3 changes: 1 addition & 2 deletions admin/tool/behat/tests/behat/nasty_strings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Feature: Transform steps arguments
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
And I follow "Preferences" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode

Scenario: Use nasty strings on steps arguments
When I set the field "Surname" to "$NASTYSTRING1"
Expand Down
4 changes: 1 addition & 3 deletions badges/tests/behat/award_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ Feature: Award badges
And I should not see "Criteria for this badge have not been set up yet."
And I press "Enable access"
And I press "Continue"
And I click on "Admin User" "link"
And I choose "Profile" in the open action menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I expand all fieldsets
And I set the field "Phone" to "123456789"
And I press "Update profile"
Expand Down
3 changes: 1 addition & 2 deletions course/tests/behat/navigate_course_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Feature: Browse course list and return back from enrolment page
And I press "Save changes"
And I log out
When I log in as "user2"
And I follow "Preferences" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I expand "Courses" node
And I expand "Sample category" node
And I follow "Course 1"
Expand Down
19 changes: 19 additions & 0 deletions lib/behat/behat_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,4 +925,23 @@ protected function execute($contextapi, $params = array()) {
// Look for exceptions.
$this->look_for_exceptions();
}

/**
* Get the actual user in the behat session (note $USER does not correspond to the behat session's user).
* @return mixed
* @throws coding_exception
*/
protected function get_session_user() {
global $DB;

$sid = $this->getSession()->getCookie('MoodleSession');
if (empty($sid)) {
throw new coding_exception('failed to get moodle session');
}
$userid = $DB->get_field('sessions', 'userid', ['sid' => $sid]);
if (empty($userid)) {
throw new coding_exception('failed to get user from seession id '.$sid);
}
return $DB->get_record('user', ['id' => $userid]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: Images with no alt
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' width='1' height='1'/><p>Some more text</p>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand All @@ -31,8 +30,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: Low contrast
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p style='color: #7c7cff; background-color: #ffffff;'>Hard to read</p>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand All @@ -41,8 +39,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: No headings
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Sweet roll oat cake jelly-o macaroon donut oat cake. Caramels macaroon cookie sweet roll croissant cheesecake candy jelly-o. Gummies sugar plum sugar plum gingerbread dessert. Tiramisu bonbon jujubes danish marshmallow cookie chocolate cake cupcake tiramisu. Bear claw oat cake chocolate bar croissant. Lollipop cookie topping liquorice croissant. Brownie cookie cupcake lollipop cupcake cupcake. Fruitcake dessert sweet biscuit dragée caramels marzipan brownie. Chupa chups gingerbread apple pie cookie liquorice caramels carrot cake cookie gingerbread. Croissant candy jelly beans. Tiramisu apple pie dessert apple pie macaroon soufflé. Brownie powder carrot cake chocolate. Tart applicake croissant dragée macaroon chocolate donut.</p><p>Jelly beans gingerbread tootsie roll. Sugar plum tiramisu cotton candy toffee pie cotton candy tiramisu. Carrot cake chocolate bar sesame snaps cupcake cake dessert sweet fruitcake wafer. Marshmallow cupcake gingerbread pie sweet candy canes powder gummi bears. Jujubes cake muffin marshmallow candy jelly beans tootsie roll pie. Gummi bears applicake chocolate cake sweet jelly sesame snaps lollipop lollipop carrot cake. Marshmallow cake jelly beans. Jelly beans sesame snaps muffin halvah cookie ice cream candy canes carrot cake. Halvah donut marshmallow tiramisu. Cookie dessert gummi bears. Sugar plum apple pie jelly beans gummi bears tart chupa chups. Liquorice macaroon gummi bears gummies macaroon marshmallow sweet roll cake topping. Lemon drops caramels pie icing danish. Chocolate cake oat cake dessert halvah danish carrot cake apple pie.</p>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand All @@ -51,8 +48,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: Merged cells
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<table><caption>Dogs that look good in pants</caption><tr><th>Breed</th><th>Coolness</th></tr><tr><td>Poodle</td><td rowspan='2'>NOT COOL</td></tr><tr><td>Doberman</td></tr></table>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand All @@ -61,8 +57,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: Table missing row/column headers
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<table><caption>Dogs that look good in pants</caption><tr><th>Breed</th><td>Coolness</td></tr><tr><td>Poodle</td><td>NOT COOL</td></tr><tr><td>Doberman</td><td>COOL</td></tr></table>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand All @@ -71,8 +66,7 @@ Feature: Atto accessibility checker
@javascript
Scenario: Table missing caption
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<table><tr><th>Breed</th><th>Coolness</th></tr><tr><td>Poodle</td><td>NOT COOL</td></tr><tr><td>Doberman</td><td>COOL</td></tr></table>"
When I click on "Show more buttons" "button"
And I click on "Accessibility checker" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto accessibility helper
@javascript
Scenario: Images and links
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' alt='Image 1'/><p><a href='#fsd'>Some link text</a></p>"
And I select the text in the "Description" Atto editor
When I click on "Show more buttons" "button"
Expand All @@ -21,8 +20,7 @@ Feature: Atto accessibility helper
@javascript
Scenario: Styles
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Some plain text</p>"
When I click on "Show more buttons" "button"
And I select the text in the "Description" Atto editor
Expand Down
9 changes: 3 additions & 6 deletions lib/editor/atto/plugins/align/tests/behat/align.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto align text
@javascript
Scenario: Right align some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Fascism</p>"
And I click on "Show more buttons" "button"
And I select the text in the "Description" Atto editor
Expand All @@ -22,8 +21,7 @@ Feature: Atto align text
@javascript
Scenario: Left align some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Communism</p>"
And I click on "Show more buttons" "button"
And I select the text in the "Description" Atto editor
Expand All @@ -40,8 +38,7 @@ Feature: Atto align text
@javascript
Scenario: Center align some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>United Future</p>"
And I click on "Show more buttons" "button"
And I select the text in the "Description" Atto editor
Expand Down
6 changes: 2 additions & 4 deletions lib/editor/atto/plugins/bold/tests/behat/bold.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto bold button
@javascript
Scenario: Bold some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Badger"
And I select the text in the "Description" Atto editor
When I click on "Bold" "button"
Expand All @@ -21,8 +20,7 @@ Feature: Atto bold button
@javascript
Scenario: Unbold some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Mouse"
And I select the text in the "Description" Atto editor
When I click on "Bold" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/charmap/tests/behat/charmap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto charmap button
@javascript
Scenario: Insert symbols
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>1980 Mullet</p>"
And I select the text in the "Description" Atto editor
When I click on "Show more buttons" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/clear/tests/behat/clear.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto clear button
@javascript
Scenario: Clear formatting
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Pisa"
And I select the text in the "Description" Atto editor
And I click on "Italic" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto collapse button
@javascript
Scenario: Toggle toolbar
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
When I click on "Show more buttons" "button"
Then "Equation editor" "button" should be visible
And I click on "Show fewer buttons" "button"
Expand Down
6 changes: 2 additions & 4 deletions lib/editor/atto/plugins/equation/tests/behat/equation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto equation editor
@javascript
Scenario: Create an equation
Given I log in as "admin"
When I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
When I open my profile in edit mode
And I set the field "Description" to "<p>Equation test</p>"
# Set field on the bottom of page, so equation editor dialogue is visible.
And I expand all fieldsets
Expand All @@ -24,8 +23,7 @@ Feature: Atto equation editor
@javascript
Scenario: Edit an equation
Given I log in as "admin"
When I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
When I open my profile in edit mode
And I set the field "Description" to "<p>\( \pi \)</p>"
# Set field on the bottom of page, so equation editor dialogue is visible.
And I expand all fieldsets
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/html/tests/behat/html.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto edit HTML
@javascript
Scenario: Edit the html source
Given I log in as "admin"
When I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
When I open my profile in edit mode
And I set the field "Description" to "<p style=\"color: blue;\">Smurf</p>"
And I click on "Show more buttons" "button"
And I click on "HTML" "button"
Expand Down
6 changes: 2 additions & 4 deletions lib/editor/atto/plugins/image/tests/behat/image.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Feature: Add images to Atto
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
When I set the field "Description" to "<p>Image test</p>"
And I select the text in the "Description" Atto editor
And I click on "Image" "button"
Expand Down Expand Up @@ -52,8 +51,7 @@ Feature: Add images to Atto
@javascript
Scenario: Manually inserting an image
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>Image: <img src='/nothing/here'>.</p>"
And I select the text in the "Description" Atto editor
When I click on "Image" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/indent/tests/behat/indent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Feature: Indent text in Atto
@javascript
Scenario: Indent and outdent
Given I log in as "admin"
And I follow "Profile" in the user menu
When I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<p>I need some space.</p>"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand Down
6 changes: 2 additions & 4 deletions lib/editor/atto/plugins/italic/tests/behat/italic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto italic button
@javascript
Scenario: Italicise some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Tower of Pisa"
And I select the text in the "Description" Atto editor
When I click on "Italic" "button"
Expand All @@ -21,8 +20,7 @@ Feature: Atto italic button
@javascript
Scenario: Toggle italics in some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "GHD - for hair"
And I select the text in the "Description" Atto editor
When I click on "Italic" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/link/tests/behat/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Feature: Add links to Atto
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
When I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
When I open my profile in edit mode
And I set the field "Description" to "Super cool"
And I select the text in the "Description" Atto editor
And I click on "Link" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto ordered list button
@javascript
Scenario: Make a list from some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Have you heard the news everyone's talking<br/> Life is good 'cause everything's awesome<br/>"
And I select the text in the "Description" Atto editor
When I click on "Ordered list" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/strike/tests/behat/strike.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto strike button
@javascript
Scenario: Strike some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "MUA"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto subscript button
@javascript
Scenario: Subscript some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Submarine"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand All @@ -22,8 +21,7 @@ Feature: Atto subscript button
@javascript
Scenario: Subscript some text in enclosed in superscript
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<sup>Submarine</sup>"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto superscript button
@javascript
Scenario: Subscript some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Helicopter"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand All @@ -22,8 +21,7 @@ Feature: Atto superscript button
@javascript
Scenario: Superscript some text that is enclosed in subscript
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "<sub>Helicopter</sub>"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand Down
3 changes: 1 addition & 2 deletions lib/editor/atto/plugins/title/tests/behat/title.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto title
@javascript
Scenario: Create a heading
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "How The Rock Has Made the WWE World Heavyweight Title More Important Than Ever"
And I select the text in the "Description" Atto editor
When I click on "Paragraph styles" "button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Feature: Atto underline button
@javascript
Scenario: Underline some text
Given I log in as "admin"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I open my profile in edit mode
And I set the field "Description" to "Deprecated HTML Tag"
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
Expand Down
Loading

0 comments on commit 0b5f9f6

Please sign in to comment.