Skip to content

Commit

Permalink
MDL-74465 theme_classic: override new block steps
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Mar 30, 2023
1 parent a507a9e commit 9788496
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Feature: The activity results block displays student scores
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"

@javascript
@javascript @addablocklink
Scenario: Block should select current activity by default
Given I click on "Test assignment 1" "link" in the "region-main" "region"
When I add the "Activity results..." block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Feature: The recently accessed items block allows users to easily access their m
And I click on "Show more items" "button" in the "Recently accessed items" "block"
And I should see "Test forum name" in the "Recently accessed items" "block"
And I turn editing mode on
And I am on homepage
And I configure the "Recently accessed items" block
And I set the following fields to these values:
| Region | content |
Expand Down
33 changes: 33 additions & 0 deletions theme/classic/tests/behat/behat_theme_classic_behat_blocks.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
use Behat\Gherkin\Node\TableNode;
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -56,6 +57,38 @@ public function i_add_the_block($blockname) {
}
}

/**
* Adds the selected block to the specified region
*
* Editing mode must be previously enabled.
*
* @param string $blockname
* @param string $region
*/
public function i_add_the_block_to_the_region(string $blockname, string $region) {
$this->execute('behat_blocks::i_add_the_block', [$blockname]);
}

/**
* Adds the selected block to the specified region and fills configuration form.
*
* Editing mode must be previously enabled.
*
* @param string $blockname
* @param string $region
* @param TableNode $data
*/
public function i_add_the_block_to_the_region_with(string $blockname, string $region, TableNode $data) {
$this->execute('behat_blocks::i_add_the_block_to_the_region', [$blockname, $region]);
$this->wait_for_pending_js();
$blocktitle = $blockname === 'Text' ? '(new text block)' : $blockname;
$this->execute('behat_blocks::i_configure_the_block', [$blocktitle]);
$dialogname = get_string('configureblock', 'core_block', $blocktitle);
$this->execute('behat_forms::i_set_the_following_fields_in_container_to_these_values',
[$dialogname, "dialogue", $data]);
$this->execute('behat_general::i_click_on_in_the', ["Save changes", 'button', $dialogname, 'dialogue']);
}

/**
* Ensures that block can be added to the page, but does not add it.
*
Expand Down

0 comments on commit 9788496

Please sign in to comment.