From 581eefa44fe2d33bdf0b428468b767a8ca25a26c Mon Sep 17 00:00:00 2001 From: Stephan Robotta Date: Wed, 9 Oct 2024 17:11:22 +0200 Subject: [PATCH] Prepare release 0.8 for Moodle 4.5 --- .github/workflows/moodle-plugin-ci.yml | 18 +++++ README.md | 8 ++- tests/behat/behat_editor_tiny_fontcolor.php | 67 +++++++++++++++++-- .../textcolortextbackgroundcolor.feature | 38 ++++++++++- version.php | 6 +- 5 files changed, 125 insertions(+), 12 deletions(-) diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index f6c89b5..2cedb4c 100644 --- a/.github/workflows/moodle-plugin-ci.yml +++ b/.github/workflows/moodle-plugin-ci.yml @@ -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 diff --git a/README.md b/README.md index ad75556..0dc39a7 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/tests/behat/behat_editor_tiny_fontcolor.php b/tests/behat/behat_editor_tiny_fontcolor.php index 4a0e6e5..3827f93 100644 --- a/tests/behat/behat_editor_tiny_fontcolor.php +++ b/tests/behat/behat_editor_tiny_fontcolor.php @@ -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. * @@ -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'); @@ -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']); + } } diff --git a/tests/behat/textcolortextbackgroundcolor.feature b/tests/behat/textcolortextbackgroundcolor.feature index 0ceadfb..b4da8c0 100644 --- a/tests/behat/textcolortextbackgroundcolor.feature +++ b/tests/behat/textcolortextbackgroundcolor.feature @@ -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" @@ -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 "

Some plain text

Some more text

" + 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" @@ -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 "

Some plain text

Some more text

" + 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: diff --git a/version.php b/version.php index acafc91..af19798 100644 --- a/version.php +++ b/version.php @@ -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];