Skip to content

Commit

Permalink
Prepare release 0.8 for Moodle 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
srobotta committed Oct 10, 2024
1 parent 9fb7402 commit 581eefa
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.1'
moodle-branch: 'MOODLE_405_STABLE'
database: pgsql
- php: '8.2'
moodle-branch: 'MOODLE_405_STABLE'
database: pgsql
- php: '8.3'
moodle-branch: 'MOODLE_405_STABLE'
database: pgsql
- php: '8.1'
moodle-branch: 'MOODLE_405_STABLE'
database: mariadb
- php: '8.2'
moodle-branch: 'MOODLE_405_STABLE'
database: mariadb
- php: '8.3'
moodle-branch: 'MOODLE_405_STABLE'
database: mariadb
- php: '8.1'
moodle-branch: 'MOODLE_404_STABLE'
database: pgsql
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
moodle-tiny_fontcolor
========================

![Release](https://img.shields.io/badge/Release-0.7-blue.svg)
![Release](https://img.shields.io/badge/Release-0.8-blue.svg)
[![Moodle Plugin CI](https://github.com/bfh/moodle-tiny_fontcolor/workflows/Moodle%20Plugin%20CI/badge.svg?branch=main)](https://github.com/bfh/moodle-tiny_fontcolor/actions?query=workflow%3A%22Moodle+Plugin+CI%22+branch%3Amain)
[![PHP Support](https://img.shields.io/badge/php-7.4--8.3-blue)](https://github.com/bfh/moodle-tiny_fontcolor/action)
[![Moodle Support](https://img.shields.io/badge/Moodle-4.1--4.4-orange)](https://github.com/bfh/moodle-tiny_fontcolor/actions)
[![Moodle Support](https://img.shields.io/badge/Moodle-4.1--4.5-orange)](https://github.com/bfh/moodle-tiny_fontcolor/actions)
[![License GPL-3.0](https://img.shields.io/github/license/bfh/moodle-tiny_fontcolor?color=lightgrey)](https://github.com/bfh/moodle-tiny_fontcolor/blob/main/LICENSE)
[![GitHub contributors](https://img.shields.io/github/contributors/bfh/moodle-tiny_fontcolor)](https://github.com/bfh/moodle-tiny_fontcolor/graphs/contributors)

Expand Down Expand Up @@ -61,6 +61,10 @@ over the appropriate color square.

## Version History

### 0.8

- Adjustments for Moodle 4.5

### 0.7
- Fix [HTML areas without files seem to fail with the tiny_fontcolor enabled #16](https://github.com/bfh/moodle-tiny_fontcolor/issues/16) and
[TinyMCE fails when creating a qtype_multichoice question #17](https://github.com/bfh/moodle-tiny_fontcolor/issues/17). The introduced context menu items in 0.6 didn't show up under
Expand Down
67 changes: 62 additions & 5 deletions tests/behat/behat_editor_tiny_fontcolor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@
class behat_editor_tiny_fontcolor extends behat_base {
use editor_tiny_helpers;

/**
* The main menu of the TinyMCE editor.
* @var string
*/
const MAINMENU = 'Format';

/**
* The menu element of the TinyMCE editor.
* @var \Behat\Mink\Element\NodeElement
*/
private $menubar;

/**
* The color name to choose from the little squares with the colors.
* @var string
*/
private $color;

/**
* The menu item in the Format menu.
* @var string
*/
private $label;

/**
* Click on a button for the specified TinyMCE editor.
*
Expand All @@ -50,18 +74,31 @@ class behat_editor_tiny_fontcolor extends behat_base {
* @param string $locator The locator for the editor
*/
public function i_click_on_colormenuitem_in_menu(string $label, string $color, string $locator): void {
global $CFG;
$this->require_tiny_tags();

$this->label = trim($label);
$this->color = trim($color);

$container = $this->get_editor_container_for_locator($locator);

$menubar = $container->find('css', '[role="menubar"]');
$this->menubar = $container->find('css', '[role="menubar"]');

$menus = [trim($label), trim($color)];
if ($CFG->version < 2024100700) {
$this->before_four_five();
} else {
$this->four_five_and_later();
}
}

/**
* Click the TinyMCE menu prior to Moodle 4.5
*/
private function before_four_five() {
// Open the menu bar.
$mainmenu = 'Format';
$this->execute('behat_general::i_click_on_in_the', [$mainmenu, 'button', $menubar, 'NodeElement']);
$this->execute('behat_general::i_click_on_in_the', [self::MAINMENU, 'button', $this->menubar, 'NodeElement']);

foreach ($menus as $menuitem) {
foreach ([$this->label, $this->color] as $menuitem) {
// Find the menu that was opened.
$openmenu = $this->find('css', '.tox-selected-menu');

Expand All @@ -78,4 +115,24 @@ public function i_click_on_colormenuitem_in_menu(string $label, string $color, s
$this->execute('behat_general::i_click_on', [$link, 'NodeElement']);
}
}

/**
* Click the TinyMCE menu in Moodle 4.5 and later.
*/
private function four_five_and_later() {
// Open the menu bar.
$mainmenu = self::MAINMENU;
$button = $this->menubar->find('xpath', "//span[text()='{$mainmenu}']");
$this->execute('behat_general::i_click_on', [$button, 'NodeElement']);

// Find the menu that was opened.
$openmenu = $this->find('css', '.tox-selected-menu');

$link = $openmenu->find('css', "[aria-label='{$this->label}'][role^='menuitem']");
$link->mouseover();
$this->execute('behat_general::i_click_on', [$link, 'NodeElement']);

$item = $openmenu->find('css', "[aria-label='{$this->color}'][role^='menuitemradio']");
$this->execute('behat_general::i_click_on', [$item, 'NodeElement']);
}
}
38 changes: 36 additions & 2 deletions tests/behat/textcolortextbackgroundcolor.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Feature: Tiny editor text color/text background color

@javascript
Scenario: Set a text color using the Text foreground color menu item
Given the following config values are set as admin:
Given the site is running Moodle version 4.4 or lower
And the following config values are set as admin:
| backgroundcolors | [{"name":"Black","value":"000000"},{"name":"White","value":"ffffff"},{"name":"Yellow","value":"e2b007"},{"name":"rosa","value":"#ffccc0"}] | tiny_fontcolor |
| textcolors | [{"name":"Normal","value":"#000000"},{"name":"Gray dark","value":"0a2c2e"},{"name":"gray","value":"#ffccba"},{"name":"test1","value":"#fce34f"}] | tiny_fontcolor |
And I log in as "admin"
Expand All @@ -17,9 +18,26 @@ Feature: Tiny editor text color/text background color
Then I should see "Some plain text"
And "//span[@style='color:rgb(10,44,46);']" "xpath_element" should exist

@javascript
Scenario: Set a text color using the Text foreground color menu item
Given the site is running Moodle version 4.5 or higher
And the following config values are set as admin:
| backgroundcolors | [{"name":"Black","value":"000000"},{"name":"White","value":"ffffff"},{"name":"Yellow","value":"e2b007"},{"name":"rosa","value":"#ffccc0"}] | tiny_fontcolor |
| textcolors | [{"name":"Normal","value":"#000000"},{"name":"Gray dark","value":"0a2c2e"},{"name":"gray","value":"#ffccba"},{"name":"test1","value":"#fce34f"}] | tiny_fontcolor |
And I log in as "admin"
And I open my profile in edit mode
And I wait until the page is ready
And I set the field "Description" to "<p>Some plain text</p><p>Some more text</p>"
And I select the "p" element in position "1" of the "Description" TinyMCE editor
And I click on the color menu item "Text foreground colour" and choose "Gray dark" for the "Description" TinyMCE editor
And I press "Update profile"
Then I should see "Some plain text"
And "//span[@style='color:#0a2c2e;']" "xpath_element" should exist

@javascript
Scenario: Set a text background color using the Text background color menu item
Given the following config values are set as admin:
Given the site is running Moodle version 4.4 or lower
And the following config values are set as admin:
| backgroundcolors | [{"name":"Black","value":"000000"},{"name":"White","value":"ffffff"},{"name":"Yellow","value":"e2b007"},{"name":"rosa","value":"#ffccc0"}] | tiny_fontcolor |
| textcolors | [{"name":"Normal","value":"#000000"},{"name":"Gray dark","value":"#0a2c2e"},{"name":"gray","value":"#ffccba"},{"name":"test1","value":"#fce34f"}] | tiny_fontcolor |
And I log in as "admin"
Expand All @@ -32,6 +50,22 @@ Feature: Tiny editor text color/text background color
Then I should see "Some plain text"
And "//span[@style='background-color:rgb(226,176,7);']" "xpath_element" should exist

@javascript
Scenario: Set a text background color using the Text background color menu item
Given the site is running Moodle version 4.5 or higher
And the following config values are set as admin:
| backgroundcolors | [{"name":"Black","value":"000000"},{"name":"White","value":"ffffff"},{"name":"Yellow","value":"e2b007"},{"name":"rosa","value":"#ffccc0"}] | tiny_fontcolor |
| textcolors | [{"name":"Normal","value":"#000000"},{"name":"Gray dark","value":"#0a2c2e"},{"name":"gray","value":"#ffccba"},{"name":"test1","value":"#fce34f"}] | tiny_fontcolor |
And I log in as "admin"
And I open my profile in edit mode
And I wait until the page is ready
And I set the field "Description" to "<p>Some plain text</p><p>Some more text</p>"
And I select the "p" element in position "1" of the "Description" TinyMCE editor
And I click on the color menu item "Text background colour" and choose "Yellow" for the "Description" TinyMCE editor
And I press "Update profile"
Then I should see "Some plain text"
And "//span[@style='background-color:#e2b007;']" "xpath_element" should exist

@javascript
Scenario: Set a text color using the Text foreground color menu button
Given the following config values are set as admin:
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'tiny_fontcolor';
$plugin->release = '0.7';
$plugin->version = 2024082000;
$plugin->release = '0.8';
$plugin->version = 2024100900;
$plugin->requires = 2022112800;
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [401, 404];
$plugin->supported = [401, 405];

0 comments on commit 581eefa

Please sign in to comment.