1
0
mirror of https://github.com/moodle/moodle.git synced 2025-03-03 15:29:08 +01:00

Merge branch 'MDL-67740-master-behatstepsfilter' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Adrian Greeve 2020-01-28 15:05:45 +08:00
commit 3d1943b46d
6 changed files with 45 additions and 34 deletions

@ -32,7 +32,7 @@ require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
// systems, but let's allow room for expansion.
core_php_time_limit::raise(300);
$filter = optional_param('filter', '', PARAM_ALPHANUMEXT);
$filter = optional_param('filter', '', PARAM_NOTAGS);
$type = optional_param('type', false, PARAM_ALPHAEXT);
$component = optional_param('component', '', PARAM_ALPHAEXT);

@ -55,13 +55,13 @@ class tool_behat {
// The loaded steps depends on the component specified.
behat_config_manager::update_config_file($component, false);
// The Moodle\BehatExtension\HelpPrinter\MoodleDefinitionsPrinter will parse this search format.
// The Moodle\BehatExtension\Definition\Printer\ConsoleDefinitionInformationPrinter will parse this search format.
if ($type) {
$filter .= '&&' . $type;
}
if ($filter) {
$filteroption = ' -d "' . $filter . '"';
$filteroption = ' -d ' . escapeshellarg($filter);
} else {
$filteroption = ' -di';
}

@ -44,13 +44,9 @@ class tool_behat_renderer extends plugin_renderer_base {
global $CFG;
require_once($CFG->libdir . '/behat/classes/behat_selectors.php');
$html = $this->generic_info();
// Form.
ob_start();
$form->display();
$html .= ob_get_contents();
ob_end_clean();
$html = $this->output->header();
$html .= $this->output->heading(get_string('pluginname', 'tool_behat'));
$html .= $form->render();
if (empty($stepsdefinitions)) {
$stepsdefinitions = get_string('nostepsdefinitions', 'tool_behat');
@ -128,7 +124,9 @@ class tool_behat_renderer extends plugin_renderer_base {
*/
public function render_error($msg) {
$html = $this->generic_info();
$html = $this->output->header();
$html .= $this->output->heading(get_string('pluginname', 'tool_behat'));
$html .= $this->generic_info();
$a = new stdClass();
$a->errormsg = $msg;
@ -153,13 +151,7 @@ class tool_behat_renderer extends plugin_renderer_base {
*
* @return string
*/
protected function generic_info() {
$title = get_string('pluginname', 'tool_behat');
// Header.
$html = $this->output->header();
$html .= $this->output->heading($title);
public function generic_info() {
// Info.
$installurl = behat_command::DOCS_URL;
@ -175,8 +167,7 @@ class tool_behat_renderer extends plugin_renderer_base {
);
// List of steps.
$html .= $this->output->box_start();
$html .= html_writer::tag('h3', get_string('infoheading', 'tool_behat'));
$html = $this->output->box_start();
$html .= html_writer::tag('div', get_string('aim', 'tool_behat'));
$html .= html_writer::start_tag('div');
$html .= html_writer::start_tag('ul');

@ -40,8 +40,14 @@ class steps_definitions_form extends moodleform {
* @return void
*/
public function definition() {
global $PAGE;
$mform = $this->_form;
$output = $PAGE->get_renderer('tool_behat');
$mform->addElement('header', 'info', get_string('infoheading', 'tool_behat'));
$mform->setExpanded('info', false);
$mform->addElement('html', $output->generic_info());
$mform->addElement('header', 'filters', get_string('stepsdefinitionsfilters', 'tool_behat'));

@ -1,25 +1,31 @@
.steps-definitions {
border-style: solid;
border-width: 1px;
border-color: #bbb;
padding: 5px;
margin: auto;
width: 50%;
#page-admin-tool-behat-index .steps-definitions {
margin: 1rem auto;
}
.steps-definitions .step {
margin: 10px 0 10px 0;
#page-admin-tool-behat-index .steps-definitions .step {
margin: 1rem 0 0 0;
border: 1px solid #eee;
padding: 1rem;
}
.steps-definitions .stepdescription {
color: #bf8c12;
#page-admin-tool-behat-index .steps-definitions .stepdescription {
font-style: italic;
}
.steps-definitions .steptype {
#page-admin-tool-behat-index .steps-definitions .stepcontent {
margin: 1rem 0;
}
#page-admin-tool-behat-index .steps-definitions .steptype {
color: #1467a6;
margin-right: 5px;
margin-right: 1ex;
}
.steps-definitions .stepregex {
#page-admin-tool-behat-index .steps-definitions .stepapipath {
font-family: monospace;
font-size: smaller;
}
#page-admin-tool-behat-index .steps-definitions .stepregex {
color: #060;
}

@ -26,3 +26,11 @@ Feature: List the system steps definitions
Given I set the field "Contains" to "homepage"
When I press "Filter"
Then I should see "Opens Moodle homepage."
@javascript
Scenario: Filtering by the multiple words pattern
Given I set the field "Contains" to "should exist"
When I press "Filter"
Then I should not see "There aren't steps definitions matching this filter"
And I should see "Checks the provided element and selector type exists in the current page."
And I should see "Checks that an element and selector type exists in another element and selector type on the current page."