Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QOLDEV-955 fix testing on CKAN 2.11 and master #150

Merged
merged 8 commits into from
Jan 29, 2025
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
6 changes: 5 additions & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion ckanext/qgov/common/intercepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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.
"""
Expand Down
7 changes: 4 additions & 3 deletions ckanext/qgov/common/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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():
Expand Down
12 changes: 6 additions & 6 deletions test/features/organisations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 22 additions & 1 deletion test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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."
""")
Loading