Skip to content

Commit

Permalink
Merge pull request #261 from qld-gov-au/QOLSVC-8587-non-truncated-titles
Browse files Browse the repository at this point in the history
QOLSVC-8587 add scenario testing for title truncation
  • Loading branch information
ThrawnCA authored Dec 13, 2024
2 parents 8afd1a3 + e43b256 commit 3a2e914
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 12 deletions.
1 change: 1 addition & 0 deletions .docker/ckan.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ckan.datastore.default_fts_index_method = gist

## Site Settings.
ckan.site_url = http://ckan:5000/
WTF_CSRF_ENABLED = False

## Authorization Settings

Expand Down
2 changes: 1 addition & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CKAN_GIT_VERSION=$CKAN_VERSION
CKAN_GIT_ORG=qld-gov-au

if [ "$CKAN_VERSION" = "2.10" ]; then
CKAN_GIT_VERSION=ckan-2.10.1-qgov.10
CKAN_GIT_VERSION=ckan-2.10.5-qgov.4
PYTHON_VERSION=py3
PYTHON="${PYTHON}3"
else
Expand Down
1 change: 1 addition & 0 deletions test/features/data_usability_rating.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@data_usability_rating
@OpenData
@multi_plugin
Feature: Data usability rating

Scenario Outline: As a publisher, when I create a resource with an open license, I can verify the openness score is correct
Expand Down
1 change: 1 addition & 0 deletions test/features/datasets.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@dataset
Feature: Dataset APIs

Scenario: Creative Commons BY-NC-SA 4.0 licence is an option for datasets
Expand Down
31 changes: 30 additions & 1 deletion test/features/groups.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@users
@groups
Feature: Group APIs

Scenario Outline: Group membership is accessible to admins of the group
Expand Down Expand Up @@ -39,3 +39,32 @@ Feature: Group APIs

When I view the "silly-walks" group API "not including" users
Then I should see an element with xpath "//*[contains(string(), '"success": true') and contains(string(), '"name": "silly-walks"')]"

Scenario: As a sysadmin, when I create a group with a long name, it should be preserved
Given "SysAdmin" as the persona
When I log in
And I go to group page
And I click the link to "/group/new"
And I fill in title with random text starting with "Group name more than 35 characters"
And I set "group_title" to "$last_generated_title"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
And I take a debugging screenshot
# Breadcrumb should be truncated but preserve full name in a tooltip
Then I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"

# 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 group name" and "name=Test"
And I press "Groups"
When I select by text " $group_title" from "group_added"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
Then I should see an element with xpath "//form//a[normalize-space() = '$group_title']"
When I press "$group_title"

Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"
When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"
Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"

When I go to dataset page
Then I should see an element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"
When I press the element with xpath "//li[contains(@class, 'nav-item')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"
Then I should see an element with xpath "//li[contains(@class, 'nav-item') and contains(@class, 'active')]//a[contains(string(), 'Group name more') and contains(string(), '...') and @title = '$group_title']"
24 changes: 23 additions & 1 deletion test/features/organisations.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@users
@organisations
Feature: Organization APIs

Scenario Outline: Organisation membership is accessible to admins of the organisation
Expand Down Expand Up @@ -48,3 +48,25 @@ Feature: Organization APIs
And I press "My Organisations"
Then I should see "Test Organisation"
And I should see an element with xpath "//a[contains(@href, 'organization/new') and contains(string(), 'Add Organisation')]"

Scenario: As a sysadmin, when I create an organisation with a long name, it should be preserved
Given "SysAdmin" as the persona
When I log in
And I go to organisation page
And I click the link to "/organization/new"
And I fill in title with random text starting with "Org name more than 35 characters"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
And I take a debugging screenshot
# Breadcrumb should be truncated but preserve full name in a tooltip
Then I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(string(), 'Org name more than') and contains(string(), '...') and contains(@title, 'Org name more than 35 characters')]"

# 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')]"
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')]"
38 changes: 29 additions & 9 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def request_reset(context):
@when(u'I fill in "{name}" with "{value}" if present')
def fill_in_field_if_present(context, name, value):
context.execute_steps(u"""
When I execute the script "field = $('#field-{0}'); if (!field.length) field = $('#{0}'); if (!field.length) field = $('[name={0}]'); field.val('{1}'); field.keyup();"
When I execute the script "field = $('#{0}'); if (!field.length) field = $('[name={0}]'); if (!field.length) field = $('#field-{0}'); field.val('{1}'); field.keyup();"
""".format(name, value))


Expand Down Expand Up @@ -195,13 +195,24 @@ def go_to_new_resource_form(context, name):

@when(u'I fill in title with random text')
def title_random_text(context):
assert context.persona
context.execute_steps(u"""
When I fill in "title" with "Test Title {0}"
And I fill in "name" with "test-title-{0}" if present
And I set "last_generated_title" to "Test Title {0}"
And I set "last_generated_name" to "test-title-{0}"
""".format(uuid.uuid4()))
When I fill in title with random text starting with "Test Title "
""")


@when(u'I fill in title with random text starting with "{prefix}"')
def title_random_text_with_prefix(context, prefix):
random_text = str(uuid.uuid4())
title = prefix + random_text
name = prefix.lower().replace(" ", "-") + random_text
assert context.persona
context.execute_steps(f"""
When I fill in "title" with "{title}"
And I fill in "name" with "{name}" if present
And I set "last_generated_title" to "{title}"
And I set "last_generated_name" to "{name}"
And I take a debugging screenshot
""")


@when(u'I go to dataset page')
Expand Down Expand Up @@ -252,6 +263,15 @@ def select_licence(context, licence_id):
""".format(licence_id))


@when(u'I select the organisation with title "{title}"')
def select_organisation(context, title):
# Organisation requires special interaction due to fancy JavaScript
context.execute_steps(u"""
When I execute the script "org_uuid=$('#field-organizations').find('option:contains({0})').val(); $('#field-organizations').val(org_uuid).trigger('change')"
And I take a debugging screenshot
""".format(title))


@when(u'I enter the resource URL "{url}"')
def enter_resource_url(context, url):
if url != "default":
Expand Down Expand Up @@ -441,8 +461,8 @@ def _create_dataset_from_params(context, params):
if key == "owner_org":
# Owner org uses UUIDs as its values, so we need to rely on displayed text
context.execute_steps(u"""
When I select by text "{1}" from "{0}"
""".format(key, value))
When I select the organisation with title "{0}"
""".format(value))
elif key in ["update_frequency", "request_privacy_assessment", "private"]:
context.execute_steps(u"""
When I select "{1}" from "{0}"
Expand Down

0 comments on commit 3a2e914

Please sign in to comment.