From 948bfc1c773b9071c321204a285b43cc9d2acae1 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 16 Jun 2022 16:17:02 +1000 Subject: [PATCH 01/30] [QOL-8871] update Publications theme to fix homepage link --- vars/shared-Publications.var.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/shared-Publications.var.yml b/vars/shared-Publications.var.yml index d679c878..ee7ebfc1 100644 --- a/vars/shared-Publications.var.yml +++ b/vars/shared-Publications.var.yml @@ -38,7 +38,7 @@ extensions: type: "git" description: "CKAN Extension for Queensland Government Publications theme" url: "https://github.com/qld-gov-au/ckanext-publications-qld-theme.git" - version: "1.1.3" + version: "1.1.4" CKANExtResourceTypeValidation: &CKANExtResourceTypeValidation name: "ckanext-resource-type-validation-{{ Environment }}" From cfc4cb2864131f0d6d057183b55b36ac30441c34 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 16 Jun 2022 16:22:41 +1000 Subject: [PATCH 02/30] [QOL-8871] update Publications tests for gazette link --- test/features/data_qld_theme.feature | 5 +++++ test/features/homepage.feature | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/features/data_qld_theme.feature b/test/features/data_qld_theme.feature index 9866aeed..934a5f43 100644 --- a/test/features/data_qld_theme.feature +++ b/test/features/data_qld_theme.feature @@ -85,6 +85,11 @@ Feature: Theme customisations Then I should see an element with xpath "//a[contains(@href, '/datastore/dump/') and contains(@href, 'format=json') and contains(string(), 'JSON')]" Then I should see an element with xpath "//a[contains(@href, '/datastore/dump/') and contains(@href, 'format=xml') and contains(string(), 'XML')]" + @Publications + Scenario: Homepage 'Publish in the Gazettes' link is correct + When I go to homepage + Then I should see an element with xpath "//a[@href='https://www.forgov.qld.gov.au/information-and-communication-technology/communication-and-publishing/website-and-digital-publishing/queensland-government-gazette/publish-in-the-gazette' and string()='Publish in the Gazettes']" + @Publications Scenario: Menu items are present and correct When I go to "/dataset" diff --git a/test/features/homepage.feature b/test/features/homepage.feature index e5f7b1d0..ff4bbcc1 100644 --- a/test/features/homepage.feature +++ b/test/features/homepage.feature @@ -6,7 +6,6 @@ Feature: Homepage Scenario: Smoke test to ensure Homepage is accessible Given "Unauthenticated" as the persona When I go to homepage - Then I take a screenshot 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.jurisdiction' and @content='Queensland' and @scheme='AGLSTERMS.AglsJuri']" And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']" From c9a23c27c9a74930aee30119afd1f97f2a62e0c2 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 17 Jun 2022 14:39:19 +1000 Subject: [PATCH 03/30] [DC-31541] update Data Qld extension - fix report links for individual datasets - fix reporting on data requests closed as 'to be released at a later date' - fix 'nature_of_change' handling so background jobs don't erase it --- vars/shared-CKANTest.var.yml | 2 +- vars/shared-OpenData.var.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/shared-CKANTest.var.yml b/vars/shared-CKANTest.var.yml index 3ea59954..28d7d548 100644 --- a/vars/shared-CKANTest.var.yml +++ b/vars/shared-CKANTest.var.yml @@ -71,7 +71,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckanext-data-qld.git" - version: "6.3.2" + version: "6.3.3" CKANExtODICertificates: &CKANExtODICertificates name: "ckanext-odi-certificates-{{ Environment }}" diff --git a/vars/shared-OpenData.var.yml b/vars/shared-OpenData.var.yml index 30fcf046..a5afcc4c 100644 --- a/vars/shared-OpenData.var.yml +++ b/vars/shared-OpenData.var.yml @@ -71,7 +71,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckanext-data-qld.git" - version: "6.3.2" + version: "6.3.3" CKANExtODICertificates: &CKANExtODICertificates name: "ckanext-odi-certificates-{{ Environment }}" From 3b638147791225e2d1015a9eede313b6fde0e496 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 17 Jun 2022 14:51:42 +1000 Subject: [PATCH 04/30] [DC-31541] update CSRF filter - fix handling of multiple leading slashes in API URLs - fix encoding of slashes in usernames --- vars/shared-CKANTest.var.yml | 2 +- vars/shared-OpenData.var.yml | 2 +- vars/shared-Publications.var.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vars/shared-CKANTest.var.yml b/vars/shared-CKANTest.var.yml index 28d7d548..1a175081 100644 --- a/vars/shared-CKANTest.var.yml +++ b/vars/shared-CKANTest.var.yml @@ -151,7 +151,7 @@ extensions: description: "CKAN Extension for preventing Cross-Site Request Forgery attacks" type: "git" url: "https://github.com/qld-gov-au/ckanext-csrf-filter.git" - version: "1.1.3" + version: "1.1.4" PROD: <<: *default_extensions diff --git a/vars/shared-OpenData.var.yml b/vars/shared-OpenData.var.yml index a5afcc4c..e3337ced 100644 --- a/vars/shared-OpenData.var.yml +++ b/vars/shared-OpenData.var.yml @@ -152,7 +152,7 @@ extensions: description: "CKAN Extension for preventing Cross-Site Request Forgery attacks" type: "git" url: "https://github.com/qld-gov-au/ckanext-csrf-filter.git" - version: "1.1.3" + version: "1.1.4" PROD: <<: *default_extensions diff --git a/vars/shared-Publications.var.yml b/vars/shared-Publications.var.yml index ee7ebfc1..bed8c9dc 100644 --- a/vars/shared-Publications.var.yml +++ b/vars/shared-Publications.var.yml @@ -54,7 +54,7 @@ extensions: description: "CKAN Extension for preventing Cross-Site Request Forgery attacks" type: "git" url: "https://github.com/qld-gov-au/ckanext-csrf-filter.git" - version: "1.1.3" + version: "1.1.4" PROD: <<: *default_extensions From 064eb22928a4fce287fe458eb2bdbafc99b3eef2 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 23 Jun 2022 15:37:46 +1000 Subject: [PATCH 05/30] [DC-31965][QOL-8988][QOL-8978] update ckanext-data-qld and ckanext-qgov - Fix PURL integration under CKAN 2.9 - Restore custom 'robots.txt' - Add help text for 'Excluded display name words' - Fix activity stream browsing --- .github/workflows/test.yml | 2 -- vars/shared-CKANTest.var.yml | 4 ++-- vars/shared-OpenData.var.yml | 4 ++-- vars/shared-Publications.var.yml | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f7b8143..ed40b786 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,4 @@ --- -#based on https://raw.githubusercontent.com/ckan/ckanext-scheming/master/.github/workflows/test.yml -# alternative https://github.com/ckan/ckan/blob/master/contrib/cookiecutter/ckan_extension/%7B%7Bcookiecutter.project%7D%7D/.github/workflows/test.yml name: Tests on: push: diff --git a/vars/shared-CKANTest.var.yml b/vars/shared-CKANTest.var.yml index 1a175081..e94768ec 100644 --- a/vars/shared-CKANTest.var.yml +++ b/vars/shared-CKANTest.var.yml @@ -23,7 +23,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckan-ex-qgov.git" - version: "5.0.0" + version: "5.0.2" CKANExtS3Filestore: &CKANExtS3Filestore name: "ckanext-s3filestore-{{ Environment }}" @@ -71,7 +71,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckanext-data-qld.git" - version: "6.3.3" + version: "6.3.4" CKANExtODICertificates: &CKANExtODICertificates name: "ckanext-odi-certificates-{{ Environment }}" diff --git a/vars/shared-OpenData.var.yml b/vars/shared-OpenData.var.yml index e3337ced..f4f2683e 100644 --- a/vars/shared-OpenData.var.yml +++ b/vars/shared-OpenData.var.yml @@ -23,7 +23,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckan-ex-qgov.git" - version: "5.0.0" + version: "5.0.2" CKANExtS3Filestore: &CKANExtS3Filestore name: "ckanext-s3filestore-{{ Environment }}" @@ -71,7 +71,7 @@ extensions: description: "CKAN Extension for Queensland Government Open Data" type: "git" url: "https://github.com/qld-gov-au/ckanext-data-qld.git" - version: "6.3.3" + version: "6.3.4" CKANExtODICertificates: &CKANExtODICertificates name: "ckanext-odi-certificates-{{ Environment }}" diff --git a/vars/shared-Publications.var.yml b/vars/shared-Publications.var.yml index bed8c9dc..82be9ca8 100644 --- a/vars/shared-Publications.var.yml +++ b/vars/shared-Publications.var.yml @@ -14,7 +14,7 @@ extensions: description: "CKAN Extension for Queensland Government sites" type: "git" url: "https://github.com/qld-gov-au/ckan-ex-qgov.git" - version: "5.0.0" + version: "5.0.2" CKANExtS3Filestore: &CKANExtS3Filestore name: "ckanext-s3filestore-{{ Environment }}" From bc02495f2165c44a2c9e4f49f443885a7b545a34 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 23 Jun 2022 15:55:14 +1000 Subject: [PATCH 06/30] [DC-31965][QOL-8988][QOL-8978] sync scenario tests - Copy tests from ckanext-data-qld and ckanext-publications-qld-theme for recent changes, eg restoring robots.txt, fixing reports, adding help text, fixing activity stream --- .docker/scripts/create-test-data-OpenData.sh | 10 ++- .../scripts/create-test-data-Publications.sh | 8 ++- test/features/admin_reporting.feature | 40 +++++++++-- test/features/config.feature | 1 + test/features/data_qld_theme.feature | 7 ++ test/features/data_request.feature | 2 +- test/features/datasets.feature | 17 +++++ test/features/engagement_reporting.feature | 70 ++++++++++--------- test/features/homepage.feature | 6 ++ test/features/login.feature | 1 - test/features/resource_freshness.feature | 8 ++- test/features/steps/steps.py | 16 +++++ test/features/users.feature | 2 +- 13 files changed, 145 insertions(+), 43 deletions(-) diff --git a/.docker/scripts/create-test-data-OpenData.sh b/.docker/scripts/create-test-data-OpenData.sh index 0d0adc10..cb2e186e 100644 --- a/.docker/scripts/create-test-data-OpenData.sh +++ b/.docker/scripts/create-test-data-OpenData.sh @@ -9,7 +9,7 @@ if [ "$VENV_DIR" != "" ]; then . ${VENV_DIR}/bin/activate fi -# Create test dataset with our standard fields +# Create private test dataset with our standard fields curl -LsH "Authorization: ${API_KEY}" \ --data '{"name": "test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", "private": true, "update_frequency": "monthly", "author_email": "admin@localhost", "version": "1.0", @@ -17,6 +17,14 @@ curl -LsH "Authorization: ${API_KEY}" \ "notes": "test", "de_identified_data": "NO"}' \ ${CKAN_ACTION_URL}/package_create +# Create public test dataset with our standard fields +curl -LsH "Authorization: ${API_KEY}" \ + --data '{"name": "public-test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", +"update_frequency": "monthly", "author_email": "admin@example.com", "version": "1.0", +"license_id": "other-open", "data_driven_application": "NO", "security_classification": "PUBLIC", +"notes": "test", "de_identified_data": "NO"}' \ + ${CKAN_ACTION_URL}/package_create + if [ "$VENV_DIR" != "" ]; then deactivate fi diff --git a/.docker/scripts/create-test-data-Publications.sh b/.docker/scripts/create-test-data-Publications.sh index 729b7d6f..ea0dcaa0 100644 --- a/.docker/scripts/create-test-data-Publications.sh +++ b/.docker/scripts/create-test-data-Publications.sh @@ -14,11 +14,17 @@ curl -LsH "Authorization: ${API_KEY}" \ --data '{"name": "publishing-standards-publications-qld-gov-au", "owner_org": "'"${TEST_ORG_ID}"'"}' \ ${CKAN_ACTION_URL}/package_create -# Create test dataset with our standard fields +# Create private test dataset with our standard fields curl -LsH "Authorization: ${API_KEY}" \ --data '{"name": "test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", "private": true}' \ ${CKAN_ACTION_URL}/package_create +# Create public test dataset with our standard fields +curl -LsH "Authorization: ${API_KEY}" \ + --data '{"name": "public-test-dataset", "owner_org": "'"${TEST_ORG_ID}"'"}' \ + ${CKAN_ACTION_URL}/package_create + + if [ "$VENV_DIR" != "" ]; then deactivate fi diff --git a/test/features/admin_reporting.feature b/test/features/admin_reporting.feature index 35260603..7cfe05d1 100644 --- a/test/features/admin_reporting.feature +++ b/test/features/admin_reporting.feature @@ -11,9 +11,9 @@ Feature: AdminReporting 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 - Then I should see an element with xpath "//tr/th[string()='Criteria' and position()=1]" - Then I should see an element with xpath "//tr/th[string()='Figure' and position()=2]" - + And I should see an element with xpath "//tr/th[string()='Criteria' and position()=1]" + And I should see an element with xpath "//tr/th[string()='Figure' and position()=2]" + And I should be able to download via the element with xpath "//a[contains(string(), 'Export')]" Scenario: As an editor user of my organisation, I can view 'My Reports' tab in the dashboard but I cannot view the 'Admin Report' link Given "TestOrgEditor" as the persona @@ -39,4 +39,36 @@ Feature: AdminReporting And I click the link with text that contains "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]" - Then I should see an element with xpath "//tr[@id='overdue-datasets']/td[contains(@class, 'metric-data') and position()=2]" + And I should see an element with xpath "//tr[@id='overdue-datasets']/td[contains(@class, 'metric-data') and position()=2]" + + Scenario: As an admin user of my organisation, when I view my admin report, I can verify that datasets without groups are identified + Given "Organisation Admin" 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 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" + Then I should see "Admin Report: Datasets not added to group/s: Department of Health" + And I should see "Department of Health Spend Data" + When I click the link with text that contains "Department of Health Spend Data" + Then I should see "Department of Health Spend Data" + 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 "Organisation Admin" 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 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" + Then I should see "Admin Report: Datasets with no tags: Department of Health" + And I should see "Department of Health Spend Data" + When I click the link with text that contains "Department of Health Spend Data" + Then I should see "Department of Health Spend Data" + And I should see "Data and Resources" diff --git a/test/features/config.feature b/test/features/config.feature index be743645..af7a3775 100644 --- a/test/features/config.feature +++ b/test/features/config.feature @@ -5,6 +5,7 @@ Feature: Config Given "SysAdmin" as the persona When I log in and go to admin config page Then I should see "Intro Text" + And I should see "Excluded display name words:" And I should see an element with id "field-ckanext.data_qld.excluded_display_name_words" And I should not see an element with id "field-ckan-main-css" And I should not see an element with id "field-ckan-site-custom-css" diff --git a/test/features/data_qld_theme.feature b/test/features/data_qld_theme.feature index 934a5f43..e88077cb 100644 --- a/test/features/data_qld_theme.feature +++ b/test/features/data_qld_theme.feature @@ -137,3 +137,10 @@ Feature: Theme customisations Then I should see an element with xpath "//a[@href='/user/login' and contains(string(), 'Log in')]" And I should see an element with xpath "//a[@href='/user/register' and contains(string(), 'Register')]" And I should not see "not found" + + @unauthenticated + Scenario: When I go to the robots file, I can see a custom disallow block + Given "Unauthenticated" as the persona + When I go to "/robots.txt" + Then I should see "Disallow: /" + And I should not see "Allow:" diff --git a/test/features/data_request.feature b/test/features/data_request.feature index 7c63cca2..1e51c7f1 100644 --- a/test/features/data_request.feature +++ b/test/features/data_request.feature @@ -1,5 +1,5 @@ -@config @OpenData +@datarequest Feature: Data Request @unauthenticated diff --git a/test/features/datasets.feature b/test/features/datasets.feature index 0f4913cf..3461bf8c 100644 --- a/test/features/datasets.feature +++ b/test/features/datasets.feature @@ -6,6 +6,23 @@ Feature: Dataset APIs And I edit the "warandpeace" dataset Then I should see an element with xpath "//option[@value='cc-by-nc-sa-4']" + Scenario: As a publisher, I can view the change history of a dataset + Given "TestOrgEditor" as the persona + When I log in + And I edit the "public-test-dataset" dataset + And I fill in "author_email" with "admin@example.com" + And I press the element with xpath "//form[contains(@class, 'dataset-form')]//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" + 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" + 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']" + @Publications Scenario: As a user with publishing privileges, I can create a dataset Given "TestOrgEditor" as the persona diff --git a/test/features/engagement_reporting.feature b/test/features/engagement_reporting.feature index 0feec07e..b90bf503 100644 --- a/test/features/engagement_reporting.feature +++ b/test/features/engagement_reporting.feature @@ -30,6 +30,7 @@ Feature: Engagement Reporting 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]" Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='3' 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" @@ -37,47 +38,52 @@ Feature: Engagement Reporting Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-title') and string()='Data requests' and position()=1]" Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='4' and position()=2]" - Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the number of dataset followers is correct and increments + Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the numbers are correct and increment 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 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]" - Then I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" - When I go to dataset "reporting" + And I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-data') and string()='0' 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]" + And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" + And I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-title') and string()='Data request comments' and position()=1]" + And I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" + 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()='0']" + + Then I go to dataset "reporting" And I press the element with xpath "//a[@class='btn btn-success' and contains(string(), 'Follow')]" - And I go to my reports page - And I click the link with text that contains "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]" - Then I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" - Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the number of dataset comments is correct and increments - 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 the element with xpath "//button[contains(string(), 'Show')]" - Then I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-title') and string()='Dataset comments' and position()=1]" - Then I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" - When I go to dataset "reporting" comments + And I go to dataset "reporting" comments And I submit a comment with subject "Test subject" and comment "This is a test comment" - And I go to my reports page - And I click the link with text that contains "Engagement Report" - Then I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-title') and string()='Dataset comments' and position()=1]" - Then I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" - Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the number of data request comments is correct and increments - 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 the element with xpath "//button[contains(string(), 'Show')]" - Then I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-title') and string()='Data request comments' and position()=1]" - Then I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" - When I go to data request "Reporting Request" comments + And I go to data request "Reporting Request" comments And I submit a comment with subject "Test subject" and comment "This is a test comment" - And I go to my reports page + + And I go to data request "Reporting Request" + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "To be released as open data at a later date" from "close_circumstance" + And I fill in "approx_publishing_date" with "01/01/1970" + And I press the element with xpath "//button[contains(string(), 'Close data request')]" + And 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" - Then I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-title') and string()='Data request comments' and position()=1]" - Then I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" + 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]" + And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" + And I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-title') and string()='Data request comments' and position()=1]" + And I should see an element with xpath "//tr[@id='datarequest-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" + 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" + 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" + 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')]" diff --git a/test/features/homepage.feature b/test/features/homepage.feature index ff4bbcc1..35a7af08 100644 --- a/test/features/homepage.feature +++ b/test/features/homepage.feature @@ -9,3 +9,9 @@ Feature: Homepage 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.jurisdiction' and @content='Queensland' and @scheme='AGLSTERMS.AglsJuri']" And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']" + + @Publications + Scenario: 'Publish in the Gazettes' link is visible + Given "Unauthenticated" as the persona + When I go to homepage + Then I should see an element with xpath "//a[@href='https://www.forgov.qld.gov.au/information-and-communication-technology/communication-and-publishing/website-and-digital-publishing/queensland-government-gazette/publish-in-the-gazette' and string()='Publish in the Gazettes']" diff --git a/test/features/login.feature b/test/features/login.feature index 3256f2d5..9c77d30c 100644 --- a/test/features/login.feature +++ b/test/features/login.feature @@ -4,7 +4,6 @@ Feature: Login Scenario: Smoke test to ensure Login step works Given "SysAdmin" as the persona When I log in - Then I take a screenshot 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.jurisdiction' and @content='Queensland' and @scheme='AGLSTERMS.AglsJuri']" And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']" diff --git a/test/features/resource_freshness.feature b/test/features/resource_freshness.feature index c0aae691..f9451662 100644 --- a/test/features/resource_freshness.feature +++ b/test/features/resource_freshness.feature @@ -27,12 +27,16 @@ Feature: Resource freshness | TestOrgAdmin | | TestOrgEditor | - Scenario Outline: An editor, admin or sysadmin user, when I go to the edit dataset page, the text 'Next update due' should be visible + Scenario Outline: As a user with editing privileges, when I set a 'monthly' update frequently, I should still be able to update the dataset via the API Given "" as the persona When I log in - And I go to "/dataset/edit/warandpeace" + And I go to "/dataset/edit/test-dataset" And I select "monthly" from "update_frequency" Then I should see "Next update due" + When I fill in "next_update_due" with "01/01/1970" + And I press the element with xpath "//form[contains(@class, 'dataset-form')]//button[contains(@class, 'btn-primary')]" + And I wait for 3 seconds + Then I should be able to patch dataset "test-dataset" via the API Examples: Users | User | diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 23014437..55e50af5 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -5,6 +5,7 @@ from behaving.web.steps.url import when_i_visit_url import email import quopri +import requests import uuid @@ -169,6 +170,21 @@ def go_to_organisation_including_users(context, organisation_id, including): when_i_visit_url(context, r'/api/3/action/organization_show?id={}&include_users={}'.format(organisation_id, including in ['with', 'including'])) +@step(u'I should be able to download via the element with xpath "{expression}"') +def test_download_element(context, expression): + url = context.browser.find_by_xpath(expression).first['href'] + assert requests.get(url, cookies=context.browser.cookies.all()).status_code == 200 + + +@step(u'I should be able to patch dataset "{package_id}" via the API') +def test_package_patch(context, package_id): + url = context.base_url + 'api/action/package_patch' + response = requests.post(url, json={'id': package_id}, cookies=context.browser.cookies.all()) + print("Response from endpoint {} is: {}, {}".format(url, response, response.text)) + assert response.status_code == 200 + assert '"success": true' in response.text + + @step(u'I create a dataset with title "{title}"') def create_dataset_titled(context, title): context.execute_steps(u""" diff --git a/test/features/users.feature b/test/features/users.feature index 093410b3..dfe44d3c 100644 --- a/test/features/users.feature +++ b/test/features/users.feature @@ -79,7 +79,7 @@ Feature: User APIs Scenario: User detail is not accessible anonymously Given "Unauthenticated" as the persona When I go to the "editor" user API - Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'requires an authenticated user')]" + Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'Authorization Error')]" Scenario Outline: User profile page is accessible to admins Given "" as the persona From a54cd10fdac570c55f390ba44c602c9b7c76d427 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 24 Jun 2022 15:09:52 +1000 Subject: [PATCH 07/30] [DC-31965] update CKAN fork to patch activity stream bugs --- vars/CKAN-Stack.var.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/CKAN-Stack.var.yml b/vars/CKAN-Stack.var.yml index 4b6db2de..28e12d45 100644 --- a/vars/CKAN-Stack.var.yml +++ b/vars/CKAN-Stack.var.yml @@ -5,7 +5,7 @@ NonProductionAnalyticsId: "{{ lookup('aws_ssm', '/config/CKAN/GaIdNonProduction' ProductionAnalyticsId: "{{ lookup('aws_ssm', '/config/CKAN/GaIdProduction', region=region) }}" solr7: "http://archive.apache.org/dist/lucene/solr/7.7.2/solr-7.7.2.zip" -ckan_tag: "ckan-2.9.5-qgov.4" +ckan_tag: "ckan-2.9.5-qgov.6" ckan_qgov_branch: "qgov-master-2.9.5" common_stack: &common_stack From e34738a4a553c4ed18ef260e878dced587bdff7a Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 14:45:43 +1000 Subject: [PATCH 08/30] [QOL-8978] fix test initialisation of sysadmin config - populate test config in init scripts instead of Behave steps - ensure comment blacklist is an empty string so it doesn't get confused --- .docker/scripts/create-test-data.sh | 8 +++++++- test/features/config.feature | 2 +- test/features/user_creation.feature | 8 -------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.docker/scripts/create-test-data.sh b/.docker/scripts/create-test-data.sh index 22aba133..bb27f886 100644 --- a/.docker/scripts/create-test-data.sh +++ b/.docker/scripts/create-test-data.sh @@ -258,7 +258,7 @@ curl -LsH "Authorization: ${API_KEY}" \ echo "Adding ckan.datarequests.closing_circumstances:" curl -LsH "Authorization: ${API_KEY}" \ - --data '{"ckan.datarequests.closing_circumstances": + --data '{"ckan.comments.profanity_list": "", "ckan.datarequests.closing_circumstances": "Released as open data|nominate_dataset\r\nOpen dataset already exists|nominate_dataset\r\nPartially released|nominate_dataset\r\nTo be released as open data at a later date|nominate_approximate_date\r\nData openly available elsewhere\r\nNot suitable for release as open data\r\nRequested data not available/cannot be compiled\r\nRequestor initiated closure"}' \ ${CKAN_ACTION_URL}/config_option_update @@ -268,6 +268,12 @@ curl -LsH "Authorization: ${API_KEY}" \ --data '{"ckanext.data_qld.resource_formats": "CSV\r\nHTML\r\nJSON\r\nRDF\r\nTXT\r\nXLS"}' \ ${CKAN_ACTION_URL}/config_option_update +echo "Creating config value for excluded display name words:" + +curl -LsH "Authorization: ${API_KEY}" \ + --data '{"ckanext.data_qld.excluded_display_name_words": "gov"}' \ + ${CKAN_ACTION_URL}/config_option_update + if [ "$VENV_DIR" != "" ]; then deactivate fi diff --git a/test/features/config.feature b/test/features/config.feature index af7a3775..8ad14383 100644 --- a/test/features/config.feature +++ b/test/features/config.feature @@ -6,7 +6,7 @@ Feature: Config When I log in and go to admin config page Then I should see "Intro Text" And I should see "Excluded display name words:" - And I should see an element with id "field-ckanext.data_qld.excluded_display_name_words" + And I should see an element with xpath "//textarea[@id='field-ckanext.data_qld.excluded_display_name_words' and contains(string(), 'gov')]" And I should not see an element with id "field-ckan-main-css" And I should not see an element with id "field-ckan-site-custom-css" diff --git a/test/features/user_creation.feature b/test/features/user_creation.feature index e29db5b8..eda029ab 100644 --- a/test/features/user_creation.feature +++ b/test/features/user_creation.feature @@ -1,14 +1,6 @@ @user_creation Feature: User creation - Scenario: SysAdmin can create 'Excluded display name words' in ckan admin config - Given "SysAdmin" as the persona - When I log in - Then I go to "/ckan-admin/config" - Then I should see "Excluded display name words" - Then I fill in "ckanext.data_qld.excluded_display_name_words" with "gov" - And I press the element with xpath "//button[contains(@class, 'btn-primary')]" - Scenario: SysAdmin create a new user to the site. Given "SysAdmin" as the persona When I log in From 670395601053372a9d78f254a9ec55710f5650d5 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 14:46:45 +1000 Subject: [PATCH 09/30] [QOL-8978] fix test template overrides - put ckanext-qgov before datarequests and comments so its admin config takes priority --- .docker/test-OpenData.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/test-OpenData.ini b/.docker/test-OpenData.ini index 2b8575ce..11289616 100644 --- a/.docker/test-OpenData.ini +++ b/.docker/test-OpenData.ini @@ -97,7 +97,7 @@ ckan.redis.url = redis://redis:6379 # Add ``datapusher`` to enable DataPusher # Add ``resource_proxy`` to enable resource proxying and get around the # same origin policy -ckan.plugins = stats text_view image_view recline_view datastore data_qld datarequests scheming_datasets validation dcat qa archiver report data_qld_reporting data_qld_google_analytics ytp_comments harvester_data_qld_geoscience harvest qgovext xloader csrf_filter resource_type_validation +ckan.plugins = stats text_view image_view recline_view datastore data_qld scheming_datasets validation dcat qa archiver report data_qld_reporting data_qld_google_analytics harvester_data_qld_geoscience harvest qgovext ytp_comments datarequests xloader csrf_filter resource_type_validation # Define which views should be created by default # (plugins must be loaded in ckan.plugins) From e44e92627ecaf3db24ab4f10d301822e213b66cd Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 14:47:25 +1000 Subject: [PATCH 10/30] [QOL-8978] increase debugging for local testing --- .ahoy.yml | 11 ++++++++++- .docker/scripts/ckan_cli | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.ahoy.yml b/.ahoy.yml index 6e652a0a..6c8092eb 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -115,6 +115,13 @@ commands: ahoy cli "flake8 ${@:-roles}" || \ [ "${ALLOW_LINT_FAIL:-0}" -eq 1 ] + copy-local-files: + usage: Update files from local repo. + cmd: | + docker cp . $(docker-compose ps -q ckan):/app/ + docker cp .docker/scripts/ckan_cli $(docker-compose ps -q ckan):/app/ckan/default/bin/ + ahoy cli 'chmod u+x $VENV_DIR/bin/ckan_cli; cp .docker/test-$VARS_TYPE.ini $CKAN_INI' + test-unit: usage: Run unit tests. cmd: | @@ -128,7 +135,9 @@ commands: ahoy start-mailmock & sleep 5 && # Run generic tests - ahoy cli "behave -k --tags ~OpenData --tags ~Publications ${*:-test/features}" || \ + BEHAVE_COMMAND="behave -k --tags=-OpenData,-Publications ${*:-test/features}" + echo "Args: ${*:-test/features}, command: $BEHAVE_COMMAND" + ahoy cli "$BEHAVE_COMMAND" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] # Run app-specific tests ahoy cli "behave -k --tags $VARS_TYPE ${*:-test/features}" || \ diff --git a/.docker/scripts/ckan_cli b/.docker/scripts/ckan_cli index 3cf0b4cc..7757dc8b 100644 --- a/.docker/scripts/ckan_cli +++ b/.docker/scripts/ckan_cli @@ -57,15 +57,15 @@ else fi if [ "$COMMAND" = "ckan" ]; then - echo "Using 'ckan' command from $ENV_DIR with config ${CKAN_INI}..." >&2 # adjust args to match ckan expectations COMMAND=$(echo "$1" | sed -e 's/create-test-data/seed/') + echo "Using 'ckan' command from $ENV_DIR with config ${CKAN_INI} to run $COMMAND..." >&2 shift exec $ENV_DIR/ckan -c ${CKAN_INI} $COMMAND "$@" $CLICK_ARGS elif [ "$COMMAND" = "paster" ]; then - echo "Using 'paster' command from $ENV_DIR with config ${CKAN_INI}..." >&2 # adjust args to match paster expectations COMMAND=$1 + echo "Using 'paster' command from $ENV_DIR with config ${CKAN_INI} to run $COMMAND..." >&2 shift if [ "$1" = "show" ]; then shift; fi exec $ENV_DIR/paster --plugin=$PASTER_PLUGIN $COMMAND "$@" -c ${CKAN_INI} From 96fe0ea986929646e8e0d876002f0951ea339597 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 15:16:18 +1000 Subject: [PATCH 11/30] [QOL-8978] fix Behave tag syntax to run correct tests - Smoke tests should be 'not OpenData AND not Publications' --- .ahoy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ahoy.yml b/.ahoy.yml index 6c8092eb..f3d92f40 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -135,7 +135,7 @@ commands: ahoy start-mailmock & sleep 5 && # Run generic tests - BEHAVE_COMMAND="behave -k --tags=-OpenData,-Publications ${*:-test/features}" + BEHAVE_COMMAND="behave -k --tags=-OpenData --tags=-Publications ${*:-test/features}" echo "Args: ${*:-test/features}, command: $BEHAVE_COMMAND" ahoy cli "$BEHAVE_COMMAND" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] From 0215aa44e702c30456f865c9491377fa904d0eb5 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 16:11:33 +1000 Subject: [PATCH 12/30] [QOL-8952] update Data Requests to fix dropdown - load the latest 500 datasets from the associated organisation, not just 10 --- vars/shared-CKANTest.var.yml | 2 +- vars/shared-OpenData.var.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/shared-CKANTest.var.yml b/vars/shared-CKANTest.var.yml index 1a175081..593775c2 100644 --- a/vars/shared-CKANTest.var.yml +++ b/vars/shared-CKANTest.var.yml @@ -87,7 +87,7 @@ extensions: description: "CKAN Extension for Data Requests" type: "git" url: "https://github.com/qld-gov-au/ckanext-datarequests.git" - version: "2.2.0-qgov" + version: "2.2.1-qgov" CKANExtYTP: &CKANExtYTP name: "ckanext-ytp-comments-{{ Environment }}" diff --git a/vars/shared-OpenData.var.yml b/vars/shared-OpenData.var.yml index e3337ced..46a4daa2 100644 --- a/vars/shared-OpenData.var.yml +++ b/vars/shared-OpenData.var.yml @@ -87,7 +87,7 @@ extensions: description: "CKAN Extension for Data Requests" type: "git" url: "https://github.com/qld-gov-au/ckanext-datarequests.git" - version: "2.2.0-qgov" + version: "2.2.1-qgov" CKANExtYTP: &CKANExtYTP name: "ckanext-ytp-comments-{{ Environment }}" From 00917c1de05dd269107624a100b10ffd7f05b75b Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 30 Jun 2022 16:20:03 +1000 Subject: [PATCH 13/30] [QOL-8952] sync tests with ckanext-datarequests --- test/features/comments.feature | 4 +- test/features/datarequest.feature | 68 +++++++ .../datarequest_circumstances.feature | 171 ++++++++++++++++++ test/features/login.feature | 1 - test/features/steps/steps.py | 26 +-- 5 files changed, 256 insertions(+), 14 deletions(-) create mode 100644 test/features/datarequest.feature create mode 100644 test/features/datarequest_circumstances.feature diff --git a/test/features/comments.feature b/test/features/comments.feature index b4fbea6d..3c399668 100644 --- a/test/features/comments.feature +++ b/test/features/comments.feature @@ -91,7 +91,7 @@ Feature: Comments Then I should see "This is a reply" within 10 seconds @comment-delete - Scenario: When an Org Admin visits a dataset belonging to their organisation, they can delete a comment and should see deletion text for the user responsible. + Scenario: When an admin visits a dataset belonging to their organisation, they can delete a comment and should see deletion text for the user responsible. Given "TestOrgAdmin" as the persona When I log in Then I go to dataset "warandpeace" comments @@ -102,7 +102,7 @@ Feature: Comments And I should see "Comment deleted by Test Admin." within 2 seconds @comment-delete @datarequest - Scenario: When an Org Admin visits a data request belonging to their organisation, they can delete a comment and should see deletion text for the user responsible. + Scenario: When an admin visits a data request belonging to their organisation, they can delete a comment and should see deletion text for the user responsible. Given "TestOrgAdmin" as the persona When I log in And I go to data request "Test Request" comments diff --git a/test/features/datarequest.feature b/test/features/datarequest.feature new file mode 100644 index 00000000..d9da84c2 --- /dev/null +++ b/test/features/datarequest.feature @@ -0,0 +1,68 @@ +@data-requests +@OpenData +Feature: Datarequest + + Scenario: Data Requests are accessible via the /datarequest URL + When I go to datarequest page + Then the browser's URL should contain "/datarequest" + + + Scenario: When visiting the datarequests page as a non-logged in user, the 'Add Data Request' button is not visible + When I go to datarequest page + Then I should not see an element with xpath "//a[contains(string(), 'Add data request', 'i')]" + + + Scenario: Data requests submitted without a description will produce an error message + Given "SysAdmin" as the persona + When I log in and go to datarequest page + And I click the link with text that contains "Add Data Request" + And I fill in "title" with "Test data request" + And I press the element with xpath "//button[contains(string(), 'Create Data Request')]" + Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds + And I should see "The form contains invalid entries" within 1 seconds + And I should see an element with the css selector "span.error-block" within 1 seconds + And I should see "Description cannot be empty" within 1 seconds + + + Scenario Outline: Data request creator and Sysadmin can see a 'Close' button on the data request detail page for opened data requests + Given "" as the persona + When I log in and go to datarequest page + And I press "Test Request" + Then I should see an element with xpath "//a[contains(string(), 'Close')]" + + Examples: Users + | User | + | SysAdmin | + + + Scenario Outline: Non admin users cannot see a 'Close' button on the data request detail page for opened data requests + Given "" as the persona + When I log in and go to datarequest page + And I press "Test Request" + Then I should not see an element with xpath "//a[contains(string(), 'Close')]" + + Examples: Users + | User | + | CKANUser | + | DataRequestOrgEditor | + | DataRequestOrgMember | + | TestOrgAdmin | + | TestOrgEditor | + | TestOrgMember | + + + Scenario: Creating a new data request will show the data request afterward + Given "TestOrgEditor" as the persona + When I log in and create a datarequest + Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" + And I should see an element with xpath "//a[contains(string(), 'Close')]" + + + Scenario: Closing a data request will show the data request afterward + Given "DataRequestOrgAdmin" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Requestor initiated closure" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see an element with xpath "//i[contains(@class, 'icon-lock')]" + And I should not see an element with xpath "//a[contains(string(), 'Close')]" diff --git a/test/features/datarequest_circumstances.feature b/test/features/datarequest_circumstances.feature new file mode 100644 index 00000000..29f02e15 --- /dev/null +++ b/test/features/datarequest_circumstances.feature @@ -0,0 +1,171 @@ +@data-requests-circumstances +@OpenData +Feature: Datarequest-circumstances + + Scenario: As a sysadmin user when I go to the admin config page I can view the data requests closing circumstances textarea + Given "SysAdmin" as the persona + When I log in and go to admin config page + Then the browser's URL should contain "/ckan-admin/config" + And I should see "Data request closing circumstances" + + + Scenario Outline: Data request creator, Sysadmin and Admin users can see the drop-down field circumstances + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + Then the element with the css selector "#field-close_circumstance" should be visible within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I select closing circumstance 'Open dataset already exists', accepted dataset is required + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Open dataset already exists" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds + And I should see "The form contains invalid entries" within 1 seconds + And I should see "Accepted dataset cannot be empty" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I select closing circumstance 'To be released as open data at a later date', Approximate publishing date is required + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "To be released as open data at a later date" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds + And I should see "The form contains invalid entries" within 1 seconds + And I should see "Approximate publishing date cannot be empty" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: Data request creator, Sysadmin and Admin users, when I select closing circumstance 'Requestor initiated closure', accepted dataset or Approximate publishing date is not required + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Requestor initiated closure" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see an element with xpath "//span[contains(@class,'label-closed') and contains(string(), 'Closed')]" within 2 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I select closing circumstance 'Open dataset already exists', the Approximate publishing date element is not visible + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Open dataset already exists" from "close_circumstance" + Then the element with the css selector "#field-approx_publishing_date" should not be visible within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I select closing circumstance 'To be released as open data at a later date', the accepted dataset element is not visible + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "To be released as open data at a later date" from "close_circumstance" + Then the element with the css selector "#field-accepted_dataset_id" should not be visible within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I select closing circumstance 'Data openly available elsewhere', the accepted dataset and Approximate publishing date elements are not visible + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Data openly available elsewhere" from "close_circumstance" + Then the element with the css selector "#field-accepted_dataset_id" should not be visible within 1 seconds + Then the element with the css selector "#field-approx_publishing_date" should not be visible within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I close a datarequest with accepted dataset, the accepted dataset should be visible on datarequest page + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Open dataset already exists" from "close_circumstance" + And I wait for 1 seconds + And I take a screenshot + # Have to use JS to change the selected value as the behaving framework does not work with autocomplete dropdown + Then I execute the script "$('#field-accepted_dataset_id').val($('#field-accepted_dataset_id option:eq(1)').attr('value'))" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see "Accepted dataset" within 1 seconds + And I should see "A Wonderful Story" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I close a datarequest with Approximate publishing date, the Approximate publishing date should be visible on datarequest page + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "To be released as open data at a later date" from "close_circumstance" + And I fill in "approx_publishing_date" with "2025-06-01" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see "Approximate publishing date" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + @wip + Scenario Outline: When I select closing circumstance 'Requestor initiated closure', the circumstance should be visible on the datarequest page + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Requestor initiated closure" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should see "Close circumstance" within 1 seconds + Then I should see "Requestor initiated closure" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | + + + Scenario Outline: When I close a datarequest with no accepted dataset or Approximate publishing date, they should not be visible on datarequest page + Given "" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Requestor initiated closure" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + Then I should not see "Accepted dataset" within 1 seconds + Then I should not see "Approximate publishing date" within 1 seconds + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | diff --git a/test/features/login.feature b/test/features/login.feature index 3256f2d5..9c77d30c 100644 --- a/test/features/login.feature +++ b/test/features/login.feature @@ -4,7 +4,6 @@ Feature: Login Scenario: Smoke test to ensure Login step works Given "SysAdmin" as the persona When I log in - Then I take a screenshot 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.jurisdiction' and @content='Queensland' and @scheme='AGLSTERMS.AglsJuri']" And I should see an element with xpath "//meta[@name='DCTERMS.type' and @content='Text' and @scheme='DCTERMS.DCMIType']" diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 23014437..857cd4ee 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -102,7 +102,6 @@ def add_resource(context, name, url): @step(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}" @@ -322,12 +321,15 @@ def submit_comment_with_subject_and_comment(context, subject, comment): :param comment: :return: """ - context.browser.execute_script( - "document.querySelector('form#comment_form input[name=\"subject\"]').value = '%s';" % subject) - context.browser.execute_script( - "document.querySelector('form#comment_form textarea[name=\"comment\"]').value = '%s';" % comment) - context.browser.execute_script( - "document.querySelector('form#comment_form .form-actions input[type=\"submit\"]').click();") + context.browser.execute_script(""" + document.querySelector('form#comment_form input[name="subject"]').value = '%s'; + """ % subject) + context.browser.execute_script(""" + document.querySelector('form#comment_form textarea[name="comment"]').value = '%s'; + """ % comment) + context.browser.execute_script(""" + document.querySelector('form#comment_form .form-actions input[type="submit"]').click(); + """) @step(u'I submit a reply with comment "{comment}"') @@ -339,10 +341,12 @@ def submit_reply_with_comment(context, comment): :param comment: :return: """ - context.browser.execute_script( - "document.querySelector('.comment-wrapper form textarea[name=\"comment\"]').value = '%s';" % comment) - context.browser.execute_script( - "document.querySelector('.comment-wrapper form .form-actions input[type=\"submit\"]').click();") + context.browser.execute_script(""" + document.querySelector('.comment-wrapper form textarea[name="comment"]').value = '%s'; + """ % comment) + context.browser.execute_script(""" + document.querySelector('.comment-wrapper form .form-actions input[type="submit"]').click(); + """) # ckanext-qgov From 4276ecd9abdb40ae2d6ea39d30fe916c5f2c8add Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 14:37:19 +1000 Subject: [PATCH 14/30] [DC-32168][QOL-8978] update cookbook - add cron job to purge Beaker session cache files - change Beaker session storage backend to Redis so it's cleaned up automatically - set extension ordering so sysadmin config page renders correctly --- vars/CKAN-Stack.var.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/CKAN-Stack.var.yml b/vars/CKAN-Stack.var.yml index 28e12d45..9df3d522 100644 --- a/vars/CKAN-Stack.var.yml +++ b/vars/CKAN-Stack.var.yml @@ -45,7 +45,7 @@ common_stack: &common_stack EnableDataStore: "{{ enable_datastore | default('no') }}" SSMKey: "{{ SSMKey | default('') }}" DefaultEC2Key: "{{ lookup('aws_ssm', '/config/CKAN/ec2KeyPair', region=region) }}" - CookbookRevision: "{{ CookbookRevision | default('5.2.13') }}" + CookbookRevision: "{{ CookbookRevision | default('5.2.14') }}" LogBucketName: "{{ lookup('aws_ssm', '/config/CKAN/s3LogsBucket', region=region) }}" AttachmentsBucketName: "{{ lookup('aws_ssm', '/config/CKAN/' + Environment + '/app/' + service_name_lower + '/s3AttachmentBucket', region=region) }}" #/config/CKAN/PROD/app/opendata/s3AttachmentBucket SolrSource: "{{ solr7 }}" From 4c076a8805e4c253f68acdd465d2c21865b7eb30 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:11:36 +1000 Subject: [PATCH 15/30] [QOL-8952] fix data request tests to match QGOV customisations --- .docker/Dockerfile.ckan | 2 +- test/features/data_request.feature | 76 ------------------------------ test/features/datarequest.feature | 44 ++++++++++------- 3 files changed, 27 insertions(+), 95 deletions(-) delete mode 100644 test/features/data_request.feature diff --git a/.docker/Dockerfile.ckan b/.docker/Dockerfile.ckan index f90ef28f..b664b2fc 100644 --- a/.docker/Dockerfile.ckan +++ b/.docker/Dockerfile.ckan @@ -16,7 +16,7 @@ WORKDIR "${APP_DIR}" ENV DOCKERIZE_VERSION v0.6.1 RUN apk add --no-cache curl build-base postgresql-client \ - && curl -s -L -O https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \ + && curl -sLO https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \ && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \ && rm dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz diff --git a/test/features/data_request.feature b/test/features/data_request.feature deleted file mode 100644 index 1e51c7f1..00000000 --- a/test/features/data_request.feature +++ /dev/null @@ -1,76 +0,0 @@ -@OpenData -@datarequest -Feature: Data Request - - @unauthenticated - Scenario: Data Requests are accessible via the /datarequest URL - Given "Unauthenticated" as the persona - When I go to the data requests page - Then the browser's URL should contain "/datarequest" - - @unauthenticated - Scenario: When visiting the datarequests page as a non-logged in user, the 'Add data request' button is not visible - Given "Unauthenticated" as the persona - When I go to the data requests page - Then I should not see an element with xpath "//a[contains(string(), 'Add data request', 'i')]" - - Scenario: Data requests submitted without a description will produce an error message - Given "SysAdmin" as the persona - When I log in and go to the data requests page - And I click the link with text that contains "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 - And I should see "The form contains invalid entries" within 1 seconds - And I should see an element with the css selector "span.error-block" within 1 seconds - And I should see "Description cannot be empty" within 1 seconds - - Scenario Outline: Data request creator and Sysadmin can see a 'Close' button on the data request detail page for opened data requests - Given "" as the persona - When I log in and go to the data requests page - And I press "Test Request" - Then I should see an element with xpath "//a[contains(string(), 'Close')]" - - Examples: Users - | User | - | SysAdmin | - - Scenario Outline: Non admin users cannot see a 'Close' button on the data request detail page for opened data requests - Given "" as the persona - When I log in and go to the data requests page - And I press "Test Request" - Then I should not see an element with xpath "//a[contains(string(), 'Close')]" - - Examples: Users - | User | - | CKANUser | - | DataRequestOrgEditor | - | DataRequestOrgMember | - | TestOrgEditor | - | TestOrgMember | - - Scenario: Creating a new data request will show the data request afterward - Given "TestOrgEditor" as the persona - When I log in and create a datarequest - Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" - And I should see an element with xpath "//a[contains(string(), 'Close')]" - - Scenario: Closing a data request will show the data request afterward - Given "DataRequestOrgAdmin" as the persona - When I log in and create a datarequest - And I press the element with xpath "//a[contains(string(), 'Close')]" - And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close data request')]" - Then I should see an element with xpath "//i[contains(@class, 'icon-lock')]" - And I should not see an element with xpath "//a[contains(string(), 'Close')]" - - Scenario: As an org admin I can re-open a closed data request - Given "DataRequestOrgAdmin" as the persona - When I log in and create a datarequest - And I press the element with xpath "//a[contains(string(), 'Close')]" - And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close data request')]" - Then I should see an element with xpath "//a[contains(string(), 'Re-open')]" - When I press the element with xpath "//a[contains(string(), 'Re-open')]" - Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" - And I should see an element with xpath "//a[contains(string(), 'Close')]" diff --git a/test/features/datarequest.feature b/test/features/datarequest.feature index d9da84c2..2fac6d12 100644 --- a/test/features/datarequest.feature +++ b/test/features/datarequest.feature @@ -1,32 +1,33 @@ -@data-requests @OpenData -Feature: Datarequest +@datarequest +Feature: Data Request + @unauthenticated Scenario: Data Requests are accessible via the /datarequest URL - When I go to datarequest page + Given "Unauthenticated" as the persona + When I go to the data requests page Then the browser's URL should contain "/datarequest" - - Scenario: When visiting the datarequests page as a non-logged in user, the 'Add Data Request' button is not visible - When I go to datarequest page + @unauthenticated + Scenario: When visiting the datarequests page as a non-logged in user, the 'Add data request' button is not visible + Given "Unauthenticated" as the persona + When I go to the data requests page Then I should not see an element with xpath "//a[contains(string(), 'Add data request', 'i')]" - Scenario: Data requests submitted without a description will produce an error message Given "SysAdmin" as the persona - When I log in and go to datarequest page - And I click the link with text that contains "Add Data Request" + When I log in and go to the data requests page + And I press the element with xpath "//a[contains(@class, 'btn-primary')]" And I fill in "title" with "Test data request" - And I press the element with xpath "//button[contains(string(), 'Create 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 And I should see "The form contains invalid entries" within 1 seconds And I should see an element with the css selector "span.error-block" within 1 seconds And I should see "Description cannot be empty" within 1 seconds - Scenario Outline: Data request creator and Sysadmin can see a 'Close' button on the data request detail page for opened data requests Given "" as the persona - When I log in and go to datarequest page + When I log in and go to the data requests page And I press "Test Request" Then I should see an element with xpath "//a[contains(string(), 'Close')]" @@ -34,10 +35,9 @@ Feature: Datarequest | User | | SysAdmin | - Scenario Outline: Non admin users cannot see a 'Close' button on the data request detail page for opened data requests Given "" as the persona - When I log in and go to datarequest page + When I log in and go to the data requests page And I press "Test Request" Then I should not see an element with xpath "//a[contains(string(), 'Close')]" @@ -46,23 +46,31 @@ Feature: Datarequest | CKANUser | | DataRequestOrgEditor | | DataRequestOrgMember | - | TestOrgAdmin | | TestOrgEditor | | TestOrgMember | - Scenario: Creating a new data request will show the data request afterward Given "TestOrgEditor" as the persona When I log in and create a datarequest Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" And I should see an element with xpath "//a[contains(string(), 'Close')]" - Scenario: Closing a data request will show the data request afterward Given "DataRequestOrgAdmin" as the persona When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger')]" Then I should see an element with xpath "//i[contains(@class, 'icon-lock')]" And I should not see an element with xpath "//a[contains(string(), 'Close')]" + + Scenario: As an org admin I can re-open a closed data request + Given "DataRequestOrgAdmin" as the persona + When I log in and create a datarequest + And I press the element with xpath "//a[contains(string(), 'Close')]" + And I select "Requestor initiated closure" from "close_circumstance" + And I press the element with xpath "//button[contains(string(), 'Close data request')]" + Then I should see an element with xpath "//a[contains(string(), 'Re-open')]" + When I press the element with xpath "//a[contains(string(), 'Re-open')]" + Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" + And I should see an element with xpath "//a[contains(string(), 'Close')]" From f35d1b2f12680d495e96fca121cfb3fe13021547 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:26:31 +1000 Subject: [PATCH 16/30] [QOL-8952] lock test 'setuptools' version to be Py2 compatible --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0225dd06..db472c91 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,5 @@ flake8==3.8.3 mock pytest-ckan PyYAML>=1.0 +setuptools==44.1.1 splinter>=0.13.0,<0.17 From f7759fd5583b6a03de228fb0203b3587c718a5af Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:45:14 +1000 Subject: [PATCH 17/30] [QOL-8952] restrict test pika to Py2 compatible versions --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index db472c91..3b4638f6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,6 +6,7 @@ ckantoolkit>=0.0.4 factory-boy==2.12.0 flake8==3.8.3 mock +pika>=1.1.0,<1.3.0 pytest-ckan PyYAML>=1.0 setuptools==44.1.1 From 03e1d8339d2136e5a3010e375339c0469250c8a4 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:45:14 +1000 Subject: [PATCH 18/30] [QOL-8952] restrict test pika to Py2 compatible versions --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0225dd06..20e6b11a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,6 +6,7 @@ ckantoolkit>=0.0.4 factory-boy==2.12.0 flake8==3.8.3 mock +pika>=1.1.0,<1.3.0 pytest-ckan PyYAML>=1.0 splinter>=0.13.0,<0.17 From 452238901ac4a4360b86fe8496305b4d67a2232d Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:26:31 +1000 Subject: [PATCH 19/30] [QOL-8952] lock test 'setuptools' version to be Py2 compatible --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 20e6b11a..3b4638f6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,4 +9,5 @@ mock pika>=1.1.0,<1.3.0 pytest-ckan PyYAML>=1.0 +setuptools==44.1.1 splinter>=0.13.0,<0.17 From 29233c0b0426c3ead8c5326ae16c0e7960bd460f Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 10:37:21 +1000 Subject: [PATCH 20/30] [QOL-8952] make test XPath more robust - Use CSS class and field name to identify button, instead of text. Text is more volatile, changing based on translation or due to site owner preferences. --- test/features/datarequest.feature | 2 +- test/features/datarequest_circumstances.feature | 14 +++++++------- test/features/engagement_reporting.feature | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/features/datarequest.feature b/test/features/datarequest.feature index 2fac6d12..1782185c 100644 --- a/test/features/datarequest.feature +++ b/test/features/datarequest.feature @@ -69,7 +69,7 @@ Feature: Data Request When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close data request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see an element with xpath "//a[contains(string(), 'Re-open')]" When I press the element with xpath "//a[contains(string(), 'Re-open')]" Then I should see an element with xpath "//i[contains(@class, 'icon-unlock')]" diff --git a/test/features/datarequest_circumstances.feature b/test/features/datarequest_circumstances.feature index 29f02e15..2dcf9f0a 100644 --- a/test/features/datarequest_circumstances.feature +++ b/test/features/datarequest_circumstances.feature @@ -26,7 +26,7 @@ Feature: Datarequest-circumstances When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Open dataset already exists" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds And I should see "The form contains invalid entries" within 1 seconds And I should see "Accepted dataset cannot be empty" within 1 seconds @@ -42,7 +42,7 @@ Feature: Datarequest-circumstances When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "To be released as open data at a later date" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see an element with the css selector "div.error-explanation.alert.alert-error" within 2 seconds And I should see "The form contains invalid entries" within 1 seconds And I should see "Approximate publishing date cannot be empty" within 1 seconds @@ -58,7 +58,7 @@ Feature: Datarequest-circumstances When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see an element with xpath "//span[contains(@class,'label-closed') and contains(string(), 'Closed')]" within 2 seconds Examples: Users @@ -116,7 +116,7 @@ Feature: Datarequest-circumstances And I take a screenshot # Have to use JS to change the selected value as the behaving framework does not work with autocomplete dropdown Then I execute the script "$('#field-accepted_dataset_id').val($('#field-accepted_dataset_id option:eq(1)').attr('value'))" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see "Accepted dataset" within 1 seconds And I should see "A Wonderful Story" within 1 seconds @@ -132,7 +132,7 @@ Feature: Datarequest-circumstances And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "To be released as open data at a later date" from "close_circumstance" And I fill in "approx_publishing_date" with "2025-06-01" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see "Approximate publishing date" within 1 seconds Examples: Users @@ -146,7 +146,7 @@ Feature: Datarequest-circumstances When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see "Close circumstance" within 1 seconds Then I should see "Requestor initiated closure" within 1 seconds @@ -161,7 +161,7 @@ Feature: Datarequest-circumstances When I log in and create a datarequest And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "Requestor initiated closure" from "close_circumstance" - And I press the element with xpath "//button[contains(string(), 'Close Data Request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should not see "Accepted dataset" within 1 seconds Then I should not see "Approximate publishing date" within 1 seconds diff --git a/test/features/engagement_reporting.feature b/test/features/engagement_reporting.feature index b90bf503..84824111 100644 --- a/test/features/engagement_reporting.feature +++ b/test/features/engagement_reporting.feature @@ -66,7 +66,7 @@ Feature: Engagement Reporting And I press the element with xpath "//a[contains(string(), 'Close')]" And I select "To be released as open data at a later date" from "close_circumstance" And I fill in "approx_publishing_date" with "01/01/1970" - And I press the element with xpath "//button[contains(string(), 'Close data request')]" + And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" And I should see an element with xpath "//i[contains(@class, 'icon-lock')]" When I go to my reports page From d4bfc1973510d4cfeaa88ea67b9c2fd2358f74df Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 11:34:32 +1000 Subject: [PATCH 21/30] [QOL-8952] provide test dataset for DR organisation - We need this in order to test data request closure with a linked dataset --- .docker/scripts/create-test-data.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.docker/scripts/create-test-data.sh b/.docker/scripts/create-test-data.sh index bb27f886..e910a764 100644 --- a/.docker/scripts/create-test-data.sh +++ b/.docker/scripts/create-test-data.sh @@ -190,6 +190,13 @@ curl -LsH "Authorization: ${API_KEY}" \ --data '{"id": "'"${DR_ORG_ID}"'", "object": "dr_member", "object_type": "user", "capacity": "member"}' \ ${CKAN_ACTION_URL}/member_create +echo "Creating test dataset for data request organisation:" + +curl -LsH "Authorization: ${API_KEY}" \ + --data '{"name": "data_request_dataset", "description": "Dataset for data requests", "owner_org": "'"${DR_ORG_ID}"'", +"update_frequency": "near-realtime", "author_email": "dr_admin@localhost", "version": "1.0", "license_id": "cc-by-4", +"data_driven_application": "NO", "security_classification": "PUBLIC", "notes": "test", "de_identified_data": "NO"}'\ + ${CKAN_ACTION_URL}/package_create echo "Creating test Data Request:" From f778ff906087e32045a9536f75a2fbfe30e41a04 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 12:31:29 +1000 Subject: [PATCH 22/30] [QOL-8952] fix test expectation for linked dataset --- test/features/datarequest_circumstances.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/features/datarequest_circumstances.feature b/test/features/datarequest_circumstances.feature index 2dcf9f0a..f5992f5c 100644 --- a/test/features/datarequest_circumstances.feature +++ b/test/features/datarequest_circumstances.feature @@ -118,7 +118,7 @@ Feature: Datarequest-circumstances Then I execute the script "$('#field-accepted_dataset_id').val($('#field-accepted_dataset_id option:eq(1)').attr('value'))" And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" Then I should see "Accepted dataset" within 1 seconds - And I should see "A Wonderful Story" within 1 seconds + And I should see "data_request_dataset" within 1 seconds Examples: Users | User | From fc415d088bb4362f296e823b0fe1ea8c635555ce Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 13:30:03 +1000 Subject: [PATCH 23/30] [QOL-8952] fix reporting tests - Anticipate the extra data request scenarios - Ensure reporting tests run last, so that the numbers aren't affected by race conditions --- .ahoy.yml | 5 ++++- test/features/engagement_reporting.feature | 25 +++++++--------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.ahoy.yml b/.ahoy.yml index f3d92f40..2f88b115 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -140,7 +140,10 @@ commands: ahoy cli "$BEHAVE_COMMAND" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] # Run app-specific tests - ahoy cli "behave -k --tags $VARS_TYPE ${*:-test/features}" || \ + ahoy cli "behave -k --tags $VARS_TYPE --tags=-reporting ${*:-test/features}" || \ + [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] + # Ensure reporting tests run last so there's no race condition on the numbers + ahoy cli "behave -k --tags $VARS_TYPE --tags=reporting ${*:-test/features}" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] ahoy stop-mailmock ahoy stop-ckan-job-workers diff --git a/test/features/engagement_reporting.feature b/test/features/engagement_reporting.feature index 84824111..6b26704a 100644 --- a/test/features/engagement_reporting.feature +++ b/test/features/engagement_reporting.feature @@ -29,22 +29,8 @@ Feature: Engagement Reporting And I click the link with text that contains "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]" - Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='3' 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 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]" - Then I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='4' and position()=2]" - - Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the numbers are correct and increment - 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 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='datarequests-total']/td[contains(@class, 'metric-data') and string()='25' and position()=2]" + And 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]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-title') and string()='Dataset comments' and position()=1]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" @@ -69,9 +55,14 @@ Feature: Engagement Reporting And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" And I should see an element with xpath "//i[contains(@class, 'icon-lock')]" + And I create a datarequest + When I go to my reports page And I click the link with text that contains "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 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]" + And 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]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" From e03820d27ca18de613f455abfacb27f0a148f612 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 14:12:46 +1000 Subject: [PATCH 24/30] [QOL-8952] reduce test logging from batch jobs - excess logs are being truncated, so reduce the batch job noise --- .docker/test-OpenData.ini | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.docker/test-OpenData.ini b/.docker/test-OpenData.ini index 11289616..7971196e 100644 --- a/.docker/test-OpenData.ini +++ b/.docker/test-OpenData.ini @@ -249,6 +249,30 @@ handlers = console qualname = ckanext propagate = 0 +[logger_ckanext_archiver] +level = ERROR +handlers = console +qualname = ckanext.archiver +propagate = 0 + +[logger_ckanext_qa] +level = ERROR +handlers = console +qualname = ckanext.qa +propagate = 0 + +[logger_ckanext_xloader] +level = ERROR +handlers = console +qualname = ckanext.xloader +propagate = 0 + +[logger_ckanext_validation] +level = ERROR +handlers = console +qualname = ckanext.validation +propagate = 0 + [handler_console] class = StreamHandler args = (sys.stderr,) From 25b6d685012cc8b0e8cbde33e7ad14deaee9aa2c Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 4 Jul 2022 15:04:20 +1000 Subject: [PATCH 25/30] [QOL-8952] make data request test step more robust - search for the target string before trying to click the link, so that we don't fail if the data request is on a second page --- test/features/steps/steps.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 6a4ab4c6..912b517e 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -396,9 +396,10 @@ def go_to_datarequest_page(context): def go_to_data_request(context, subject): context.execute_steps(u""" When I go to the data requests page - And I click the link with text "%s" - Then I should see "%s" within 5 seconds - """ % (subject, subject)) + And I fill in "q" with "{0}" + And I click the link with text "{0}" + Then I should see "{0}" within 5 seconds + """.format(subject)) @step(u'I log in and create a datarequest') From 3dd23daaf8541b9ee226540f01f65f7a30ba104e Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Tue, 5 Jul 2022 08:30:02 +1000 Subject: [PATCH 26/30] [QOL-8978] fix test steps for data request search - Interacting with the search fields isn't working properly, so add a test step to use the search URL directly --- test/features/steps/steps.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 912b517e..33fbce1e 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -387,6 +387,11 @@ def log_in_go_to_datarequest_page(context): """) +@step(u'I go to the data requests page containing "{keyword"}') +def go_to_datarequest_page_search(context, keyword): + when_i_visit_url(context, '/datarequest?q={}'.format(keyword)) + + @step(u'I go to the data requests page') def go_to_datarequest_page(context): when_i_visit_url(context, '/datarequest') @@ -395,8 +400,7 @@ def go_to_datarequest_page(context): @step(u'I go to data request "{subject}"') def go_to_data_request(context, subject): context.execute_steps(u""" - When I go to the data requests page - And I fill in "q" with "{0}" + When I go to the data requests page containing {0} And I click the link with text "{0}" Then I should see "{0}" within 5 seconds """.format(subject)) From 29a7fdd5a29a7e6bfe45698488244028357c9666 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Tue, 5 Jul 2022 09:17:39 +1000 Subject: [PATCH 27/30] [QOL-8978] oops fix syntax for data request list step --- test/features/steps/steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 33fbce1e..421be6e2 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -400,7 +400,7 @@ def go_to_datarequest_page(context): @step(u'I go to data request "{subject}"') def go_to_data_request(context, subject): context.execute_steps(u""" - When I go to the data requests page containing {0} + When I go to the data requests page containing "{0}" And I click the link with text "{0}" Then I should see "{0}" within 5 seconds """.format(subject)) From e67a8ee64acdb03eec3161db0b46ff386700b1b0 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Tue, 5 Jul 2022 09:57:44 +1000 Subject: [PATCH 28/30] [QOL-8978] oops fix syntax for data request list step - Misplaced double quote --- test/features/steps/steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 421be6e2..50ba609c 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -387,7 +387,7 @@ def log_in_go_to_datarequest_page(context): """) -@step(u'I go to the data requests page containing "{keyword"}') +@step(u'I go to the data requests page containing "{keyword}"') def go_to_datarequest_page_search(context, keyword): when_i_visit_url(context, '/datarequest?q={}'.format(keyword)) From d84e17b379557690d13d0788f318a167afbfb077 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Tue, 5 Jul 2022 10:57:20 +1000 Subject: [PATCH 29/30] [QOL-8978] revert tests to be more similar to develop branch - Scenarios for DataRequestOrgAdmin and ReportingOrgAdmin should not have been combined. --- test/features/engagement_reporting.feature | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/features/engagement_reporting.feature b/test/features/engagement_reporting.feature index 6b26704a..33e54c79 100644 --- a/test/features/engagement_reporting.feature +++ b/test/features/engagement_reporting.feature @@ -30,7 +30,22 @@ Feature: Engagement Reporting 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]" - And I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-title') and string()='Dataset followers' and position()=1]" + + 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 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]" + + Scenario: As an admin user of my organisation, when I view my engagement report, I can verify the numbers are correct and increment + 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 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]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-title') and string()='Dataset comments' and position()=1]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='0' and position()=2]" @@ -55,14 +70,9 @@ Feature: Engagement Reporting And I press the element with xpath "//button[contains(@class, 'btn-danger') and @name='close']" And I should see an element with xpath "//i[contains(@class, 'icon-lock')]" - And I create a datarequest - When I go to my reports page And I click the link with text that contains "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]" - And I should see an element with xpath "//tr[@id='dataset-followers']/td[contains(@class, 'metric-title') and string()='Dataset followers' and position()=1]" + 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]" And I should see an element with xpath "//tr[@id='dataset-comments']/td[contains(@class, 'metric-data') and string()='1' and position()=2]" From 0280eaf00887b5603e630f915daa4826cd1d4cac Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Tue, 5 Jul 2022 12:06:00 +1000 Subject: [PATCH 30/30] [DC-31965][QOL-8976][QOL-8989] update Publications theme - Drop duplicate breadcrumbs - Fix activity stream links - Restore custom robots.txt file --- vars/shared-Publications.var.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/shared-Publications.var.yml b/vars/shared-Publications.var.yml index 82be9ca8..f8ebb217 100644 --- a/vars/shared-Publications.var.yml +++ b/vars/shared-Publications.var.yml @@ -38,7 +38,7 @@ extensions: type: "git" description: "CKAN Extension for Queensland Government Publications theme" url: "https://github.com/qld-gov-au/ckanext-publications-qld-theme.git" - version: "1.1.4" + version: "1.1.5" CKANExtResourceTypeValidation: &CKANExtResourceTypeValidation name: "ckanext-resource-type-validation-{{ Environment }}"