Commit f7fd7220 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Bug 1557200: Find the TinyMCE editor by field label"

parents 8f89c31d 625ad7fc
......@@ -524,30 +524,39 @@ class BehatForms extends BehatBase {
}
/**
* Fills in WYSIWYG editor with specified id. (If no ID is specified, uses the first
* TinyMCE editor on the page.
* Fills in TinyMCE editor with specified label.
*
* TODO: Is there a better, more human-readable way we could specify the TinyMCE editor
* to use? Like, tie it to the label for the pieform element?
*
* @Given /^(?:|I )fill in "(?P<text>[^"]*)" in WYSIWYG editor(?:| "(?P<iframe>[^"]*)")$/
* @Given /^(?:|I )fill in "(?P<text>[^"]*)" in editor "(?P<fieldlabel>[^"]*)"$/
*/
public function iFillInInWYSIWYGEditor($text, $iframe = null) {
if ($iframe == null) {
// Use the first TinyMCE iframe on the page
// TODO: May have to change this when upgrading TinyMCE. Is there a TinyMCE
// Javascript API we could use instead?
$iframe = $this->find('css', '.mce-edit-area > iframe')->getAttribute('id');
public function iFillInWYSIWYGEditor($text, $fieldlabel) {
$exception = new ElementNotFoundException($this->getSession(), 'field', null, $fieldlabel);
$label = $this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), ' wysiwyg ')]//label[contains(normalize-space(.), " . $fieldlabel . ")]", $exception);
$id = $label->getAttribute('for');
$iframe = $id . '_ifr';
// Use javascript to update the tinyMCE editor
if ($this->find('xpath', "//iframe[@id='" . $iframe . "']")) {
$this->getSession()->executeScript("tinymce.get('" . $id . "').setContent('" . $text . "');");
}
else {
throw new ElementNotFoundException("TinyMCE with label '" . $fieldlabel);
}
}
// switchToIFrame($iframe) seems not to work using current selenium webdriver
/**
* Fills in first TinyMCE editor on the page.
*
* @Given /^(?:|I )fill in "(?P<text>[^"]*)" in first editor$/
*/
public function iFillInFirstWYSIWYGEditor($text) {
$iframe = $this->find('css', '.mce-edit-area > iframe')->getAttribute('id');
$id = substr($iframe, 0, -4); // remove '_ifr'
// Use javascript to update the tinyMCE editor
if ($this->find('xpath', "//iframe[@id='" . $iframe . "']")) {
$editorid = substr($iframe, 0, -4); // remove '_ifr'
$this->getSession()->executeScript("tinymce.get('" . $editorid . "').setContent('" . $text . "');");
$this->getSession()->executeScript("tinymce.get('" . $id . "').setContent('" . $text . "');");
}
else {
throw new \NotFoundException("Iframe with id '$iframe'");
throw new \NotFoundException("TinyMCE not found on this page");
}
}
......
......@@ -23,7 +23,7 @@ Scenario: Making adjustments to the mathslate plugin for mahara (Bug 1472446)
And I choose "Pages" in "Configure site"
And I follow "test"
# Tinymce field adding a math equation
And I fill in "\\[\\alpha A\\beta B\\]" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "\\[\\alpha A\\beta B\\]" in editor "Message"
And I press "Comment"
And I wait "1" seconds
And I should see "αAβB"
......
......@@ -17,14 +17,13 @@ Scenario: Adding and deleting public comments
# Adding
Given I go to portfolio page "page1"
And I fill in "Name" with "Joe Anonymous"
# No WYSIWYG editor for anonymous users
# No TinyMCE editor for anonymous users
And I fill in "Message" with "Public comment by anonymous user"
And I enable the switch "Make public"
And I press "Comment"
And I log in as "pageowner" with password "password"
And I go to portfolio page "page1"
And I fill in "Comment by page owner" in WYSIWYG editor "add_feedback_form_message_ifr"
And I wait "1" seconds
And I fill in "Comment by page owner" in editor "Message"
And I press "Comment"
Then I should see "Joe Anonymous"
And I should see "Public comment by anonymous user"
......@@ -51,8 +50,7 @@ Scenario: Comments update the page's mtime
# Public comment updates page last updated
And I go to portfolio page "page1"
And I fill in "Public comment" in WYSIWYG editor "add_feedback_form_message_ifr"
And I wait "1" seconds
And I fill in "Public comment" in editor "Message"
And I press "Comment"
And I follow "Dashboard"
Then I should see "page1" in the ".bt-newviews" element
......@@ -60,9 +58,8 @@ Scenario: Comments update the page's mtime
# Private comment updates page last updated
And I go to portfolio page "page2"
And I fill in "Private comment" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Private comment" in editor "Message"
And I disable the switch "Make public"
And I wait "1" seconds
And I press "Comment"
And I follow "Dashboard"
Then I should see "page2" in the ".bt-newviews" element
......
......@@ -19,29 +19,29 @@ Scenario: Threaded comments should be displayed in correct order
Given I log in as "pageowner" with password "password"
And I go to portfolio page "page1"
# Add 11 comments
And I fill in "Comment #1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1" in editor "Message"
And I press "Comment"
And I fill in "Comment #2" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #2" in editor "Message"
And I press "Comment"
And I fill in "Comment #3" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #3" in editor "Message"
And I press "Comment"
And I fill in "Comment #4" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #4" in editor "Message"
And I press "Comment"
And I fill in "Comment #5" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #5" in editor "Message"
And I press "Comment"
And I fill in "Comment #6" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #6" in editor "Message"
And I press "Comment"
And I fill in "Comment #7" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #7" in editor "Message"
And I press "Comment"
And I fill in "Comment #8" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #8" in editor "Message"
And I press "Comment"
And I fill in "Comment #9" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #9" in editor "Message"
And I press "Comment"
And I fill in "Comment #10" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #10" in editor "Message"
And I press "Comment"
And I fill in "Comment #11" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #11" in editor "Message"
And I press "Comment"
And I fill in "Comment #12" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #12" in editor "Message"
And I press "Comment"
# Go to the first page
And I scroll to the base of id "comment-form"
......@@ -61,36 +61,36 @@ Scenario: Threaded comments should be displayed in correct order
And I follow "1"
And I scroll to the base of id "main-nav"
And I click on "Reply" in "Comment #1" row
And I fill in "Comment #1/1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1" in editor "Message"
And I press "Comment"
And "Comment #1/1" "text" should appear before "Comment #2" "text"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1" row
And I fill in "Comment #1/1/1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/1" in editor "Message"
And I press "Comment"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1" row
And I fill in "Comment #1/1/2" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/2" in editor "Message"
And I press "Comment"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1/1" row
And I fill in "Comment #1/1/1/1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/1/1" in editor "Message"
And I press "Comment"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1/1/1" row
And I fill in "Comment #1/1/1/1/1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/1/1/1" in editor "Message"
And I press "Comment"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1/1/1" row
And I fill in "Comment #1/1/1/1/2" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/1/1/2" in editor "Message"
And I press "Comment"
And I scroll to the id "feedbacktable"
And I click on "Reply" in "Comment #1/1" row
And I fill in "Comment #1/1/3" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/3" in editor "Message"
And I press "Comment"
And I scroll to the base of id "feedbacktable"
And I click on "Reply" in "Comment #1/1/2" row
And I fill in "Comment #1/1/2/1" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Comment #1/1/2/1" in editor "Message"
And I press "Comment"
And "Comment #1/1/1/1/1" "text" should appear before "Comment #1/1/1/1/2" "text"
And "Comment #1/1/1/1/2" "text" should appear before "Comment #1/1/2" "text"
......
......@@ -23,7 +23,7 @@ Background:
Scenario: Public comment by page owner, public reply by third party
Given I log in as "pageowner" with password "password"
And I go to portfolio page "page1"
And I fill in "Public comment by pageowner" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Public comment by pageowner" in editor "Message"
And I enable the switch "Make public"
And I press "Comment"
And I log out
......@@ -32,7 +32,7 @@ Scenario: Public comment by page owner, public reply by third party
And I press "Reply"
# I should see a preview of the reply-to comment below the feedback form
And I should see "Public comment by pageowner" in the ".commentreplyview" "css_element"
And I fill in "Public reply by pagecommenter" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Public reply by pagecommenter" in editor "Message"
When I press "Comment"
Then I should see "Public comment by pageowner"
And I should see "Public reply by pagecommenter"
......@@ -40,7 +40,7 @@ Scenario: Public comment by page owner, public reply by third party
Scenario: Public comment by non-owner, owner can private reply, another non-owner cannot private reply
Given I log in as "pagecommenter" with password "password"
And I go to portfolio page "page1"
And I fill in "Public comment by pagecommenter" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Public comment by pagecommenter" in editor "Message"
And I enable the switch "Make public"
And I press "Comment"
And I log out
......@@ -48,7 +48,7 @@ Scenario: Public comment by non-owner, owner can private reply, another non-owne
And I go to portfolio page "page1"
And I press "Reply"
And I disable the switch "Make public"
And I fill in "Private reply by pageowner" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Private reply by pageowner" in editor "Message"
And I press "Comment"
And I log out
And I log in as "pagewatcher" with password "password"
......@@ -56,7 +56,7 @@ Scenario: Public comment by non-owner, owner can private reply, another non-owne
And I press "Reply"
# I should not be able to make a private reply to a comment by someone other than the page owner
And I should see "Public" in the "#add_feedback_form_ispublic_container" "css_element"
When I fill in "Public reply by pagewatcher" in WYSIWYG editor "add_feedback_form_message_ifr"
When I fill in "Public reply by pagewatcher" in editor "Message"
And I press "Comment"
Then I should see "Public comment by pagecommenter"
And I should not see "Private reply by pageowner"
......@@ -65,7 +65,7 @@ Scenario: Public comment by non-owner, owner can private reply, another non-owne
Scenario: Private comment by commenter, private reply by page owner, private counter-reply by page commenter
Given I log in as "pagecommenter" with password "password"
And I go to portfolio page "page1"
And I fill in "Private comment by pagecommenter" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Private comment by pagecommenter" in editor "Message"
And I disable the switch "Make public"
And I press "Comment"
And I press "More..."
......@@ -76,7 +76,7 @@ Scenario: Private comment by commenter, private reply by page owner, private cou
And I press "Reply"
# There should be no option to make a public reply to a private comment
And I should see "Private" in the "#add_feedback_form_ispublic_container" "css_element"
And I fill in "Private reply by pageowner" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Private reply by pageowner" in editor "Message"
And I press "Comment"
And I log out
And I log in as "pagecommenter" with password "password"
......@@ -85,7 +85,7 @@ Scenario: Private comment by commenter, private reply by page owner, private cou
# (An exception to the general rule that only the pageowner can see private comments)
And I should see "Private reply by pageowner"
And I press "Reply"
And I fill in "Private counter-reply by pagecommenter" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Private counter-reply by pagecommenter" in editor "Message"
When I press "Comment"
Then I should see "Private comment by pagecommenter"
And I should see "Private reply by pageowner"
......@@ -98,7 +98,7 @@ Scenario: Private comment by commenter, private reply by page owner, private cou
Scenario: No private replies to anonymous comments
Given I go to portfolio page "page1"
And I fill in "Name" with "Anonymous User"
# No WYSIWYG editor for anonymous users
# No TinyMCE editor for anonymous users
And I fill in "Message" with "Public comment by anonymous user"
And I enable the switch "Make public"
And I press "Comment"
......@@ -107,7 +107,7 @@ Scenario: No private replies to anonymous comments
And I press "Reply"
# I should not be able to make a private reply to a comment by someone other than the page owner
Then I should see "Public" in the "#add_feedback_form_ispublic_container" "css_element"
And I fill in "Public reply by pagecommenter" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Public reply by pagecommenter" in editor "Message"
And I press "Comment"
And I should see "Public comment by anonymous user"
And I should see "Public reply by pagecommenter"
......@@ -115,7 +115,7 @@ Scenario: No private replies to anonymous comments
Scenario: No replies to deleted comments
Given I log in as "pageowner" with password "password"
And I go to portfolio page "page1"
And I fill in "I will delete this comment" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "I will delete this comment" in editor "Message"
And I enable the switch "Make public"
When I press "Comment"
And I should see "I will delete this comment"
......
......@@ -14,7 +14,6 @@ The wall post must generate a notification (Bug 547333)
Given I log in as "userB" with password "Kupuhipa1"
And I go to "/user/find.php"
And I follow "Pete Mc"
#And I fill in "Hello" in WYSIWYG editor
And I set the field "Post" to "Hello"
And I press "Post"
And I log out
......
......@@ -20,14 +20,14 @@ Scenario: Moving pages within a group (Bug 1426983)
And I follow "New forum"
And I set the following fields to these values:
| Title | Testing forum 1 |
And I fill in "Testing forum" in WYSIWYG editor "edit_interaction_description_ifr"
And I fill in "Testing forum" in editor "Description"
And I press "Save"
And I follow "Forums (tab selected)"
And I follow "General discussion"
And I follow "New topic"
And I set the following fields to these values:
| Subject | Testing topic 1 |
And I fill in "Testing moving topic" in WYSIWYG editor "addtopic_body_ifr"
And I fill in "Testing moving topic" in editor "Message"
And I press "Post"
# Verifying post has been created
And I follow "General discussion"
......
......@@ -29,7 +29,7 @@ Scenario: Leaving feedback on a group page (Bug 1426983)
And I follow "Pages (tab)"
# And I click on "Pages"
And I follow "Testing group page 01"
And I fill in "Testing feedback notifications" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "Testing feedback notifications" in editor "Message"
And I press "Comment"
# Log out as user 1
And I follow "Logout"
......
......@@ -38,17 +38,17 @@ Scenario: Testing that views & collections are collated properly
Given I log in as "userA" with password "Kupuhipa1"
And I choose "Pages" in "Portfolio"
And I follow "P1A"
And I fill in "I am on P1A" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "I am on P1A" in editor "Message"
And I press "Comment"
And I choose "Pages" in "Portfolio"
And I follow "P1B"
And I fill in "I am on P1B" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "I am on P1B" in editor "Message"
And I press "Comment"
And I choose "Pages" in "Portfolio"
And I follow "P2"
And I fill in "I am on P2" in WYSIWYG editor "add_feedback_form_message_ifr"
And I fill in "I am on P2" in editor "Message"
And I press "Comment"
When I log out
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment