first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,102 @@
@block @block_comments
Feature: Add a comment to the comments block
In order to comment on a conversation or a topic
As a user
In need to add comments to courses
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | First | teacher1@example.com |
| student1 | Student | First | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
And I am on the "Course 1" course page logged in as student1
@javascript
Scenario: Add a comment with Javascript enabled
When I add "I'm a comment from student1" comment to comments block
Then I should see "I'm a comment from student1"
And I am on the "Course 1" course page logged in as teacher1
And I should see "I'm a comment from student1"
Scenario: Add a comment with Javascript disabled
When I follow "Show comments"
And I add "I'm a comment from student1" comment to comments block
Then I should see "I'm a comment from student1"
And I am on the "Course 1" course page logged in as teacher1
And I follow "Show comments"
And I should see "I'm a comment from student1"
@javascript
Scenario: Test comment block pagination
When I add "Super test comment 01" comment to comments block
And I change window size to "1024x4096"
And I add "Super test comment 02" comment to comments block
And I add "Super test comment 03" comment to comments block
And I add "Super test comment 04" comment to comments block
And I add "Super test comment 05" comment to comments block
And I add "Super test comment 06" comment to comments block
And I add "Super test comment 07" comment to comments block
And I add "Super test comment 08" comment to comments block
And I add "Super test comment 09" comment to comments block
And I add "Super test comment 10" comment to comments block
And I add "Super test comment 11" comment to comments block
And I add "Super test comment 12" comment to comments block
And I add "Super test comment 13" comment to comments block
And I add "Super test comment 14" comment to comments block
And I add "Super test comment 15" comment to comments block
And I add "Super test comment 16" comment to comments block
And I add "Super test comment 17" comment to comments block
And I add "Super test comment 18" comment to comments block
And I add "Super test comment 19" comment to comments block
And I add "Super test comment 20" comment to comments block
And I add "Super test comment 21" comment to comments block
And I add "Super test comment 22" comment to comments block
And I add "Super test comment 23" comment to comments block
And I add "Super test comment 24" comment to comments block
And I add "Super test comment 25" comment to comments block
And I add "Super test comment 26" comment to comments block
And I add "Super test comment 27" comment to comments block
And I add "Super test comment 28" comment to comments block
And I add "Super test comment 29" comment to comments block
And I add "Super test comment 30" comment to comments block
And I add "Super test comment 31" comment to comments block
Then I should see "Super test comment 01"
And I should see "Super test comment 31"
And I am on "Course 1" course homepage
And I should not see "Super test comment 01"
And I should not see "Super test comment 02"
And I should not see "Super test comment 16"
And I should see "Super test comment 17"
And I should see "Super test comment 31"
And I should see "1" in the ".block_comments .comment-paging" "css_element"
And I should see "2" in the ".block_comments .comment-paging" "css_element"
And I should see "3" in the ".block_comments .comment-paging" "css_element"
And I should not see "4" in the ".block_comments .comment-paging" "css_element"
And I click on "2" "link" in the ".block_comments .comment-paging" "css_element"
And I should not see "Super test comment 01"
And I should see "Super test comment 02"
And I should see "Super test comment 16"
And I should not see "Super test comment 17"
And I should not see "Super test comment 31"
And I click on "3" "link" in the ".block_comments .comment-paging" "css_element"
And I should see "Super test comment 01"
And I should not see "Super test comment 02"
And I should not see "Super test comment 16"
And I should not see "Super test comment 17"
And I should not see "Super test comment 31"
And I click on "1" "link" in the ".block_comments .comment-paging" "css_element"
And I should not see "Super test comment 01"
And I should not see "Super test comment 02"
And I should not see "Super test comment 16"
And I should see "Super test comment 17"
And I should see "Super test comment 31"
@@ -0,0 +1,110 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Commenting system steps definitions.
*
* @package block_comments
* @category test
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
Behat\Mink\Exception\ExpectationException as ExpectationException;
/**
* Steps definitions to deal with the commenting system
*
* @package block_comments
* @category test
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_block_comments extends behat_base {
/**
* Adds the specified option to the comments block of the current page.
*
* This method can be adapted in future to add other comments considering
* that there could be more than one comment textarea per page.
*
* Only 1 comments block instance is allowed per page, if this changes this
* steps definitions should be adapted.
*
* @Given /^I add "(?P<comment_text_string>(?:[^"]|\\")*)" comment to comments block$/
* @throws ElementNotFoundException
* @param string $comment
*/
public function i_add_comment_to_comments_block($comment) {
// Getting the textarea and setting the provided value.
$exception = new ElementNotFoundException($this->getSession(), 'Comments block ');
// The whole DOM structure changes depending on JS enabled/disabled.
if ($this->running_javascript()) {
$commentstextarea = $this->find('css', '.comment-area textarea', $exception);
$commentstextarea->setValue($comment);
$this->find_link(get_string('savecomment'))->click();
// Delay after clicking so that additional comments will have unique time stamps.
// We delay 1 second which is all we need.
$this->getSession()->wait(1000);
} else {
$commentstextarea = $this->find('css', '.block_comments form textarea', $exception);
$commentstextarea->setValue($comment);
// Comments submit button
$submit = $this->find('css', '.block_comments form input[type=submit]');
$submit->press();
}
}
/**
* Deletes the specified comment from the current page's comments block.
*
* @Given /^I delete "(?P<comment_text_string>(?:[^"]|\\")*)" comment from comments block$/
* @throws ElementNotFoundException
* @throws ExpectationException
* @param string $comment
*/
public function i_delete_comment_from_comments_block($comment) {
$exception = new ElementNotFoundException($this->getSession(), '"' . $comment . '" comment ');
// Using xpath liternal to avoid possible problems with comments containing quotes.
$commentliteral = behat_context_helper::escape($comment);
$commentxpath = "//*[contains(concat(' ', normalize-space(@class), ' '), ' block_comments ')]" .
"/descendant::div[@class='comment-message'][contains(., $commentliteral)]";
$commentnode = $this->find('xpath', $commentxpath, $exception);
// Click on delete icon.
$this->execute('behat_general::i_click_on_in_the',
array("Delete comment posted by", "icon", $this->escape($commentxpath), "xpath_element")
);
// Wait for the animation to finish, in theory is just 1 sec, adding 4 just in case.
$this->getSession()->wait(4 * 1000);
}
}
@@ -0,0 +1,30 @@
@block @block_comments
Feature: Enable Block comments on an activity page and view comments
In order to enable the comments block on an activity page
As a teacher
I can add the comments block to an activity page
Scenario: Add the comments block on an activity page and add comments
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | First | teacher1@example.com |
| student1 | Student | First | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | idnumber | name | intro |
| page | C1 | page1 | Test page name | Test page description |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Activity module | page1 | mod-page-* | side-pre |
And I am on the "Test page name" "page activity" page logged in as teacher1
And I follow "Show comments"
And I add "I'm a comment from the teacher" comment to comments block
When I am on the "Test page name" "page activity" page logged in as student1
And I follow "Show comments"
Then I should see "I'm a comment from the teacher"
@@ -0,0 +1,29 @@
@block @block_comments
Feature: Enable Block comments on the dashboard and view comments
In order to enable the comments block on a the dashboard
As a teacher
I can add the comments block to my dashboard
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | First | teacher1@example.com |
Scenario: Add the comments block on the dashboard and add comments with Javascript disabled
When I log in as "teacher1"
And I turn editing mode on
And I add the "Comments" block
And I follow "Show comments"
And I add "I'm a comment from the teacher" comment to comments block
Then I should see "I'm a comment from the teacher"
@javascript
Scenario: Add the comments block on the dashboard and add comments with Javascript enabled
When I log in as "teacher1"
And I turn editing mode on
And I add the "Comments" block
And I add "I'm a comment from the teacher" comment to comments block
Then I should see "I'm a comment from the teacher"
@@ -0,0 +1,22 @@
@block @block_comments
Feature: Enable Block comments on the frontpage and view comments
In order to enable the comments block on the frontpage
As a admin
I can add the comments block to the frontpage
Scenario: Add the comments block on the frontpage and add comments
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | System | 1 | site-index | side-pre |
And I log in as "admin"
And I am on site homepage
And I follow "Show comments"
And I add "I'm a comment from admin" comment to comments block
And I log out
When I log in as "teacher1"
And I am on site homepage
And I follow "Show comments"
Then I should see "I'm a comment from admin"
@@ -0,0 +1,30 @@
@block @block_comments
Feature: Delete comment block messages
In order to refine comment block's contents
As a teacher
In need to delete comments from courses
@javascript
Scenario: Delete comments with Javascript enabled
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | First | teacher1@example.com |
| student1 | Student | First | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
And I am on the "Course 1" course page logged in as student1
And I add "Comment from student1" comment to comments block
And I am on the "Course 1" course page logged in as teacher1
And I add "Comment from teacher1" comment to comments block
When I delete "Comment from student1" comment from comments block
Then I should not see "Comment from student1"
And I delete "Comment from teacher1" comment from comments block
And I should not see "Comment from teacher1"