Commit 9cf3d8eb authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1813987: Behat - block creation

- Data generator creates blocks for new gridstack layout
- we don't look for nodes inside script elements

behatnotneeded

Change-Id: I0e791c431ab6b80e75ae397290a20b3ec9fba836
parent ccc2446d
......@@ -2256,7 +2256,7 @@ class View {
}
else {
$result = $blockinstance->render_viewing($exporting, $versioning);
if (call_static_method(generate_class_name('blocktype', $blockinstance->get('blocktype')), 'has_static_content')) {
if (call_static_method(generate_class_name('blocktype', $blockinstance->get('blocktype')), 'has_static_content') && !defined('BEHAT_TEST')) {
$block['class'] = 'staticblock';
}
}
......
......@@ -738,7 +738,8 @@ EOD;
$viewid = $this->get_view_id($view);
if (!isset(self::$viewcolcounts[$viewid])) {
self::$viewcolcounts[$viewid] = 1;
self::$viewcolcounts[$viewid]['x'] = 0;
self::$viewcolcounts[$viewid]['y'] = 0;
}
$ids = get_records_sql_array($sql, array($page));
......@@ -804,26 +805,42 @@ EOD;
* @param View $view object of the current view
* @param int $viewid of the View
* @param string $title of the block instance to be created
* @param int $viewcolcounts the current count of 1,2,3 column to create next block instance
* @param int $viewcolcounts the current count of 0,1,2,.. column and 0,1,2,.. row to create next block instance
* @param array $configdata holding data for new block instance
* @param int $maxcols ~ 3
* @param int $maxcols ~ 3 (1,2,3,4,6)
* @param View $otherview for situations such as navigation where a block is related to another view
*/
public static function create_new_block_instance($blocktype, $view, $viewid, $title, $viewcolcounts, $configdata, $maxcols, $otherview = null) {
safe_require('blocktype', $blocktype);
if (!in_array($maxcols, array(1,2,3,4,6))) $maxcols = 3;
$blockwidth = 12/$maxcols;
$bi = new BlockInstance(0,
array(
'blocktype' => $blocktype,
'title' => $title,
'view' => $viewid,
'row' => 1,
)
);
if (!isset(self::$viewcolcounts[$viewid])) self::$viewcolcounts[$viewid] = 0;
$bi->set('order', $view->get_current_max_order(1, self::$viewcolcounts[$viewid]) + 1);
if (!isset(self::$viewcolcounts[$viewid])) {
self::$viewcolcounts[$viewid]['x'] = 0;
self::$viewcolcounts[$viewid]['y'] = 0;
}
$bi->set('configdata', $configdata);
$bi->set('column', self::$viewcolcounts[$viewid]);
self::$viewcolcounts[$viewid] = ((self::$viewcolcounts[$viewid]+1) % $maxcols) ? (self::$viewcolcounts[$viewid]+1) % $maxcols : $maxcols;
$bi->set('positionx', self::$viewcolcounts[$viewid]['x'] * $blockwidth);
$bi->set('positiony', self::$viewcolcounts[$viewid]['y'] * 3);
$bi->set('height', 3);
$bi->set('width', $blockwidth);
if ($newcol = (self::$viewcolcounts[$viewid]['x']+1) % $maxcols) {
self::$viewcolcounts[$viewid]['x'] = $newcol;
}
else {
self::$viewcolcounts[$viewid]['x'] = 0;
self::$viewcolcounts[$viewid]['y']++;
}
//in cases such as navigation where we want to add a block to a different view than the current.
if ($otherview) {
......
......@@ -98,8 +98,14 @@ class BehatBase extends Behat\MinkExtension\Context\RawMinkContext {
protected function find($selector, $locator, $exception = false, $node = false) {
// Returns the first match.
$items = $this->find_all($selector, $locator, $exception, $node);
return count($items) ? reset($items) : null;
if ($items = $this->find_all($selector, $locator, $exception, $node)) {
foreach ($items as $key => $value) {
if ($value->getTagName() != 'script') {
$returnitems[] = $value;
}
}
}
return count($returnitems) ? reset($returnitems) : null;
}
/**
......
......@@ -44,7 +44,6 @@ Scenario: Testing that views & collections are collated properly
Given I log in as "admin" with password "Kupuh1pa!"
And I am on homepage
And I scroll to the id 'bottom-pane'
Then should see "(Author's name hidden)"
And I follow "(Author's name hidden)"
Then I should see "UserA"
......@@ -25,7 +25,6 @@ Scenario: Viewing a list of pages I watch from the dashboard (Bug 1444784)
And I select "Email" from "Watchlist"
And I press "Save"
And I am on homepage
And I scroll to the id 'bottom-pane'
And I follow "Page UserA_01"
And I press "More options"
And I follow "Add page to watchlist"
......@@ -36,7 +35,6 @@ Scenario: Viewing a list of pages I watch from the dashboard (Bug 1444784)
And I unsubscribe from "Page UserA_01" owned by "UserB"
And I should see "You have unsubscribed successfully"
And I am on homepage
And I scroll to the id 'bottom-pane'
And I follow "Page UserA_01"
And I press "More options"
And I should see "Add page to watchlist"
......@@ -45,8 +45,3 @@ Scenario: Group homepage basic settings and skins can't be edited - Bug 1718806
When I go to group "GroupA"
And I follow "Edit"
And I should not see "Settings"
When I follow "Edit layout"
And I should not see "Basics"
And I should not see "Skin"
And I press "Save"
And I should see "Page saved successfully"
......@@ -108,7 +108,6 @@ Background:
And I log in as "UserB" with password "Kupuh1pa!"
And I wait "1" seconds
And I scroll to the center of id 'row_1'
And I follow "Collection UserA_01"
And I should see "This is comment 3"
And I should not see "This is comment 2"
......
......@@ -63,7 +63,6 @@ Scenario: Creating and accessing social media buttons (Bug 1448948)
And I log out
# Logging in as UserB to try see the buttons
Given I log in as "UserB" with password "Kupuh1pa!"
And I scroll to the id 'bottom-pane'
And I follow "Page UserA_01"
And I should see "Social Media"
And I should see "Facebook"
......
......@@ -57,7 +57,7 @@ Feature: Mahara users can create their blogs
And I press "Save entry"
And I choose "Pages and collections" in "Create" from main menu
And I click on "Edit" in "Page UserA_01" card menu
When I follow "Drag to Drag to add a new block" in the "blocktype sidebar" property
When I follow "Drag to add a new block" in the "blocktype sidebar" property
And I press "Add"
And I click on "Show more"
And I click on "Tagged journal entries" in the "Content types" property
......
......@@ -42,6 +42,7 @@ Scenario: Clicking ID's (Bug 1428456)
| Block content | <p>It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind...</p> |
And I press "Save"
Then I should see "Winston Smith"
And I scroll to the top
# Checking if we can edit a block
When I configure the block "About me"
......
......@@ -29,6 +29,7 @@ Scenario: Adding a placeholder block to the page
Then I should see "Please configure the block to choose what type of block this should be"
# Edit placeholder block and check we can see more options
And I scroll to the top
And I configure the block "Mahara placeholder block"
And I click on "Show more"
Then I should see "Image gallery"
......@@ -51,4 +52,4 @@ Scenario: Adjusting the order of the placeholder blocks
And I move blocktype "External media" to before "Text"
And I move blocktype "PDF" to before "Text"
And I reload the page
# TODO - then go to add a placeholder block and check the order
\ No newline at end of file
# TODO - then go to add a placeholder block and check the order
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