Skip to content

Commit

Permalink
[QOLDEV-955] prepare scenario test expectations for latest CKAN
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Nov 20, 2024
1 parent bff3e3b commit 9e77637
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions ckanext/qgov/common/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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):
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion test/features/resources.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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=<name>::url=<url>"
And I press the element with xpath "//a[contains(@title, '<name>') and contains(string(), '<name>')]"
And I press the element with xpath "//a[(contains(@title, '<name>') or contains(@aria-label, 'Navigate to resource: <name>')) and contains(string(), '<name>')]"
Then I should see "<url>"

Examples:
Expand Down
12 changes: 7 additions & 5 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]"
""")


Expand Down Expand Up @@ -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"
""")
Expand Down Expand Up @@ -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}'"
Expand Down Expand Up @@ -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"
""")

Expand Down
2 changes: 1 addition & 1 deletion test/features/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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']"

0 comments on commit 9e77637

Please sign in to comment.