Skip to content

Commit

Permalink
[QOLDEV-312] refactor to clean up test steps
Browse files Browse the repository at this point in the history
- Use the 'press' step for more robustness, instead of 'link with text that contains'
- Invoke steps rather than directly calling functions when possible
  • Loading branch information
ThrawnCA committed Jun 20, 2023
1 parent 0097355 commit 9d575d7
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 77 deletions.
34 changes: 17 additions & 17 deletions test/features/admin_reporting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Feature: AdminReporting
Given "TestOrgAdmin" as the persona
When I log in
And I visit "dashboard"
And I click the link with text that contains "My Reports"
And I click the link with text that contains "Admin Report"
And I press "My Reports"
And I press "Admin Report"
Then I should see an element with id "organisation"
When I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see "Organisation: Test Organisation" within 1 seconds
Expand All @@ -18,14 +18,14 @@ Feature: AdminReporting
Given "TestOrgEditor" as the persona
When I log in
And I visit "dashboard"
And I click the link with text that contains "My Reports"
And I press "My Reports"
Then I should not see an element with xpath "//a[contains(string(), 'Admin Report')]"

Scenario: As an admin user of my organisation, when I view my admin report, I can verify the de-identified datasets row exists
Given "TestOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='de-identified-datasets']/td[contains(@class, 'metric-title') and contains(string(), 'De-identified Datasets') and position()=1]"
Then I should see an element with xpath "//tr[@id='de-identified-datasets']/td[contains(@class, 'metric-data') and position()=2]"
Expand All @@ -34,7 +34,7 @@ Feature: AdminReporting
Given "TestOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='overdue-datasets']/td[contains(@class, 'metric-title') and contains(string(), 'Overdue Datasets') and position()=1]"
And I should see an element with xpath "//tr[@id='overdue-datasets']/td[contains(@class, 'metric-data') and position()=2]"
Expand All @@ -43,31 +43,31 @@ Feature: AdminReporting
Given "ReportingOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='datasets_no_groups']/td[contains(@class, 'metric-title') and position()=1]/a[contains(@href, 'datasets_no_groups?report_type=admin') and contains(string(), 'Datasets not added to group')]"
And I should see an element with xpath "//tr[@id='datasets_no_groups']/td[contains(@class, 'metric-data') and position()=2]/a[contains(@href, 'datasets_no_groups?report_type=admin')]"

When I click the link with text that contains "Datasets not added to group/s"
When I press "Datasets not added to group/s"
Then I should see "Admin Report: Datasets not added to group/s: Reporting Organisation"
And I should see "Dataset for reporting"
When I click the link with text that contains "Dataset for reporting"
When I press "Dataset for reporting"
Then I should see "Dataset for reporting"
And I should see "Data and Resources"

Scenario: As an admin user of my organisation, when I view my admin report, I can verify that datasets without tags are identified
Given "ReportingOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='datasets_no_tags']/td[contains(@class, 'metric-title') and position()=1]/a[contains(@href, 'datasets_no_tags?report_type=admin') and contains(string(), 'Datasets with no tags')]"
And I should see an element with xpath "//tr[@id='datasets_no_tags']/td[contains(@class, 'metric-data') and position()=2]/a[contains(@href, 'datasets_no_tags?report_type=admin')]"

When I click the link with text that contains "Datasets with no tags"
When I press "Datasets with no tags"
Then I should see "Admin Report: Datasets with no tags: Reporting Organisation"
And I should see "Dataset for reporting"
When I click the link with text that contains "Dataset for reporting"
When I press "Dataset for reporting"
Then I should see "Dataset for reporting"
And I should see "Data and Resources"

Expand All @@ -76,17 +76,17 @@ Feature: AdminReporting
When I log in
And I create a dataset and resource with key-value parameters "name=de-identified-package-without-schema::title=de-identified-package-without-schema::owner_org=Reporting Organisation::de_identified_data=YES" and "url=default"
And I go to my reports page
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"

Then I should see an element with xpath "//tr[@id='de_identified_datasets_no_schema']/td[contains(@class, 'metric-title') and position()=1]/a[contains(@href, 'de_identified_datasets_no_schema?report_type=admin') and contains(string(), 'De-identified datasets without default data schema (post-')]"
And I should see an element with xpath "//tr[@id='de_identified_datasets_no_schema']/td[contains(@class, 'metric-data') and position()=2]/a[contains(@href, 'de_identified_datasets_no_schema?report_type=admin')]"

When I click the link with text that contains "De-identified datasets without default data schema"
When I press "De-identified datasets without default data schema"
Then I should see "Admin Report: De-identified datasets without data schema validation (post-"
And I should see "Reporting Organisation"
And I should see "de-identified-package-without-schema"
When I click the link with text that contains "de-identified-package-without-schema"
When I press "de-identified-package-without-schema"
Then I should see "de-identified-package-without-schema"
And I should see "Data and Resources"

Expand All @@ -95,16 +95,16 @@ Feature: AdminReporting
When I log in
And I create a dataset and resource with key-value parameters "name=package-with-pending-assessment-resource::schema_json=default::owner_org=Reporting Organisation" and "name=pending-assessment-resource::request_privacy_assessment=YES"
And I visit "dashboard/reporting?report_type=admin&organisation=reporting-org"
And I click the link with text that contains "Admin Report"
And I press "Admin Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"

Then I should see an element with xpath "//tr[@id='pending_privacy_assessment']/td[contains(@class, 'metric-title') and position()=1]/a[contains(@href, 'pending_privacy_assessment?report_type=admin') and contains(string(), 'Pending privacy assessment')]"
And I should see an element with xpath "//tr[@id='pending_privacy_assessment']/td[contains(@class, 'metric-data') and position()=2]/a[contains(@href, 'pending_privacy_assessment?report_type=admin')]"

When I click the link with text that contains "Pending privacy assessment"
When I press "Pending privacy assessment"
Then I should see "Admin Report: Pending privacy assessment"
And I should see "Reporting Organisation"
And I should see "Total number of resources: 1"
And I should see "pending-assessment-resource"
When I click the link with text that contains "pending-assessment-resource"
When I press "pending-assessment-resource"
Then I should see an element with xpath "//th[string()='Request privacy assessment']/following-sibling::td[string()='YES']"
8 changes: 4 additions & 4 deletions test/features/data_qld_theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: Theme customisations
Given "SysAdmin" as the persona
When I log in
And I go to organisation page
And I click the link with text that contains "Add Organisation"
And I press "Add Organisation"
Then I should see "Create an Organisation"
When I execute the script "$('#field-name').val('Org without description')"
And I execute the script "$('#field-url').val('org-without-description')"
Expand All @@ -43,7 +43,7 @@ Feature: Theme customisations
Given "SysAdmin" as the persona
When I log in
And I go to organisation page
And I click the link with text that contains "Add Organisation"
And I press "Add Organisation"
Then I should see "Create an Organisation"
When I execute the script "$('#field-name').val('Org with description')"
And I execute the script "$('#field-url').val('org-with-description')"
Expand All @@ -58,7 +58,7 @@ Feature: Theme customisations
Scenario: Explore button does not exist on dataset detail page
Given "Unauthenticated" as the persona
When I go to dataset page
And I click the link with text that contains "public-test"
And I press "public-test"
Then I should not see "Explore"

@unauthenticated
Expand Down Expand Up @@ -94,7 +94,7 @@ Feature: Theme customisations
When I log in
And I create a dataset and resource with key-value parameters "license=other-open::private=False" and "format=CSV::upload=csv_resource.csv"
And I wait for 10 seconds
And I click the link with text that contains "Test Resource"
And I press "Test Resource"
Then I should see an element with xpath "//a[contains(string(), 'Data API')]"
And I should see an element with xpath "//button[contains(@class, 'dropdown-toggle')]"
And I should see an element with xpath "//a[contains(@class, 'resource-btn') and contains(@href, '/download/csv_resource.csv') and contains(string(), '(CSV)')]"
Expand Down
2 changes: 1 addition & 1 deletion test/features/data_usability_rating.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Data usability rating
And I press the element with xpath "//ol[contains(@class, 'breadcrumb')]//a[starts-with(@href, '/dataset/')]"
And I reload page every 3 seconds until I see an element with xpath "//div[contains(@class, 'qa') and contains(@class, 'openness-')]" but not more than 3 times
Then I should see "Data usability rating"
When I click the link with text that contains "Test Resource"
When I press "Test Resource"
Then I should see an element with xpath "//div[contains(@class, 'qa openness-<Score>')]"

Examples: Formats
Expand Down
4 changes: 2 additions & 2 deletions test/features/data_validation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Feature: Data Validation
And I attach the file "test-resource_schemea.json" to "schema_upload"
And I press "Finish"
And I wait for 1 seconds
And I click the link with text that contains "Test Resource"
And I click the link with text that contains "View Schema File"
And I press "Test Resource"
And I press "View Schema File"
Then I should see "Measure of the oblique fractal impedance at noon"
2 changes: 1 addition & 1 deletion test/features/datarequest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Data Request
Given "SysAdmin" as the persona
When I log in
And I go to the data requests page
And I click the link with text that contains "Add data request"
And I press "Add data request"
And I fill in "title" with "Test data request"
And I press the element with xpath "//button[contains(@class, 'btn-primary')]"
Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds
Expand Down
4 changes: 2 additions & 2 deletions test/features/datasets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Feature: Dataset APIs
And I press the element with xpath "//form[@id='dataset-edit']//button[contains(@class, 'btn-primary')]"
And I press the element with xpath "//a[contains(@href, '/dataset/activity/') and contains(string(), 'Activity Stream')]"
Then I should see "created the dataset"
When I click the link with text that contains "View this version"
When I press "View this version"
Then I should see "You're currently viewing an old version of this dataset."
When I go to dataset "public-test-dataset"
And I press the element with xpath "//a[contains(@href, '/dataset/activity/') and contains(string(), 'Activity Stream')]"
And I click the link with text that contains "Changes"
And I press "Changes"
Then I should see "View changes from"
And I should see an element with xpath "//select[@name='old_id']"
And I should see an element with xpath "//select[@name='new_id']"
16 changes: 8 additions & 8 deletions test/features/engagement_reporting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Feature: Engagement Reporting
Given "<User>" as the persona
When I log in
And I visit "dashboard"
And I click the link with text that contains "My Reports"
And I click the link with text that contains "Engagement Report"
And I press "My Reports"
And I press "Engagement Report"
Then I should see an element with id "organisation"
And I should see an element with id "start_date"
When I fill in "start_date" with "01-01-2019"
Expand All @@ -26,14 +26,14 @@ Feature: Engagement Reporting
Given "DataRequestOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Engagement Report"
And I press "Engagement Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-title') and string()='Data requests' and position()=1]"
And I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='25' and position()=2]"

When I create a datarequest
And I go to my reports page
And I click the link with text that contains "Engagement Report"
And I press "Engagement Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-title') and string()='Data requests' and position()=1]"
And I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='26' and position()=2]"
Expand All @@ -42,7 +42,7 @@ Feature: Engagement Reporting
Given "ReportingOrgAdmin" as the persona
When I log in
And I go to my reports page
And I click the link with text that contains "Engagement Report"
And I press "Engagement Report"
And I press the element with xpath "//button[contains(string(), 'Show')]"
Then I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-title') and string()='Dataset followers' and position()=1]"
And I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-data') and string()='0' and position()=2]"
Expand All @@ -67,7 +67,7 @@ Feature: Engagement Reporting
Then I should see an element with xpath "//i[contains(@class, 'icon-lock')]"

When I go to my reports page
And I click the link with text that contains "Engagement Report"
And I press "Engagement Report"
Then I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-title') and string()='Dataset followers' and position()=1]"
And I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-data') and string()='1' and position()=2]"
And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-title') and string()='Dataset comments' and position()=1]"
Expand All @@ -77,10 +77,10 @@ Feature: Engagement Reporting
And I should see an element with xpath "//tr[contains(@class, 'closing-circumstance')]/td[position()=1]/a[contains(@href, '/closed?') and contains(string(), 'To be released as open data at a later date')]"
And I should see an element with xpath "//tr[contains(@class, 'closing-circumstance')]/td[position()=2]/a[contains(@href, '/closed?') and string()='1']"

When I click the link with text that contains "To be released as open data at a later date"
When I press "To be released as open data at a later date"
Then I should see "Engagement Report: Data requests: Reporting"
And I should see "Closed data requests - To be released as open data at a later date"
And I should see "Reporting Request"
When I click the link with text that contains "Reporting Request"
When I press "Reporting Request"
Then I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(@href, '/datarequest') and contains(string(), 'Data requests')]"
And I should see an element with xpath "//ol[contains(@class, 'breadcrumb')]//a[contains(@href, '/datarequest/') and contains(string(), 'Reporting Request')]"
10 changes: 5 additions & 5 deletions test/features/google_analytics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Feature: GoogleAnalytics
And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']"
And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']"

When I click the link with text that contains "Dave's books"
And I click the link with text that contains "About"
When I press "Dave's books"
And I press "About"
Then I should see an element with xpath "//meta[@name='DCTERMS.title' and contains(@content, 'Dave')]"
And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']"
And I should see an element with xpath "//meta[@name='DCTERMS.creator' and contains(@content, 'c=AU; o=The State of Queensland; ou=Dave') and @scheme='AGLSTERMS.GOLD']"
Expand All @@ -45,8 +45,8 @@ Feature: GoogleAnalytics
And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']"
And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']"

When I click the link with text that contains "Test Organisation"
And I click the link with text that contains "About"
When I press "Test Organisation"
And I press "About"
Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Test Organisation']"
And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']"
And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Test Organisation' and @scheme='AGLSTERMS.GOLD']"
Expand Down Expand Up @@ -82,7 +82,7 @@ Feature: GoogleAnalytics
And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']"
And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']"

When I click the link with text that contains "Test Resource"
When I press "Test Resource"
Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Test Resource']"
And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']"
And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Test Organisation' and @scheme='AGLSTERMS.GOLD']"
Expand Down
Loading

0 comments on commit 9d575d7

Please sign in to comment.