Skip to content

Commit

Permalink
[QOLDEV-312] fix testing of validation schema generation
Browse files Browse the repository at this point in the history
- Make test datasets public so XLoader can download files without an API token.
Generating a token and injecting it into config before the test CKAN starts is problematic.
- Wait on resource page to ensure that the datastore exists before proceeding.
  • Loading branch information
ThrawnCA committed Aug 31, 2023
1 parent f32e509 commit a1c1ae1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
33 changes: 20 additions & 13 deletions test/features/schema_generation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ Feature: Schema Generation
Scenario: As a publisher, when I visit my resource, I can generate a validation schema for it
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "name=package-with-csv-res::schema_json=default" and "upload=default::format=CSV"
And I create a dataset and resource with key-value parameters "notes=package-with-csv-res::schema_json=default::private=False" and "upload=default::format=CSV"
And I take a debugging screenshot
And I go to the first resource in the dataset
And I take a debugging screenshot
# Ensure that the datastore is active
And I reload page every 3 seconds until I see an element with xpath "//*[string() = 'Data Dictionary']" but not more than 6 times
And I visit resource schema generation page
And I reload page every 3 seconds until I see an element with xpath "//ul[@class="nav nav-tabs"]/li[position()=2]/a[contains(string(), 'Data Schema')]" but not more than 6 times
Then I should see an element with xpath "//button[contains(string(), 'Generate JSON data schema')]"
And I should see an element with xpath "//button[contains(@class, 'btn-generate')]/following::table[contains(@class, 'table-schema')]"
And I take a debugging screenshot
Then I should see an element with xpath "//button[contains(string(), 'Generate JSON data schema') and contains(@class, 'btn-generate')]/following::table[contains(@class, 'table-schema')]"
And I should see an element with xpath "//th[string()='Status']/following::td[string()='Not generated']"
And I should see an element with xpath "//th[string()='Last updated']/following::td[string()='Never']"

When I press the element with xpath "//button[contains(string(), 'Generate JSON data schema')]"
When I press "Generate JSON data schema"
And I take a debugging screenshot
And I reload page every 3 seconds until I see an element with xpath "//th[string()='Status']/following::td[string()='Pending']" but not more than 6 times
Then I should see an element with xpath "//th[string()='Last updated']/following::td/span[contains(@class, 'date')]"
When I reload page every 3 seconds until I see an element with xpath "//button[string()='Apply']" but not more than 6 times
Expand All @@ -40,28 +44,31 @@ Feature: Schema Generation
Scenario: System actions following the selection of the set as dataset default dropdown option on the manage data schema GUI page
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "name=apply-for-dataset-schema::schema_json=default" and "upload=default::format=CSV"
And I create a dataset and resource with key-value parameters "notes=apply-for-dataset-schema::schema_json=default::private=False" and "upload=default::format=CSV"
And I go to the first resource in the dataset
And I reload page every 3 seconds until I see an element with xpath "//*[string() = 'Data Dictionary']" but not more than 6 times
And I visit resource schema generation page
And I reload page every 3 seconds until I see an element with xpath "//ul[@class="nav nav-tabs"]/li[position()=2]/a[contains(string(), 'Data Schema')]" but not more than 6 times
And I press the element with xpath "//button[contains(string(), 'Generate JSON data schema')]"
Then I should see an element with xpath "//button[contains(string(), 'Generate JSON data schema') and contains(@class, 'btn-generate')]/following::table[contains(@class, 'table-schema')]"
When I press "Generate JSON data schema"
And I reload page every 3 seconds until I see an element with xpath "//button[string()='Apply']" but not more than 6 times
And I select "dataset" from "apply_for"
And I press the element with xpath "//button[string()='Apply']"
And I go to dataset "apply-for-dataset-schema"
And I go to dataset "$last_generated_name"
And I show all the fields
Then I should see an element with xpath "//th[@class="dataset-label" and string()="Default data schema"]/following::a[string()="View Schema File"]"


Scenario: System actions following the selection of the validate only this resource dropdown option on the manage data schema GUI page
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "name=apply-for-resource-schema::schema_json=default" and "upload=default::format=CSV"
And I create a dataset and resource with key-value parameters "notes=apply-for-resource-schema::schema_json=default::private=False" and "upload=default::format=CSV"
And I go to the first resource in the dataset
And I reload page every 3 seconds until I see an element with xpath "//*[string() = 'Data Dictionary']" but not more than 6 times
And I visit resource schema generation page
And I reload page every 3 seconds until I see an element with xpath "//ul[@class="nav nav-tabs"]/li[position()=2]/a[contains(string(), 'Data Schema')]" but not more than 6 times
And I press the element with xpath "//button[contains(string(), 'Generate JSON data schema')]"
Then I should see an element with xpath "//button[contains(string(), 'Generate JSON data schema') and contains(@class, 'btn-generate')]/following::table[contains(@class, 'table-schema')]"
When I press "Generate JSON data schema"
And I reload page every 3 seconds until I see an element with xpath "//button[string()='Apply']" but not more than 6 times
And I select "resource" from "apply_for"
And I press the element with xpath "//button[string()='Apply']"
And I press the element with xpath "//a[contains(string(), 'View resource')]"
And I show all the fields
Then I should see an element with xpath "//th[string()="Data Schema"]/following::a[string()="View Schema File"]"
17 changes: 15 additions & 2 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def debug_screenshot(context):
"""
if context.persona and context.persona.get('debug') == 'True':
context.execute_steps(u"""
Then I take a screenshot
When I take a screenshot
""")


Expand Down Expand Up @@ -196,6 +196,16 @@ def go_to_first_resource(context):
""")


@when(u'I show all the fields')
def show_more_fields(context):
"""
Click the 'Show more' link, if present, to reveal all the metadata.
"""
context.execute_steps(u"""
When I execute the script "$('a.show-more').click()"
""")


@when(u'I edit the "{name}" dataset')
def edit_dataset(context, name):
context.execute_steps(u"""
Expand Down Expand Up @@ -559,7 +569,7 @@ def reload_page_every_n_until_find(context, xpath, seconds=5, reload_times=5):
assert False, 'Element with xpath "{}" was not found'.format(xpath)


# ckanext-data-qld
# ckanext-validation-schema-generator


@when(u'I visit resource schema generation page')
Expand All @@ -570,6 +580,9 @@ def resource_schema_generation(context):
""".format(path))


# ckanext-data-qld


@when(u'I trigger notification about updated privacy assessment results')
def i_trigger_notification_assessment_results(context):
context.execute_steps(u"""
Expand Down

0 comments on commit a1c1ae1

Please sign in to comment.