Skip to content

Commit

Permalink
[QOLDEV-312] adjust schema alignment tests to work with or without Ja…
Browse files Browse the repository at this point in the history
…vaScript

- If JavaScript is enabled, use it to reveal the fallback elements so we can test consistently
  • Loading branch information
ThrawnCA committed Sep 5, 2023
1 parent 0ccf676 commit baa7633
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/features/resource_align_default_schema.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ Feature: Resource align_default_schema field
Then I should see an element with xpath "//th[@class="dataset-label" and string()="Default data schema"]/following-sibling::td[contains(string(), "[blank]")]"

When I go to the first resource in the dataset
And I press the element with xpath "//a[contains(string(),'Manage')]"
And I press "Manage"
Then I should not see "Align this data schema with the dataset default"
And I should see "Upload"
And I should see "Link"
And I should see "JSON"
And I should see an element with xpath "//div[@id='resource-schema-buttons']/label[contains(string(), 'Data Schema')]"
When I show the non-JavaScript schema fields
Then I should see "Upload Data Schema"
And I should see "Data Schema URL"
And I should see "Data Schema JSON definition"

When I open the new resource form for dataset "$last_generated_name"
Then I should not see "Align this data schema with the dataset default"
And I should see "Upload"
And I should see "Link"
And I should see "JSON"
When I show the non-JavaScript schema fields
Then I should see "Upload Data Schema"
And I should see "Data Schema URL"
And I should see "Data Schema JSON definition"

Scenario: Create resource with schema not aligned to default schema
Given "TestOrgEditor" as the persona
Expand Down Expand Up @@ -51,7 +54,7 @@ Feature: Resource align_default_schema field
Then I should see an element with xpath "//body[contains(string(), '"Resource schema"')]"

When I go back
And I press the element with xpath "//a[contains(string(), 'Manage')]"
And I press "Manage"
Then I should see an element with xpath "//input[@type='checkbox' and @name='align_default_schema' and not(@checked)]/following-sibling::label[@for='field-align_default_schema' and contains(string(),'Align this data schema with the dataset default')]"

When I check "align_default_schema"
Expand All @@ -68,31 +71,31 @@ Feature: Resource align_default_schema field

When I go to the first resource in the dataset
Then I should see an element with xpath "//th[string()='Aligned with default data schema']/following-sibling::td[string()='FALSE']"
When I press the element with xpath "//a[contains(string(), 'Manage')]"
When I press "Manage"
Then I should see "Align this data schema with the dataset default"

When I execute the script "document.getElementById('field-schema').value='{"fields":[{"format": "default","name": "Game Number","type": "integer"},{"format": "default","name": "Game Length","type": "integer"}],"missingValues": ["Default schema"]}'"
And I press the element with xpath "//button[string()='Update Resource']"
Then I should see an element with xpath "//th[string()='Aligned with default data schema']/following-sibling::td[string()='TRUE']"

# now default and resource schema are the same
When I press the element with xpath "//a[contains(string(), 'Manage')]"
When I press "Manage"
Then I should not see "Align this data schema with the dataset default"

# now default and resource schema are different
When I press the element with xpath "//textarea[@id='field-schema-json']/preceding-sibling::a[string()='Clear']"
When I execute the script "$('#field-schema-json ~ a.btn-remove-url').click()"
And I execute the script "document.getElementById('field-schema').value='{"fields":[{"format": "default","name": "Game Number","type": "integer"},{"format": "default","name": "Game Length","type": "integer"}], "missingValues": ["Resource schema"]}'"

When I press the element with xpath "//button[string()='Update Resource']"
And I press the element with xpath "//a[contains(string(), 'Manage')]"
And I press "Manage"
Then I should see "Align this data schema with the dataset default"

When I press the element with xpath "//button[string()='Update Resource']"
And I click the link with text "View Schema File"
Then I should see an element with xpath "//body[contains(string(), '"Resource schema"')]"

When I go back
And I press the element with xpath "//a[contains(string(), 'Manage')]"
And I press "Manage"
Then I should see an element with xpath "//input[@type='checkbox' and @name='align_default_schema' and not(@checked)]/following-sibling::label[@for='field-align_default_schema' and contains(string(), 'Align this data schema with the dataset default')]"

When I check "align_default_schema"
Expand Down
6 changes: 6 additions & 0 deletions test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ def _parse_params(param_string):
return six.iteritems(params)


@when(u'I show the non-JavaScript schema fields')
def reveal_non_js_schema_fields(context):
context.execute_steps(u"""
When I execute the script "$('#resource-schema-buttons ~ div.form-group').attr('style', '')"
""")

# Enter a JSON schema value
# This can require JavaScript interaction, and doesn't fit well into
# a step invocation due to all the double quotes.
Expand Down

0 comments on commit baa7633

Please sign in to comment.