Commit 425a1451 authored by Robert Lyon's avatar Robert Lyon

New Behat option: "And I delete the [text string] row" (Bug #1479631)

This test should find the delete button within a row and click it

Note: delete buttons should have a confirm popup on them

Change-Id: I99c2b1154b154b63676c1d08bd5c82da1c73e308
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 8787994a
......@@ -151,7 +151,7 @@ var Paginator = function(id, list, heading, script, extradata) {
swapDOM(container, temp.childNodes[0].childNodes[0]);
}
else {
temp.innerHTML = data.data.tablerows;
temp.innerHTML = listdata;
replaceChildNodes(container, temp.childNodes);
}
}
......@@ -159,6 +159,13 @@ var Paginator = function(id, list, heading, script, extradata) {
container.innerHTML = listdata;
}
if (listdata.match(/data\-confirm/gm) !== null) {
// need to re-animate the confirm option popup
jQuery('[data-confirm]').on('click', function() {
var content = jQuery(this).attr('data-confirm');
return confirm(content);
});
}
// In Chrome, tbody remains set to the value before tbody.innerHTML was modified
// to fix that, we re-initialize tbody using getFirstElementByTagAndClassName
if (/chrome/.test(navigator.userAgent.toLowerCase()) && container.tagName == 'TBODY') {
......
......@@ -385,6 +385,29 @@ class BehatGeneral extends BehatBase {
$elementnode->click();
}
/**
* Click on the delete button inside a list/table row containing the specified text.
*
* @When /^I delete the "(?P<row_text_string>(?:[^"]|\\")*)" row$/
* @param string $rowtext The list/table row text
* @throws ElementNotFoundException
*/
public function i_delete_the_row($rowtext) {
// The table row container.
$rowtextliteral = $this->escaper->escapeLiteral($rowtext);
$exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the delete button in the row containing the text "' . $rowtext . '"');
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'list-group-item', ' '))" .
" and contains(normalize-space(.), " . $rowtextliteral . ")]//button[starts-with(@id, 'delete_')]" .
"|" .
"//tr[contains(normalize-space(.), " . $rowtextliteral . ")]//button[starts-with(@id, 'delete_')]";
$deletenode = $this->find('xpath', $xpath, $exception);
$this->ensure_node_is_visible($deletenode);
$deletenode->press();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* Drags and drops the specified element to the specified container. This step does not work in all the browsers, consider it experimental.
*
......
......@@ -4,11 +4,10 @@ jQuery(function($) {
"use strict";
function submitConfirm() {
$('[data-confirm]').on('click', function(){
$('[data-confirm]').on('click', function() {
var content = $(this).attr('data-confirm');
return confirm(content);
});
}
submitConfirm();
});
......@@ -34,6 +34,8 @@ Scenario Outline: Adding a Note block to a portfolio (Bug 1424512)
# Verifying the Note block saved
And I choose "Notes" in "Content"
And I should see "Note block 1"
And I delete the "Note block 1" row
Then I should see "Note deleted"
Examples:
| Log | Verify |
......
......@@ -29,6 +29,12 @@ Given the following "users" exist:
And I press "Comment"
And I should see "There was an error with submitting this form. Please check the marked fields and try again."
And I should see "Your message is empty. Please enter a message or attach a file."
And I set the following fields to these values:
| Message | This is a comment 1 |
And I press "Comment"
And I wait "1" seconds
And I delete the "This is a comment 1" row
Then I should see "Comment removed by the author"
Examples:
| log |
......
......@@ -20,14 +20,25 @@
| A's Page 06 | UserA's page 06 | user | userA |
| A's Page 07 | UserA's page 07 | user | userA |
| A's Page 08 | UserA's page 08 | user | userA |
| A's Page 09 | UserA's page 06 | user | userA |
| A's Page 10 | UserA's page 07 | user | userA |
| A's Page 11 | UserA's page 08 | user | userA |
| A's Page 09 | UserA's page 09 | user | userA |
| A's Page 10 | UserA's page 10 | user | userA |
| A's Page 11 | UserA's page 11 | user | userA |
| A's Page 12 | UserA's page 12 | user | userA |
| A's Page 13 | UserA's page 13 | user | userA |
| A's Page 14 | UserA's page 14 | user | userA |
| A's Page 15 | UserA's page 15 | user | userA |
| A's Page 16 | UserA's page 16 | user | userA |
| A's Page 17 | UserA's page 17 | user | userA |
| A's Page 18 | UserA's page 18 | user | userA |
| A's Page 19 | UserA's page 19 | user | userA |
| A's Page 20 | UserA's page 20 | user | userA |
| A's Page 21 | UserA's page 21 | user | userA |
| A's Page 22 | UserA's page 22 | user | userA |
And I follow "Portfolio"
And I follow "A's Page 01"
And I follow "Edit this page"
And I follow "Share page"
And I set the field "editaccess_views" to "A's Page 01, A's Page 02, A's Page 03, A's Page 04, A's Page 05, A's Page 06, A's Page 07, A's Page 08, A's Page 09, A's Page 10, A's Page 11"
And I set the field "editaccess_views" to "A's Page 01, A's Page 02, A's Page 03, A's Page 04, A's Page 05, A's Page 06, A's Page 07, A's Page 08, A's Page 09, A's Page 10, A's Page 11, A's Page 12, A's Page 13, A's Page 14, A's Page 15, A's Page 16, A's Page 17, A's Page 18, A's Page 19, A's Page 20, A's Page 21"
And I select "Public" from "accesslist[0][searchtype]"
And I press "editaccess_submit"
And I follow "Logout"
......
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