catalyst / moodle-mod_subcourse

Subcourse module for Moodle
https://moodle.org/plugins/mod_subcourse
GNU General Public License v3.0
23 stars 40 forks source link

Change to behat selector in Moodle might be breaking tests #93

Open sharpchi opened 1 month ago

sharpchi commented 1 month ago

I was just running behat tests against your plugin (MOODLE_401_STABLE) on M4.1.12. I get the following errors, which I've not seen before on previous runs. Moodle recently made a change to the table selector in MDL-80907 - maybe connected?

002 Scenario: Grades are fetched as real values by default       # /var/www/html/mod/subcourse/tests/behat/fetch_percentage_grades.feature:118
      And the following should exist in the "user-grades" table: # /var/www/html/mod/subcourse/tests/behat/fetch_percentage_grades.feature:109
        (//html/.//table[(./@id = 'user-grades' or contains(.//caption, 'user-grades') or contains(.//th, 'user-grades') or contains(concat(' ', normalize-space(@class), ' '), 'user-grades' ))])[1][thead/tr[1]/th[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])] | tbody/tr[1]/td[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])]]

        Column matching locator "Email address" in table "user-grades"" not found. (Behat\Mink\Exception\ElementNotFoundException)

003 Scenario: Grades can be fetched as percentual values         # /var/www/html/mod/subcourse/tests/behat/fetch_percentage_grades.feature:148
      And the following should exist in the "user-grades" table: # /var/www/html/mod/subcourse/tests/behat/fetch_percentage_grades.feature:109
        (//html/.//table[(./@id = 'user-grades' or contains(.//caption, 'user-grades') or contains(.//th, 'user-grades') or contains(concat(' ', normalize-space(@class), ' '), 'user-grades' ))])[1][thead/tr[1]/th[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])] | tbody/tr[1]/td[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])]]

        Column matching locator "Email address" in table "user-grades"" not found. (Behat\Mink\Exception\ElementNotFoundException)

004 Scenario: If the course final grade is hidden, the associated subcourse activity grade is marked as hidden, too. # /var/www/html/mod/subcourse/tests/behat/hidden_grades.feature:49
      Then the following should exist in the "user-grades" table:                                                    # /var/www/html/mod/subcourse/tests/behat/hidden_grades.feature:62
        (//html/.//table[(./@id = 'user-grades' or contains(.//caption, 'user-grades') or contains(.//th, 'user-grades') or contains(concat(' ', normalize-space(@class), ' '), 'user-grades' ))])[1][thead/tr[1]/th[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])] | tbody/tr[1]/td[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])]]

        Column matching locator "Email address" in table "user-grades"" not found. (Behat\Mink\Exception\ElementNotFoundException)

005 Scenario: If the whole course final grade item is hidden, the associated subcourse activity grade item is marked as hidden, too. # /var/www/html/mod/subcourse/tests/behat/hidden_grades.feature:88
      Then the following should exist in the "user-grades" table:                                                                    # /var/www/html/mod/subcourse/tests/behat/hidden_grades.feature:105
        (//html/.//table[(./@id = 'user-grades' or contains(.//caption, 'user-grades') or contains(.//th, 'user-grades') or contains(concat(' ', normalize-space(@class), ' '), 'user-grades' ))])[1][thead/tr[1]/th[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])] | tbody/tr[1]/td[(normalize-space(.)='Email address' or a[normalize-space(text())='Email address'] or div[normalize-space(text())='Email address'])]]

        Column matching locator "Email address" in table "user-grades"" not found. (Behat\Mink\Exception\ElementNotFoundException)
sharpchi commented 1 month ago

Changing "Email address" for "-3-" works around the slightly wonky selector as per https://github.com/HuongNV13/moodle/commit/MDL-80907-401

danmarsden commented 1 month ago

cool thanks - behat tests on this repo haven't been passing for a while (also mentioned in #78) but I don't know if those are the same as these ones - pull requests with fixes are always very welcome! :-)

sharpchi commented 1 month ago

ISSUE93_table_selector.txt I'm only really working on one branch, but here's a diff for MOODLE_401_STABLE