From 0a6706ed1696c74188fe12d310b6797231aa9b13 Mon Sep 17 00:00:00 2001 From: Stephan Robotta Date: Wed, 9 Oct 2024 17:15:04 +0200 Subject: [PATCH] Prepare release 1.3 for Moodle 4.5 - Add ci config for Moodle 4.5 - Remove test to select language ru because the same is done before and in this test, it fails because of the list and the mouseout event that lets the menu disappear. - Add different handling of the TinyMCE menu clicks. --- .github/workflows/moodle-plugin-ci.yml | 18 +++++++ README.md | 9 ++-- tests/behat/behat_editor_tiny_multilang2.php | 54 ++++++++++++++++++-- tests/behat/tiny_multilang.feature | 3 -- version.php | 6 +-- 5 files changed, 76 insertions(+), 14 deletions(-) diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index bcbcbb0..e918d1c 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 a1c96bb..4c60ea9 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ TinyMCE multilanguage plugin ============================ -![Release](https://img.shields.io/badge/Release-1.2-blue.svg) +![Release](https://img.shields.io/badge/Release-1.3-blue.svg) [![Moodle Plugin CI](https://github.com/bfh/moodle-tiny_multilang2/workflows/Moodle%20Plugin%20CI/badge.svg?branch=main)](https://github.com/bfh/moodle-tiny_multilang2/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_multilang2/actions) -[![Moodle Support](https://img.shields.io/badge/Moodle-4.1--4.4+-orange)](https://github.com/bfh/moodle-tiny_multilang2/actions) +[![Moodle Support](https://img.shields.io/badge/Moodle-4.1--4.5+-orange)](https://github.com/bfh/moodle-tiny_multilang2/actions) [![License GPL-3.0](https://img.shields.io/github/license/bfh/moodle-tiny_multilang2?color=lightgrey)](https://github.com/bfh/moodle-tiny_multilang2/blob/main/LICENSE) [![GitHub contributors](https://img.shields.io/github/contributors/bfh/moodle-tiny_multilang2)](https://github.com/bfh/moodle-tiny_multilang2/graphs/contributors) @@ -29,7 +29,7 @@ formatting of the text is correct. ## Current version -The latest release is v1.2 (build 2024042200) for Moodle 4.1 and newer. +The latest release is v1.3 (build 2024100900) for Moodle 4.1 and newer. ## Requirements @@ -114,6 +114,9 @@ provided iso codes is preserved. ## Version History +### 1.3 +- Adaptions for Moodle 4.5. + ### 1.2 - Removal of the attribute `dir` e.g. `dir="ltr"` for language direction because it breaks the standard multilanguage filter in Moodle. diff --git a/tests/behat/behat_editor_tiny_multilang2.php b/tests/behat/behat_editor_tiny_multilang2.php index 7abff3c..9e79724 100644 --- a/tests/behat/behat_editor_tiny_multilang2.php +++ b/tests/behat/behat_editor_tiny_multilang2.php @@ -39,6 +39,18 @@ class behat_editor_tiny_multilang2 extends behat_base { use editor_tiny_helpers; + /** + * The menu element of the TinyMCE editor. + * @var \Behat\Mink\Element\NodeElement + */ + private $menubar; + + /** + * The menu items in the TinyMCE editor that should be clicked. + * @var string[] + */ + private $menus; + /** * Click on a button for the specified TinyMCE editor. * @@ -50,20 +62,33 @@ class behat_editor_tiny_multilang2 extends behat_base { * @param string $locator The locator for the editor */ public function i_click_on_submenuitem_in_menu(string $menuitem, string $locator): void { + global $CFG; + $this->require_tiny_tags(); $container = $this->get_editor_container_for_locator($locator); - $menubar = $container->find('css', '[role="menubar"]'); + $this->menubar = $container->find('css', '[role="menubar"]'); - $menus = array_map(function(string $value): string { + $this->menus = array_map(function(string $value): string { return trim($value); }, explode('>', $menuitem)); + + 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 = array_shift($menus); - $this->execute('behat_general::i_click_on_in_the', [$mainmenu, 'button', $menubar, 'NodeElement']); + $mainmenu = array_shift($this->menus); + $this->execute('behat_general::i_click_on_in_the', [$mainmenu, 'button', $this->menubar, 'NodeElement']); - foreach ($menus as $menuitem) { + foreach ($this->menus as $menuitem) { // Find the menu that was opened. $openmenu = $this->find('css', '.tox-selected-menu'); @@ -81,6 +106,25 @@ public function i_click_on_submenuitem_in_menu(string $menuitem, string $locator } } + /** + * Click the TinyMCE menu in Moodle 4.5 and later. + */ + private function four_five_and_later() { + // Open the menu bar. + $mainmenu = array_shift($this->menus); + $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'); + + foreach ($this->menus as $i => $menuitem) { + $item = $openmenu->find('css', "[aria-label='{$menuitem}']"); + $item->mouseover(); + $this->execute('behat_general::i_click_on', [$item, 'NodeElement']); + } + } + /** * Select the first child of an element type/index for the specified TinyMCE editor. * Note that this works only if the content is plain text without formatting. Otherwise, the first child diff --git a/tests/behat/tiny_multilang.feature b/tests/behat/tiny_multilang.feature index 75055e3..73a6785 100644 --- a/tests/behat/tiny_multilang.feature +++ b/tests/behat/tiny_multilang.feature @@ -59,9 +59,6 @@ Feature: Tiny editor multilang plugin with multilangfilter2 And I should see "Malay (ms)" And I should see "Russian (ru)" And I should see "Bengali (bn)" - And I click on "div[title='Russian (ru)']" "css_element" - And I press "Update profile" - And I should see "{mlang ru}Some plain text{mlang}" Scenario: Test remove all language tags. Given I log in as "admin" diff --git a/version.php b/version.php index a60808e..e11b195 100644 --- a/version.php +++ b/version.php @@ -28,8 +28,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'tiny_multilang2'; -$plugin->release = '1.2'; -$plugin->version = 2024042200; +$plugin->release = '1.3'; +$plugin->version = 2024100900; $plugin->requires = 2022112800; $plugin->maturity = MATURITY_STABLE; -$plugin->supported = [401, 404]; +$plugin->supported = [401, 405];