Skip to content

Commit

Permalink
Prepare release 1.3 for Moodle 4.5
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
srobotta committed Oct 10, 2024
1 parent 50bfa05 commit 0a6706e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
54 changes: 49 additions & 5 deletions tests/behat/behat_editor_tiny_multilang2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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');

Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tests/behat/tiny_multilang.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

0 comments on commit 0a6706e

Please sign in to comment.