From 9e77637b598242c118925252ded9cf175d6e97a3 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Wed, 20 Nov 2024 15:03:05 +1000 Subject: [PATCH] [QOLDEV-955] prepare scenario test expectations for latest CKAN --- bin/build.sh | 2 +- ckanext/qgov/common/views/user.py | 8 ++++---- test/features/resources.feature | 2 +- test/features/steps/steps.py | 12 +++++++----- test/features/users.feature | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 0be862d..0206189 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -28,7 +28,7 @@ if [ "$CKAN_VERSION" = "2.11" ]; then CKAN_GIT_VERSION=ckan-2.11.0 elif [ "$CKAN_VERSION" = "2.10" ]; then if [ "$CKAN_TYPE" = "custom" ]; then - CKAN_GIT_VERSION=ckan-2.10.5-qgov.1 + CKAN_GIT_VERSION=ckan-2.10.5-qgov.4 else CKAN_GIT_VERSION=ckan-2.10.5 fi diff --git a/ckanext/qgov/common/views/user.py b/ckanext/qgov/common/views/user.py index 1d0da5c..3686a5a 100644 --- a/ckanext/qgov/common/views/user.py +++ b/ckanext/qgov/common/views/user.py @@ -4,8 +4,7 @@ from typing import Any from ckan.plugins.toolkit import g, redirect_to, url_for -import ckan.views.user -from ckan.views.user import _ as original_gettext, EditView +from ckan.views import user as user_view blueprint = Blueprint(u'user_overrides', __name__) @@ -21,7 +20,7 @@ def user_edit_override(): return redirect_to(url_for( u'user.login', came_from=url_for(u'user.edit'))) - return EditView().dispatch_request() + return user_view.EditView().dispatch_request() def _gettext_wrapper(*args: Any, **kwargs: Any): @@ -32,7 +31,8 @@ def _gettext_wrapper(*args: Any, **kwargs: Any): blueprint.add_url_rule(u'/user/edit', u'edit', user_edit_override) -ckan.views.user._ = _gettext_wrapper +original_gettext = user_view._ +user_view._ = _gettext_wrapper def get_blueprints(): diff --git a/test/features/resources.feature b/test/features/resources.feature index 66ed1e6..125aeac 100644 --- a/test/features/resources.feature +++ b/test/features/resources.feature @@ -6,7 +6,7 @@ Feature: Resource UI When I log in And I open the new resource form for dataset "test-dataset" And I create a resource with key-value parameters "name=::url=" - And I press the element with xpath "//a[contains(@title, '') and contains(string(), '')]" + And I press the element with xpath "//a[(contains(@title, '') or contains(@aria-label, 'Navigate to resource: ')) and contains(string(), '')]" Then I should see "" Examples: diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index ff61141..f9c41dc 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -69,10 +69,11 @@ def log_in_directly(context): :return: """ - assert context.persona, "A persona is required to log in, found [{}] in context. Have you configured the personas in before_scenario?".format(context.persona) + assert context.persona, "A persona is required to log in, found [{}] in context." \ + " Have you configured the personas in before_scenario?".format(context.persona) context.execute_steps(u""" When I attempt to log in with password "$password" - Then I should see an element with xpath "//*[@title='Log out']/i[contains(@class, 'fa-sign-out')]" + Then I should see an element with xpath "//*[@title='Log out' or @data-bs-title='Log out']/i[contains(@class, 'fa-sign-out')]" """) @@ -161,7 +162,8 @@ def go_to_new_resource_form(context, name): """) else: # Existing dataset, browse to the resource form - if context.browser.is_element_present_by_xpath("//a[contains(string(), 'Resources') and contains(@href, '/dataset/resources/')]"): + if context.browser.is_element_present_by_xpath( + "//a[contains(string(), 'Resources') and contains(@href, '/dataset/resources/')]"): context.execute_steps(u""" When I press "Resources" """) @@ -254,7 +256,7 @@ def fill_in_default_link_resource_fields(context): @when(u'I upload "{file_name}" of type "{file_format}" to resource') def upload_file_to_resource(context, file_name, file_format): context.execute_steps(u""" - When I execute the script "$('#resource-upload-button').trigger(click);" + When I execute the script "$('#resource-upload-button').trigger('click');" And I attach the file "{file_name}" to "upload" # Don't quote the injected string since it can have trailing spaces And I execute the script "document.getElementById('field-format').value='{file_format}'" @@ -476,7 +478,7 @@ def go_to_admin_config(context): @when(u'I log out') def log_out(context): context.execute_steps(u""" - When I press the element with xpath "//*[@title='Log out']" + When I press the element with xpath "//*[@title='Log out' or @data-bs-title='Log out']" Then I should see "Log in" """) diff --git a/test/features/users.feature b/test/features/users.feature index 9dd395e..6c31e03 100644 --- a/test/features/users.feature +++ b/test/features/users.feature @@ -168,6 +168,6 @@ Feature: User APIs Then I should see "Promoted Test Admin to sysadmin" And I should see an element with xpath "//table//a[string() = 'Test Admin' and @href = '/user/test_org_admin']" - When I press the element with xpath "//tr/td/a[@href = '/user/test_org_admin']/../following-sibling::td//button[contains(@title, 'Revoke')]" + When I press the element with xpath "//tr/td/a[@href = '/user/test_org_admin']/../following-sibling::td//button[contains(@title, 'Revoke') or contains(@data-bs-title, 'Revoke')]" Then I should see "Revoked sysadmin permission from Test Admin" And I should not see an element with xpath "//table//a[@href = '/user/test_org_admin']"