diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1460164..6e16908 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,12 @@ jobs: include: - ckan-version: '2.11' solr-version: "9" + ckan-type: 'vanilla' experimental: true + - ckan-version: '2.11' + solr-version: "9" + ckan-type: 'custom' + experimental: false - ckan-version: 'master' solr-version: "9" experimental: true #master is unstable, good to know if we are compatible or not @@ -100,7 +105,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: CKAN ${{ matrix.ckan-version }} screenshots + name: CKAN ${{ matrix.ckan-version }} ${{ matrix.ckan-type }} screenshots path: /tmp/artifacts/behave/screenshots timeout-minutes: 1 continue-on-error: ${{ matrix.experimental }} diff --git a/bin/build.sh b/bin/build.sh index ff0780c..ddd3607 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -25,7 +25,11 @@ else fi if [ "$CKAN_VERSION" = "2.11" ]; then - CKAN_GIT_VERSION=ckan-2.11.1 + if [ "$CKAN_TYPE" = "custom" ]; then + CKAN_GIT_VERSION=ckan-2.11.1-qgov.2 + else + CKAN_GIT_VERSION=ckan-2.11.1 + fi elif [ "$CKAN_VERSION" = "2.10" ]; then if [ "$CKAN_TYPE" = "custom" ]; then CKAN_GIT_VERSION=ckan-2.10.5-qgov.5 diff --git a/ckanext/qgov/common/intercepts.py b/ckanext/qgov/common/intercepts.py index baab3cf..0fb6ff5 100644 --- a/ckanext/qgov/common/intercepts.py +++ b/ckanext/qgov/common/intercepts.py @@ -19,6 +19,8 @@ DEFAULT_USER_SCHEMA = schemas.default_user_schema() USER_NEW_FORM_SCHEMA = schemas.user_new_form_schema() +if hasattr(schemas, 'user_perform_reset_form_schema'): + USER_PERFORM_RESET_FORM_SCHEMA = schemas.user_perform_reset_form_schema() USER_EDIT_FORM_SCHEMA = schemas.user_edit_form_schema() DEFAULT_UPDATE_USER_SCHEMA = schemas.default_update_user_schema() RESOURCE_SCHEMA = schemas.default_resource_schema() @@ -46,8 +48,9 @@ def set_intercepts(): schemas.default_user_schema = default_user_schema schemas.user_new_form_schema = user_new_form_schema schemas.user_edit_form_schema = user_edit_form_schema + if hasattr(schemas, 'user_perform_reset_form_schema'): + schemas.user_perform_reset_form_schema = user_perform_reset_form_schema schemas.default_update_user_schema = default_update_user_schema - schemas.default_resource_schema = default_resource_schema @@ -118,6 +121,14 @@ def user_new_form_schema(): return user_schema +def user_perform_reset_form_schema(): + """ Apply our password validator function when resetting a password. + """ + user_schema = USER_PERFORM_RESET_FORM_SCHEMA + user_schema = _apply_schema_validator(user_schema, 'password1') + return user_schema + + def user_edit_form_schema(): """ Apply our password validator function when editing an existing user. """ diff --git a/ckanext/qgov/common/views/user.py b/ckanext/qgov/common/views/user.py index 4baee8d..3c9315c 100644 --- a/ckanext/qgov/common/views/user.py +++ b/ckanext/qgov/common/views/user.py @@ -3,7 +3,7 @@ from flask import Blueprint from typing import Any -from ckan.plugins.toolkit import g, redirect_to, url_for +from ckan.plugins.toolkit import config, g, redirect_to, url_for from ckan.views import user as user_view blueprint = Blueprint(u'user_overrides', __name__) @@ -31,8 +31,9 @@ def _gettext_wrapper(*args: Any, **kwargs: Any): blueprint.add_url_rule(u'/user/edit', u'edit', user_edit_override) -original_gettext = user_view._ -user_view._ = _gettext_wrapper +if config.get('ckan.recaptcha.privatekey'): + original_gettext = user_view._ + user_view._ = _gettext_wrapper def get_blueprints(): diff --git a/test/features/organisations.feature b/test/features/organisations.feature index 6289879..8d37e97 100644 --- a/test/features/organisations.feature +++ b/test/features/organisations.feature @@ -70,10 +70,10 @@ Feature: Organization APIs # Search facets should be truncated but preserve full name in a tooltip When I create a dataset and resource with key-value parameters "notes=Testing long org name::owner_org=Org name more than" and "name=Test" And I press "Org name more than" - Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" - When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" - Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" + Then I should see a search facet for "Org name more than 35 characters" truncated to "Org name more than" + When I press the search facet pointing to "Org name more than 35 characters" + Then I should see an active search facet for "Org name more than 35 characters" truncated to "Org name more than" When I go to dataset page - Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" - When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" - Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]" + Then I should see a search facet for "Org name more than 35 characters" truncated to "Org name more than" + When I press the search facet pointing to "Org name more than 35 characters" + Then I should see an active search facet for "Org name more than 35 characters" truncated to "Org name more than" diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 866ed7f..cca1446 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -104,6 +104,27 @@ def request_reset(context): """) +@then(u'I should see a search facet for "{title}" truncated to "{truncated_title}"') +def truncated_facet_visible(context, title, truncated_title): + context.execute_steps(u""" + Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), '{truncated_title}') and contains(string(), '...') and (contains(@title, '{title}') or contains(@data-bs-title, '{title}'))]" + """.format(title=title, truncated_title=truncated_title)) + + +@then(u'I should see an active search facet for "{title}" truncated to "{truncated_title}"') +def active_truncated_facet_visible(context, title, truncated_title): + context.execute_steps(u""" + Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), '{truncated_title}') and contains(string(), '...') and (contains(@title, '{title}') or contains(@data-bs-title, '{title}'))]" + """.format(title=title, truncated_title=truncated_title)) + + +@when(u'I press the search facet pointing to "{title}"') +def press_search_facet(context, title): + context.execute_steps(u""" + When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(@title, '{0}') or contains(@data-bs-title, '{0}')]" + """.format(title)) + + @when(u'I fill in "{name}" with "{value}" if present') def fill_in_field_if_present(context, name, value): context.execute_steps(u""" @@ -543,5 +564,5 @@ def lock_account(context): for x in range(11): context.execute_steps(u""" When I attempt to log in with password "incorrect password" - Then I should see "Bad username or password or CAPTCHA." + Then I should see "Bad username or password." """)