Commit 90d28036 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1710988 - add behat test for broken js in note copy"

parents 836e37d9 4c54d9d7
......@@ -1341,7 +1341,7 @@ JS;
/**
* Check if images exist in the block given its title
*
* @Then I should see images in the block :blocktitle
* @Then I should see images within the block :blocktitle
*
*/
public function i_should_see_images_block($blocktitle) {
......@@ -1380,10 +1380,54 @@ JS;
);
}
/**
* Check if text exist in the block given its title
*
* @Then I should see :text in the block :blocktitle
*
*/
public function i_should_see_text_in_block($text, $blocktitle) {
// Find the block.
$blocktitleliteral = $this->escaper->escapeLiteral($blocktitle);
$textliteral = $this->escaper->escapeLiteral($text);
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' column-content ')]" .
"/div[contains(@id,'blockinstance_')" .
" and contains(h3, " . $blocktitleliteral . ")]" .
"//div[contains(normalize-space(.), " . $textliteral . ")]";
// Wait until it finds the text inside the block title.
try {
$blocktext = $this->find_all('xpath', $xpath);
}
catch (ElementNotFoundException $e) {
throw new ExpectationException('The block with title ' . $blocktitleliteral . ' containing ' . $textliteral . ' was not found', $this->getSession());
}
// If we are not running javascript we have enough with the
// element existing as we can't check if it is visible.
if (!$this->running_javascript()) {
return;
}
// We also check the element visibility when running JS tests.
$this->spin(
function($context, $args) {
foreach ($args['nodes'] as $node) {
if ($node->isVisible()) {
return true;
}
}
throw new ExpectationException('The block with title ' . $args['text'] . ' was not visible', $context->getSession());
},
array('nodes' => $blocktext, 'text' => $blocktitleliteral)
);
}
/**
* Check if images does not exist in the block given its title
*
* @Then I should not see images in the block :blocktitle
* @Then I should not see images within the block :blocktitle
*
*/
public function i_should_not_see_images_block($blocktitle) {
......@@ -1423,6 +1467,50 @@ JS;
);
}
/**
* Check if text exist in the block given its title
*
* @Then I should not see :text in the block :blocktitle
*
*/
public function i_should_not_see_text_in_block($text, $blocktitle) {
// Find the block.
$blocktitleliteral = $this->escaper->escapeLiteral($blocktitle);
$textliteral = $this->escaper->escapeLiteral($text);
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' column-content ')]" .
"/div[contains(@id,'blockinstance_')" .
" and contains(h3, " . $blocktitleliteral . ")]" .
"//div[count(descendant::*[contains(normalize-space(.), " . $textliteral . ")]) = 0]";
// Wait until it finds the text inside the block title.
try {
$blocktext = $this->find_all('xpath', $xpath);
}
catch (ElementNotFoundException $e) {
throw new ExpectationException('The block with title ' . $blocktitleliteral . ' containing ' . $textliteral . ' was found', $this->getSession());
}
// If we are not running javascript we have enough with the
// element existing as we can't check if it is visible.
if (!$this->running_javascript()) {
return;
}
// We also check the element visibility when running JS tests.
$this->spin(
function($context, $args) {
foreach ($args['nodes'] as $node) {
if ($node->isVisible()) {
return true;
}
}
throw new ExpectationException('The block with title ' . $args['text'] . ' was not visible', $context->getSession());
},
array('nodes' => $blocktext, 'text' => $blocktitleliteral)
);
}
/**
* Pauses the scenario until the user presses a key. Useful when debugging a scenario locally
* but not meant for automated runs.
......
@javascript @core @blocktype @blocktype_notes
Feature: Add a note which copies the contents
from an existing note using the "Use content from another note" option
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| userA | Kupuhipa1 | userA@example.com | Angela | User | mahara | internal | member |
And the following "pages" exist:
| title | description| ownertype | ownername |
| Page 1 | Test page 1 | user | userA |
Scenario: Use content from another note (Bug 1710988)
Given I log in as "userA" with password "Kupuhipa1"
And I follow "Page 1"
And I follow "Edit this page"
And I expand "General" node
And I follow "Note" in the "div#general" "css_element"
And I press "Add"
And I set the following fields to these values:
| Block title | Note block 1 |
| Block content | This is a test |
And I press "Save"
And I follow "Note" in the "div#general" "css_element"
And I press "Add"
And I follow "Use content from another note"
And I select the radio "Note block 1"
# Set title after selection as selection updates the title with original one
And I set the following fields to these values:
| Block title | Note block 2 |
And I press "Save"
And I should see "This is a test" in the block "Note block 2"
......@@ -43,8 +43,8 @@ Scenario: Enable/disable external resources in mahara pages
And I press "Save"
And I scroll to the top
And I follow "Display page"
Then I should see images in the block "Text block with an internal image"
And I should see images in the block "Text block with an external image"
Then I should see images within the block "Text block with an internal image"
And I should see images within the block "Text block with an external image"
And I log out
# Disable external resources and check if external images are displayed in pages
......@@ -57,5 +57,5 @@ Scenario: Enable/disable external resources in mahara pages
And I log in as "UserA" with password "Kupuhipa1"
And I choose "Pages and collections" in "Portfolio" from main menu
And I follow "Page UserA_01"
Then I should see images in the block "Text block with an internal image"
And I should not see images in the block "Text block with an external image"
Then I should see images within the block "Text block with an internal image"
And I should not see images within the block "Text block with an external image"
......@@ -13,6 +13,7 @@ Given the following "users" exist:
| title | description | ownertype | ownername |
| Page UserA_01 | Page 01| user | UserA |
Scenario: Adding and deleting a Note block (Bug 1424512)
# Logging in as a user
Given I log in as "UserA" with password "Kupuhipa1"
And I choose "Pages and collections" in "Portfolio" from main menu
......@@ -22,27 +23,31 @@ Given the following "users" exist:
And I expand "General" node
And I follow "Note" in the "div#general" "css_element"
And I press "Add"
And I fill in the following:
And I set the following fields to these values:
| Block title | Note block 1 |
Scenario: Adding and deleting a Note block (Bug 1424512)
And I press "Save"
And I should see "Note block 1"
# Verifying the Note block saved
And I display the page
And I choose "Notes" in "Content" from main menu
And I should see "Note block 1"
# Verifying the Note block can be deleted
And I delete the "Note block 1" row
Then I should see "Note deleted"
Scenario: Adding an attachment to a note
# Attaching a file to the note
| Block content | This is a test |
#Adding an attachment to a note and attaching a file to it.
And I follow "Attachments" in the "div#instconf_artefactfieldset_container" "css_element"
And I attach the file "Image2.png" to "userfile[]"
And I should see "Upload of Image2.png complete"
And I press "Save"
#Add a second note to the page
And I follow "Note" in the "div#general" "css_element"
And I press "Add"
And I follow "Use content from another note"
And I select the radio "Note block 1"
# Set title after selection as selection updates the title with original one
And I set the following fields to these values:
| Block title | Note block 2 |
And I press "Save"
And I should see "This is a test" in the block "Note block 2"
# Verifying the attachment saved
And I choose "Notes" in "Content" from main menu
And I follow "Note block 1"
And I should see "Image2.png"
# Verifying the Note block saved
And I follow "Page UserA_01"
And I choose "Notes" in "Content" from main menu
And I should see "Note block 1"
# Verifying the Note block can be deleted
And I delete the "Note block 1" row
Then I should see "Note deleted"
......@@ -34,7 +34,7 @@ Scenario:
And I should see "There is a cat in a table"
And I should not see "</h2></strong>"
And I should not see "<title>Sample HTML file</title>"
And I should see images in the block "Some HTML"
And I should see images within the block "Some HTML"
And I follow "mahara manual"
And I wait "2" seconds
Then I should see "This is the user manual for Mahara"
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