From a1c1ae181c787554affcc0e3bab16a70d40c0ea5 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 31 Aug 2023 11:13:10 +1000 Subject: [PATCH] [QOLDEV-312] fix testing of validation schema generation - 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. --- test/features/schema_generation.feature | 33 +++++++++++++++---------- test/features/steps/steps.py | 17 +++++++++++-- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/test/features/schema_generation.feature b/test/features/schema_generation.feature index 148eed2b..7faee434 100644 --- a/test/features/schema_generation.feature +++ b/test/features/schema_generation.feature @@ -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 @@ -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"]" diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 73d687e9..9da4eee4 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -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 """) @@ -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""" @@ -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') @@ -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"""