522 Commits

Author SHA1 Message Date
Andrew Nicols
43d00eaeba
MDL-78673 grade: Switch test to use generators 2023-07-10 11:30:14 +08:00
David Woloszyn
7f6d6d240f MDL-75913 behat: Private files data generator 2023-06-19 16:38:18 +10:00
Andrew Nicols
196ed7530b
Merge branch 'MDL-69231-401' of https://github.com/lameze/moodle into MOODLE_401_STABLE 2023-06-15 10:56:53 +08:00
Eloy Lafuente (stronk7)
7abeaf37ea
MDL-78036 behat: Move all links from old docs to new counterparts 2023-06-06 12:39:21 +02:00
Andrew Nicols
c4cd52ce5a MDL-69231 tests: Add role capability setting generator 2023-06-02 12:42:35 +08:00
Eloy Lafuente (stronk7)
278ce49b7f
MDL-78036 behat: Fix php81 deprecation warning 2023-05-26 18:04:26 +02:00
Andrew Nicols
5e32d574c6 MDL-77733 behat: Remove extraneous no-axe option
There is no need for no-axe if we make axe a boolean value. We already
have automatic support for negated boolean flags.
2023-05-19 11:28:08 +08:00
Andrew Nicols
bc85007834 MDL-77944 behat: Rename chrome options for w3c support
From Selenium 4.8.0, support for non-w3c browser control has ended.

We only use W3C browser control these days, and this was missed as part
of the move to W3C. All browser options must be vendor-prefixed.
2023-04-18 09:04:08 +08:00
Laurent David
bdd1708455 MDL-77037 core_courseformat: Refresh course index
* Refresh course index when language change
2023-03-09 08:44:22 +01:00
Eloy Lafuente (stronk7)
4e5ed8fdcd MDL-77417 behat: behat_error_handler meets deprecation error types
Right now, any E_DEPRECATED, E_USER_DEPRECATED error type leads
to exception in behat runs, because the behat error handled is
not aware of them. See MDL-38041 for the initial implementation.

We don't want that to happen and they must behave like other "low"
error types (notices, warnings...), that will be reported in logs
or output, but won't trigger any exception, so the test can continue.

This commit just adds those 2 "new" error types to the handler,
providing the very same behaviour for them than the rest.
2023-02-27 09:37:42 +01:00
Simey Lameze
d17117ab02 MDL-76542 behat: add step to go to user edit page directly 2023-02-08 12:24:27 +08:00
Marina Glancy
2dd7290ccb MDL-76362 various: Avoid passing nulls to functions that don't allow nulls
PHP 8.1 is more strict on the parameter type. Functions such as trim(), strlen(), str_replace(), etc
show notice when null is passed as an argument
2023-01-23 09:16:06 +08:00
Marina Glancy
ff5fc3820a MDL-76356 various: avoid implicit conversion to int
PHP before version 8.1 automatically converted to int if the function
parameter (or array key) is expected to be int. PHP 8.1 shows notice in
this case
2023-01-10 15:25:57 +01:00
Ilya Tregubov
f84d8e3c37 Merge branch 'MDL-76399-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE 2022-12-29 09:43:28 +07:00
Mark Johnson
0c448af668 MDL-75105 tool_behat: List available data generators
This will find all data generators that can be used in behat via the
'the following "something" exist:' step, and display them in a select
list on the step definitions page.

When a generator is selected, it will fetch the required fields for that
generator and display them on the page.
2022-12-21 08:38:28 +00:00
Paul Holden
1dda343f05 MDL-76399 behat: improvements to "should exist in" thrown exception. 2022-12-16 12:29:57 +00:00
Paul Holden
d4681259bc MDL-76398 behat: broader action menu partial matching by element.
For action menu elements whose trigger element isn't plain text
(e.g. a pix icon), we should be able to match via the title of
that element.
2022-12-02 09:55:45 +00:00
Marina Glancy
a5f92c041e MDL-74853 various: add second parameter to htmlentities functions
Default value of the $flag argument changed in PHP 8.1 from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE
To ensure consistent behavior across different PHP version the second parameter is now required for the functions:
htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode() and get_html_translation_table()
2022-11-28 16:12:32 +01:00
Kevin Percy
7f4ca89a79 MDL-75490 lib: Upgrade axe to v4.5.1 2022-11-11 11:02:32 +08:00
Andrew Nicols
426ea50861 MDL-76169 behat: Normalise exception message in should (not) steps
These steps have accepted a NodeElement instance as an argument for some
time, but were trying to cast it to string when formulating exception
messages, making it harder to debug and, in the case of the 'should see'
step, not work at all.

This patch introduces a new function to produce a consistent naming for
them.
2022-11-03 21:39:15 +08:00
Andrew Nicols
232ebac338 MDL-76169 behat: Add improved steps for using action menus
This commit adds new steps related to action menus to support:
* Choosing an item in a named action menu
* Choosing an item in a named action menu within a container
* Confirming that an action menu item does or does not exist in a named
  action menu
* Confirming that an action menu item does or does not exist in a named
  action menu within a container

The existing action menu steps were insufficient as they assume that
there is only one action menu within he container, which is not
necessarily the case.

The existing action menu steps are not non-JS friendly and will error if
JS is disabled, without providing any fallback when one is easily
available.

Unfortunately these steps cannot be used to replace the existing steps
without manual intervention.
2022-11-03 21:39:15 +08:00
Víctor Déniz
d76550da83 Merge branch 'MDL-75969-master' of https://github.com/andrewnicols/moodle 2022-10-27 15:29:40 +01:00
Jun Pataleta
c76a2a05ba Merge branch 'MDL-72558' of https://github.com/NoelDeMartin/moodle 2022-10-26 13:37:45 +08:00
Andrew Nicols
872eef9c9a MDL-75969 behat: Allow the editor field to request a save
Some editors do not immediately store their content to the textarea they
represent and only do so when the form is submitted or they are
requested to.

This change adds to the existing API to allow an (optional)
`store_current_value` function to be defined for the editor type so that
it can use the JavaScript API to persist any current content to the
editor.
2022-10-14 23:46:25 +08:00
Andrew Nicols
febd5d944c MDL-75985 behat: Standardise HTML output when comparing editor content
This commit adds a standardise_html function and updates the matches
function to compare normalised content.

This allows for a wider variety of valid editor output to be handled
using the standard value matching steps in Behat, thus supporting
editors other than Atto better.
2022-10-14 23:44:56 +08:00
Noel De Martin
594a64348a MDL-72558 behat: Remove legacy mobile app code 2022-10-13 09:18:40 +02:00
Simey Lameze
baa1e52530 MDL-75887 behat: Add ability to set value regardless of the editor
Prior to this commit, the behat_form_editor integration was hard-coded
to use Atto.

This change allows other editors to be used to set editor values, and
breaks that hard bond. Following this change, any editor is able to
define a behat_editor_[name].php file defining a function which meets
the following signature:

  set_editor_value(string $editorid, string $value): void

Each editor is responsible for checking whether its own API is available
and calling any relevant functions to force the editor to set the
content.

Please note: Behat is unable to determine the current editor in use on
the page automatically.
2022-10-12 06:44:09 +08:00
Andrew Nicols
13cc3607de MDL-75886 atto: Always use Atto for @atto tests
This change, which should be easy to mimic for other editors.

This will ensure that the correct editor is used for tests relating to
that editor, or its subplugins.
2022-10-05 09:54:21 +08:00
Jun Pataleta
9441d5294e Merge branch 'MDL-75559-master' of https://github.com/andrewnicols/moodle 2022-09-29 10:54:20 +08:00
Andrew Nicols
7bb3291e1c Merge branch 'MDL-75456-master' of https://github.com/lameze/moodle 2022-09-27 11:13:46 +08:00
Mihail Geshoski
460744a6a6 MDL-75153 form: Behat support for group structures in select menu field
Adds behat support for group structures in the select menu field. When
looking for a particular option you can further specify the group under
which this option should be located by using the '>' delimiter
(e.g. "Group name > Option name"). In addition to that, this commit
intorduces new step definition which can be used to check whether the
select menu field contains a particular option.
2022-09-20 00:17:55 +08:00
Andrew Nicols
5412ddbf97 MDL-75559 behat: Sort behat_hooks to top of context list 2022-09-12 12:32:35 +08:00
Shamim Rezaie
5d33ef3c21 MDL-75155 behat: Add select_menu field type
This commit introduces a new partial selector for select_menu fields,
and teaching the field manager how to recognise these, then introducing
a new field type which can handle setting values for this field.
2022-09-06 13:38:28 +10:00
Shamim Rezaie
cad62440e3 Merge branch 'MDL-73876-master' of https://github.com/ilyatregubov/moodle 2022-08-17 02:32:00 +10:00
Simey Lameze
7abd77f565 MDL-75456 behat: final deprecation of get_node_type() and get_field() 2022-08-15 12:58:05 +08:00
Jun Pataleta
87e513e439 MDL-74800 core: block actions fix suggestion 2022-08-08 14:46:42 +02:00
Andrew Lyons
019c633bd9 MDL-73876 behat: Show exceptions stack trace 2022-08-04 16:50:59 +04:00
Andrew Nicols
6d46332a94 Merge branch 'MDL-74613-master' of https://github.com/NoelDeMartin/moodle 2022-06-30 11:02:41 +08:00
Alfonso Salces
db7178edca MDL-74674 core: create notification generators 2022-06-29 10:31:40 +02:00
Noel De Martin
bbaf83322f MDL-74613 grade: Add missing generators 2022-05-31 17:59:52 +02:00
Eloy Lafuente (stronk7)
c21a82df58 MDL-72446 behat: Ensure that the day reset happens on enabled element
Before this change we were setting the month day to 1 unconditionally
and that was working ok for enabled by default elements.

But in a number or cases we were doing that against disabled elements
so the day reset was not happening. Now we wait for the element to
be enabled and only then proceed with the day reset.

Backed with tests using disabled form elements, so we have now
both enabled and disabled fields covered.
2022-03-31 11:29:22 +02:00
Andrew Nicols
c3404942e4 MDL-74116 behat: Fix browser instantiation for Selenium 4 2022-03-16 22:29:20 +08:00
Jake Dallimore
a745a7dfae Merge branch 'MDL-73899-master' of https://github.com/andrewnicols/moodle 2022-03-10 15:34:21 +08:00
Eloy Lafuente (stronk7)
3a016e2784 MDL-73824 gradebook: Add support for localised floats where missing
It has been detected, thanks to php80 specially, that there are
various places in core where support for localised floats is
missing. Before php80, some locale-dependent conversions were
performed by PHP, allowing things to work. But with php80 all
those comparisons are now locale-independent. See:

https://wiki.php.net/rfc/locale_independent_float_to_string

That implies that we now need to, always, unformat floats to
be internally the correct (decimal point as separator) in
order to compare it.

While this was visited in the php80 epic (MDL-70745), nothing
was found, all automated tests were passing ok. Problem is that
we run behat tests with en-AU laguage that has the decimal point
separator.

So, in this issue we are fixing all the problems detected by
running those Behat tests using localised (comma) decimal
separator.

Note that there may be other places still causing problems, but
it's really hard to find them programmatically, so we'll have to
wait for real use reports / issues and go fixing them while they
happen.

Back to this commit, this is the list of changes performed (note that
in the next commit, we'll be adding scenarios explicitly using
a localised decimal separator to ensure that they work ok).

A. Changes to various grade forms to ensure that, on their validation
  floats are unformatted properly. Also, changed the corresponding
  form element from current text/PARAM_RAW to proper float ones that
  take care of the conversion in a number of places (but when disabled,
  that's the reason we still have to unformat in validation.
  This includes the following forms:
    - edit_category_form
    - edit_item_form
  (this is the original problem reported that cause all the research
  to be performed against full behat runs)

B. Changes to edit_letter_form, so it uses a proper PARAM_LOCALISEDFLOAT
  (note this is the type of change that surely should be used for all
  the rest of /grade/edit/tree form, including those in the previous
  point).

C. Changes to the grade_item behat generator, so it's able to work with
  localised floats, un-formatting them when needed.
  At lib/behat/classes/behat_core_generator.php

D. Fix problem passing localised floats to scales, not displaying
  properly. At grade/report/singleview/classes/local/ui/finalgrade.php

E. Change the behat text matcher in order to allow comparison of
  localised floats when they are the current ones. Before this change
  the matches was using soft/lazy comparison, so '50' and '50.0000'
  match. Now, when the comma (for example) is used (and only then),
  '50' and '50,000' will also match. This comparison is in use in a
  bunch of tests and makes sense to make it localisation-aware.
  At grade/report/singleview/classes/local/ui/finalgrade.php

F. Fix a couple of number_format() uses in lesson, because they are
  not localised-aware. Switched to format_float(). At mod/lesson/locallib.php

G. Change the quiz_contains_the_following_questions() step to accept
  localised maxmark expectations. At mod/quiz/tests/behat/behat_mod_quiz.php

H. Change the quiz generator so it accepts localised gradepass.
  At mod/quiz/tests/generator/lib.php

I. Change the edit question form to show proper localised penalties,
  previously it was always showing point-decimal ones. Of course,
  leaving the values of the select element unmodified (internal floats).
  Related, also change a couple of tests to, instead of try to match the
  value (always internal floats), match the description (now localised),
  so we can test them with different separators. At:
    - question/type/ddimageortext/tests/behat/backup_and_restore.feature
    - question/type/ddmarker/tests/behat/backup_and_restore.feature
    - question/type/edit_question_form.php
2022-03-04 10:22:49 +01:00
Andrew Nicols
39588c2ee1 MDL-73899 behat: Fix coding style issues to change third-party status
This commit removes the moodle-behat-extension from the list of
third-party libraries.

In order to do this properly, all pending coding-style issues are fixed.
In addition the following niceties have also been included:
* convert long form array() syntax to short form
* alphabetically sort class imports (use)
* remove unused class imports
* correct documentation
* Normalise whitespace in concat operators
* Remove unnecessary file docblocks
2022-02-23 08:19:30 +08:00
Sara Arjona
78408e5017 Merge branch 'MDL-73883-master' of https://github.com/andrewnicols/moodle 2022-02-21 15:35:11 +01:00
Shamim Rezaie
7015cbf75f MDL-73592 phpunit: Run adhoc tasks after install 2022-02-18 02:09:49 +11:00
Andrew Nicols
0491ccb6c8 MDL-73883 behat: Display actual step during testing
Because of the way in which we check for exceptions, we always show the
following string during behat pretty output:

    behat_hooks::i_look_for_exceptions()

We can easily modify this to only show this value when the
i_look_for_exceptions() test itself fails, but otherwise to show the
actual step that is run.
2022-02-15 14:57:00 +08:00
Eloy Lafuente (stronk7)
83497580cb Merge branch 'MDL-73669-master' of https://github.com/marinaglancy/moodle 2022-02-10 16:39:06 +01:00
Marina Glancy
31751c2f32 MDL-73669 behat: allow multiple files with deprecated steps 2022-02-04 17:17:08 +01:00