From 6d242cb5d6b17294939cbab0dc1541c653f22301 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:29:06 +1000 Subject: [PATCH 1/7] drop unnecessary 'pika' dependency that requires Py3 --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0672049..7038f46 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ ckantoolkit>=0.0.4 -pika>=1.1.0 pyOpenSSL>=18.0.0 redis requests>=2.11.1 From 4b7f63c96bd5095d8f39a907718a02aa6ff74bd7 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:41:00 +1000 Subject: [PATCH 2/7] lock test version of ckanext-dcat to match infrastructure --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 84019b8..b7646be 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -14,7 +14,7 @@ python-magic==0.4.18 messytables==0.15.2 progressbar==2.5 --e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat +-e git+https://github.com/ckan/ckanext-dcat.git@v1.1.3#egg=ckanext-dcat -e git+https://github.com/ckan/ckanext-harvest.git@v1.3.4#egg=ckanext-harvest -e git+https://github.com/ckan/ckanext-scheming.git@release-1.2.0#egg=ckanext-scheming -e git+https://github.com/qld-gov-au/ckan-ex-qgov.git@4.0.2#egg=ckanext-qgov From 83ff562ca141f1f70b9c0307e0e3b697ceb6cca4 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 1 Jul 2022 15:42:33 +1000 Subject: [PATCH 3/7] restore 'pika' dependency but restrict to Py2 compatible versions --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 7038f46..1e34dfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ ckantoolkit>=0.0.4 +pika>=1.1.0,<1.3.0 pyOpenSSL>=18.0.0 redis requests>=2.11.1 From a4701674363f7e3bc9ad9505f51d291f708cf13e Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 7 Jul 2022 14:14:43 +1000 Subject: [PATCH 4/7] [QOL-9030] fix egg name - Newer Python/pip versions are stricter about matching names --- README.md | 2 +- setup.cfg | 20 ++++++++++---------- setup.py | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7f5e91f..b80ed5c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# ckanext-data-qld-harvester +# ckanext-harvester-data-qld-geoscience A CKAN extension to implement custom harvesting requirements for Data.Qld. diff --git a/setup.cfg b/setup.cfg index 3776322..5ff045f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,21 +1,21 @@ [extract_messages] keywords = translate isPlural add_comments = TRANSLATORS: -output_file = ckanext/data-qld-harvester/i18n/ckanext-data-qld-harvester.pot +output_file = ckanext/harvester-data-qld-geoscience/i18n/ckanext-harvester-data-qld-geoscience.pot width = 80 [init_catalog] -domain = ckanext-data-qld-harvester -input_file = ckanext/data-qld-harvester/i18n/ckanext-data-qld-harvester.pot -output_dir = ckanext/data-qld-harvester/i18n +domain = ckanext-harvester-data-qld-geoscience +input_file = ckanext/harvester-data-qld-geoscience/i18n/ckanext-harvester-data-qld-geoscience.pot +output_dir = ckanext/harvester-data-qld-geoscience/i18n [update_catalog] -domain = ckanext-data-qld-harvester -input_file = ckanext/data-qld-harvester/i18n/ckanext-data-qld-harvester.pot -output_dir = ckanext/data-qld-harvester/i18n +domain = ckanext-harvester-data-qld-geoscience +input_file = ckanext/harvester-data-qld-geoscience/i18n/ckanext-harvester-data-qld-geoscience.pot +output_dir = ckanext/harvester-data-qld-geoscience/i18n previous = true [compile_catalog] -domain = ckanext-data-qld-harvester -directory = ckanext/data-qld-harvester/i18n -statistics = true \ No newline at end of file +domain = ckanext-harvester-data-qld-geoscience +directory = ckanext/harvester-data-qld-geoscience/i18n +statistics = true diff --git a/setup.py b/setup.py index 1001d97..0f55c6f 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ long_description = f.read() setup( - name='ckanext-data-qld-harvester', + name='ckanext-harvester-data-qld-geoscience', # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see From 0253defa94affefc4d35fe980cea4c8958425912 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Thu, 7 Jul 2022 14:30:03 +1000 Subject: [PATCH 5/7] [QOL-9030] sync tests with ckanext-data-qld --- .ahoy.yml | 14 +- .docker/Dockerfile.ckan | 3 +- .docker/scripts/ckan_cli | 4 +- .docker/scripts/create-test-data.sh | 36 +- .docker/scripts/init-ext.sh | 1 - .docker/scripts/init.sh | 2 +- .docker/test.ini | 14 +- .github/workflows/test.yml | 4 +- dev-requirements.txt | 12 +- test/features/admin_reporting.feature | 40 +- test/features/comments.feature | 29 +- test/features/config.feature | 10 +- test/features/data_qld_theme.feature | 19 +- test/features/data_usability_rating.feature | 1 - test/features/data_validation.feature | 1 - ...ta_request.feature => datarequest.feature} | 11 +- .../datarequest_circumstances.feature | 171 +++++++++ test/features/dataset_deletion.feature | 6 +- test/features/datasets.feature | 17 + test/features/de_identified_data.feature | 5 +- test/features/engagement_reporting.feature | 77 ++-- test/features/google_analytics.feature | 94 ++++- test/features/groups.feature | 7 + test/features/homepage.feature | 6 +- test/features/login.feature | 4 +- test/features/login_redirect.feature | 22 +- test/features/navigation.feature | 5 +- test/features/organisations.feature | 9 +- test/features/resource_availability.feature | 230 ++++------- test/features/resource_freshness.feature | 12 +- test/features/resources.feature | 3 +- test/features/schema_metadata.feature | 9 +- test/features/search_facets.feature | 2 +- test/features/steps/steps.py | 358 +++++++++++------- test/features/user_creation.feature | 3 - test/features/users.feature | 17 +- 36 files changed, 821 insertions(+), 437 deletions(-) rename test/features/{data_request.feature => datarequest.feature} (96%) create mode 100644 test/features/datarequest_circumstances.feature diff --git a/.ahoy.yml b/.ahoy.yml index 08c3adf..19c222f 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -109,6 +109,13 @@ commands: ahoy cli "flake8 ${@:-ckanext}" || \ [ "${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.ini $CKAN_INI' + test-unit: usage: Run unit tests. cmd: | @@ -120,9 +127,14 @@ commands: cmd: | ahoy start-ckan-job-workers ahoy start-mailmock & + if (echo "$CKAN_VERSION" | grep '^ckan-2.8'); then + BEHAVE_TAGS="--tags=-ckan29" + fi sleep 5 && ahoy cli "behave -k ${*:-test/features}" --tags @smoke && \ - ahoy cli "behave -k ${*:-test/features}" || \ + ahoy cli "behave -k ${*:-test/features} --tags=-reporting $BEHAVE_TAGS" || \ + [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] + ahoy cli "behave -k ${*:-test/features} --tags=reporting" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] ahoy stop-mailmock ahoy stop-ckan-job-workers diff --git a/.docker/Dockerfile.ckan b/.docker/Dockerfile.ckan index cb97ebf..f270783 100644 --- a/.docker/Dockerfile.ckan +++ b/.docker/Dockerfile.ckan @@ -12,7 +12,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 @@ -32,7 +32,6 @@ RUN . ${VENV_DIR}/bin/activate \ COPY .docker/test.ini $CKAN_INI -# Add current extension and files. COPY . ${APP_DIR}/ COPY .docker/scripts ${APP_DIR}/scripts diff --git a/.docker/scripts/ckan_cli b/.docker/scripts/ckan_cli index 3cf0b4c..7757dc8 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} diff --git a/.docker/scripts/create-test-data.sh b/.docker/scripts/create-test-data.sh index d877cbe..2d17c48 100644 --- a/.docker/scripts/create-test-data.sh +++ b/.docker/scripts/create-test-data.sh @@ -95,14 +95,22 @@ add_user_if_needed foodie "Foodie" foodie@localhost add_user_if_needed group_admin "Group Admin" group_admin@localhost add_user_if_needed walker "Walker" walker@localhost -# 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}"'", + --data '{"name": "test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", "private": true, "update_frequency": "monthly", "author_email": "admin@localhost", "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 +# 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 + # Datasets need to be assigned to an organisation echo "Assigning test Datasets to Organisation..." @@ -208,6 +216,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:" @@ -269,12 +284,29 @@ curl -LsH "Authorization: ${API_KEY}" \ # END. # +## +# BEGIN: Add sysadmin config values. +# This needs to be done before closing datarequests as they require the below config values +# +echo "Adding ckan.datarequests.closing_circumstances:" + +curl -LsH "Authorization: ${API_KEY}" \ + --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 + echo "Creating config value for resource formats:" 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/.docker/scripts/init-ext.sh b/.docker/scripts/init-ext.sh index cc84557..e6d8823 100755 --- a/.docker/scripts/init-ext.sh +++ b/.docker/scripts/init-ext.sh @@ -13,7 +13,6 @@ pip install -r "$VENV_DIR/src/ckanext-archiver/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-dcat/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-qa/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-qgov/requirements.txt" -pip install -r "$VENV_DIR/src/ckanext-scheming/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-validation/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-xloader/requirements.txt" pip install -r "$VENV_DIR/src/ckanext-ytp-comments/requirements.txt" diff --git a/.docker/scripts/init.sh b/.docker/scripts/init.sh index 7f4c4aa..39a069d 100755 --- a/.docker/scripts/init.sh +++ b/.docker/scripts/init.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh ## -# Initialise CKAN instance. +# Initialise CKAN data for testing. # set -e diff --git a/.docker/test.ini b/.docker/test.ini index 8b76539..8c02631 100644 --- a/.docker/test.ini +++ b/.docker/test.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 data_qld_google_analytics datarequests scheming_datasets validation dcat qa archiver report ytp_comments xloader csrf_filter resource_type_validation harvest harvester_data_qld_geoscience qgovext +ckan.plugins = stats text_view image_view recline_view datastore data_qld data_qld_google_analytics scheming_datasets validation dcat qa archiver report qgovext ytp_comments datarequests xloader csrf_filter resource_type_validation ssm_config odi_certificates harvest harvester_data_qld_geoscience # Define which views should be created by default # (plugins must be loaded in ckan.plugins) @@ -192,19 +192,9 @@ ckanext.validation.formats = csv xlsx xls ##You can also provide validation options that will be used by default when running the validation: ## ckanext-scheming settings -# module-path:file to schemas being used +# see https://github.com/ckan/ckanext-scheming#configuration scheming.dataset_schemas = ckanext.data_qld:ckan_dataset.json ckanext.harvester_data_qld_geoscience:geoscience_dataset.json -# will try to load "spatialx_schema.json" and "spatialxy_schema.json" -# as dataset schemas -# -# URLs may also be used, e.g: -# -# scheming.dataset_schemas = http://example.com/spatialx_schema.json - -# Preset files may be included as well. The default preset setting is: scheming.presets = ckanext.scheming:presets.json ckanext.data_qld:presets.json - -# The is_fallback setting may be changed as well. Defaults to false: scheming.dataset_fallback = false ## ckanext-datarequests settings diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d3af13..cbde21c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - ckan-version: [ckan-2.8.8-qgov.5, qgov-master-2.9.4] + ckan-version: [ckan-2.8.8-qgov.5, ckan-2.9.5-qgov.7] name: Continuous Integration build on CKAN ${{ matrix.ckan-version }} runs-on: ubuntu-latest @@ -30,7 +30,7 @@ jobs: - name: Test run: .circleci/test.sh - timeout-minutes: 25 + timeout-minutes: 30 - name: Retrieve screenshots if: failure() diff --git a/dev-requirements.txt b/dev-requirements.txt index b7646be..2ea932b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -16,15 +16,17 @@ progressbar==2.5 -e git+https://github.com/ckan/ckanext-dcat.git@v1.1.3#egg=ckanext-dcat -e git+https://github.com/ckan/ckanext-harvest.git@v1.3.4#egg=ckanext-harvest --e git+https://github.com/ckan/ckanext-scheming.git@release-1.2.0#egg=ckanext-scheming --e git+https://github.com/qld-gov-au/ckan-ex-qgov.git@4.0.2#egg=ckanext-qgov +-e git+https://github.com/ckan/ckanext-scheming.git@release-2.1.0#egg=ckanext-scheming +-e git+https://github.com/qld-gov-au/ckan-ex-qgov.git@5.0.2#egg=ckanext-qgov -e git+https://github.com/qld-gov-au/ckanext-archiver.git@2.1.1-qgov.8#egg=ckanext-archiver --e git+https://github.com/qld-gov-au/ckanext-csrf-filter.git@1.1.3#egg=ckanext-csrf-filter --e git+https://github.com/qld-gov-au/ckanext-data-qld.git@6.0.5#egg=ckanext-data-qld +-e git+https://github.com/qld-gov-au/ckanext-csrf-filter.git@1.1.4#egg=ckanext-csrf-filter +-e git+https://github.com/qld-gov-au/ckanext-data-qld.git@6.3.4#egg=ckanext-data-qld -e git+https://github.com/qld-gov-au/ckanext-datarequests.git@2.2.0-qgov#egg=ckanext-datarequests +-e git+https://github.com/qld-gov-au/ckanext-odi-certificates.git@1.0.1#egg=ckanext-odi-certificates -e git+https://github.com/qld-gov-au/ckanext-qa.git@2.0.3-qgov.4#egg=ckanext-qa -e git+https://github.com/qld-gov-au/ckanext-report.git@0.3#egg=ckanext-report -e git+https://github.com/qld-gov-au/ckanext-resource-type-validation.git@1.0.2#egg=ckanext-resource-type-validation +-e git+https://github.com/qld-gov-au/ckanext-ssm-config.git@0.0.2#egg=ckanext-ssm-config -e git+https://github.com/qld-gov-au/ckanext-validation.git@v0.0.8-qgov.4#egg=ckanext-validation --e git+https://github.com/qld-gov-au/ckanext-xloader.git@0.9.0-qgov.1#egg=ckanext-xloader +-e git+https://github.com/qld-gov-au/ckanext-xloader.git@0.10.0-qgov.1#egg=ckanext-xloader -e git+https://github.com/qld-gov-au/ckanext-ytp-comments.git@2.5.0-qgov.2#egg=ckanext-ytp-comments diff --git a/test/features/admin_reporting.feature b/test/features/admin_reporting.feature index 35e0f0b..ab77937 100644 --- a/test/features/admin_reporting.feature +++ b/test/features/admin_reporting.feature @@ -10,9 +10,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 @@ -38,4 +38,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/comments.feature b/test/features/comments.feature index 0c7e6dc..e0329d9 100644 --- a/test/features/comments.feature +++ b/test/features/comments.feature @@ -1,24 +1,25 @@ @comments Feature: Comments + @unauthenticated Scenario: The Add Comment form should not display for a non-logged-in user - instead they see a 'Login to comment' button Given "Unauthenticated" as the persona When I go to dataset "warandpeace" comments - Then I should see an element with xpath "//a[contains(string(), 'Login to comment')]" - And I should not see "Add a comment" + Then I should see "Login to comment" within 1 seconds + And I should not see the add comment form Scenario: Logged-in users see the add comment form Given "CKANUser" as the persona When I log in Then I go to dataset "warandpeace" comments - Then I should see an element with xpath "//h3[contains(string(), 'Add a comment')]" + Then I should see the add comment form @comment-add Scenario: When a logged-in user submits a comment on a Dataset the comment should display within 10 seconds Given "CKANUser" as the persona When I log in Then I go to dataset "warandpeace" comments - Then I should see an element with xpath "//h3[contains(string(), 'Add a comment')]" + Then I should see the add comment form Then I submit a comment with subject "Test subject" and comment "This is a test comment" Then I should see "This is a test comment" within 10 seconds And I should see an element with xpath "//div[contains(@class, 'comment-wrapper') and contains(string(), 'This is a test comment')]" @@ -32,7 +33,7 @@ Feature: Comments Then I submit a comment with subject "Test subject" and comment "This is a test comment" Then I should see "This is a test comment" within 10 seconds - @comment-add @datarequest @comment-email + @comment-add @datarequest @email Scenario: When a logged-in user submits a comment on a Data Request the email should contain title and comment Given "CKANUser" as the persona When I log in @@ -40,15 +41,14 @@ Feature: Comments Then I should see an element with xpath "//h3[contains(string(), 'Add a comment')]" Then I submit a comment with subject "Test Request" and comment "This is a test data request comment" When I wait for 5 seconds - Then I should receive a base64 email at "test_org_admin@localhost" containing "Data request subject: Test Request" - And I should receive a base64 email at "test_org_admin@localhost" containing "Comment: This is a test data request comment" + Then I should receive a base64 email at "test_org_admin@localhost" containing both "Data request subject: Test Request" and "Comment: This is a test data request comment" @comment-add @comment-profane Scenario: When a logged-in user submits a comment containing whitelisted profanity on a Dataset the comment should display within 10 seconds Given "CKANUser" as the persona When I log in Then I go to dataset "warandpeace" comments - Then I should see an element with xpath "//h3[contains(string(), 'Add a comment')]" + Then I should see the add comment form Then I submit a comment with subject "Test subject" and comment "sex" Then I should see "sex" within 10 seconds @@ -61,7 +61,7 @@ Feature: Comments Then I submit a comment with subject "Test subject" and comment "He had sheep, and oxen, and he asses, and menservants, and maidservants, and she asses, and camels." Then I should see "Comment blocked due to profanity" within 5 seconds - @comment-report + @comment-report @email Scenario: When a logged-in user reports a comment on a Dataset the comment should be marked as reported and an email sent to the admins of the organisation Given "TestOrgEditor" as the persona When I log in @@ -70,7 +70,7 @@ Feature: Comments Then I should see "Reported" within 5 seconds Then I should receive a base64 email at "test_org_admin@localhost" containing "This comment has been flagged as inappropriate by a user" - @comment-report @datarequest + @comment-report @datarequest @email Scenario: When a logged-in user reports a comment on a Data Request the comment should be marked as reported and an email notification sent to the organisation admins Given "CKANUser" as the persona When I log in @@ -90,7 +90,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 @@ -101,7 +101,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 @@ -112,6 +112,7 @@ Feature: Comments And I should see "Comment deleted by Test Admin." within 2 seconds @comment-tab + @unauthenticated Scenario: Non-logged in users should not see comment form in dataset tab Given "Unauthenticated" as the persona When I go to dataset "warandpeace" @@ -120,10 +121,12 @@ Feature: Comments @comment-tab Scenario: Logged in users should not see comment form in dataset tab Given "CKANUser" as the persona - When I go to dataset "warandpeace" + When I log in + And I go to dataset "warandpeace" Then I should not see an element with id "comment_form" @comment-tab + @unauthenticated Scenario: Users should see comment tab on dataset Given "Unauthenticated" as the persona Then I go to dataset "warandpeace" diff --git a/test/features/config.feature b/test/features/config.feature index dd23174..bbfdcbf 100644 --- a/test/features/config.feature +++ b/test/features/config.feature @@ -5,15 +5,11 @@ 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 an element with id "field-ckanext.data_qld.excluded_display_name_words" + And I should see "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" - - Scenario: Assert that Data Request configuration values are available - Given "SysAdmin" as the persona - When I log in and go to admin config page - And I resize the browser to 1024x2048 - Then I should see "Data Request Suggested Description" + And I should see "Data Request Suggested Description" And I should see an element with id "field-ckanext.data_qld.datarequest_suggested_description" And I should see "Data Request Closing Circumstances" And I should see an element with id "field-ckan.datarequests.closing_circumstances" diff --git a/test/features/data_qld_theme.feature b/test/features/data_qld_theme.feature index 81c55a9..6e20410 100644 --- a/test/features/data_qld_theme.feature +++ b/test/features/data_qld_theme.feature @@ -1,10 +1,14 @@ Feature: Theme customisations + @unauthenticated Scenario: Lato font is implemented on homepage + Given "Unauthenticated" as the persona When I go to homepage Then I should see an element with xpath "//link[contains(@href,'https://fonts.googleapis.com/css?family=Lato')]" + @unauthenticated Scenario: Organisation is in fact spelled Organisation (as opposed to Organization) + Given "Unauthenticated" as the persona When I go to organisation page Then I should see "Organisation" And I should not see "Organization" @@ -35,11 +39,14 @@ Feature: Theme customisations And I should see "Some description or other" And I should see an element with xpath "//a[string() = 'read more' and contains(@href, '/organization/about/org-with-description')]" + @unauthenticated Scenario: Explore button does not exist on dataset detail page + Given "Unauthenticated" as the persona When I go to dataset page And I click the link with text that contains "A Wonderful Story" Then I should not see "Explore" + @unauthenticated Scenario: Explore button does not exist on dataset detail page When I go to organisation page Then I should see "Organisations are Queensland Government departments, other agencies or legislative entities responsible for publishing open data on this portal." @@ -67,7 +74,6 @@ Feature: Theme customisations Scenario: As a publisher, when I create a resource with an API entry, I can download it in various formats Given "TestOrgEditor" as the persona When I log in - And I resize the browser to 1024x2048 And I create a dataset with license "other-open" and "CSV" resource file "csv_resource.csv" And I wait for 10 seconds And I click the link with text that contains "Test Resource" @@ -78,7 +84,9 @@ 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')]" + @unauthenticated Scenario: When I encounter a 'resource not found' error page, it has a custom message + Given "Unauthenticated" as the persona When I go to "/dataset/nonexistent/resource/nonexistent" Then I should see "Sorry, the page you were looking for could not be found." @@ -86,9 +94,18 @@ Feature: Theme customisations Then I should see an element with xpath "//div[contains(string(), 'was not found') or contains(string(), 'could not be found')]" And I should not see "Sorry, the page you were looking for could not be found." + @unauthenticated Scenario: When I go to the header URL, I can see the list of necessary assets + Given "Unauthenticated" as the persona When I go to "/header.html" 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 see an element with xpath "//a[@href='/datarequest' and contains(string(), 'Request data')]" 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_usability_rating.feature b/test/features/data_usability_rating.feature index 7b5f1ce..292a243 100644 --- a/test/features/data_usability_rating.feature +++ b/test/features/data_usability_rating.feature @@ -4,7 +4,6 @@ Feature: Data usability rating Scenario Outline: As a publisher, when I create a resource with an open license, I can verify the openness score is correct Given "TestOrgEditor" as the persona When I log in - And I resize the browser to 1024x2048 And I create a dataset with license "other-open" and "" resource file "" Then I wait for 10 seconds When I press the element with xpath "//ol[contains(@class, 'breadcrumb')]//a[starts-with(@href, '/dataset/')]" diff --git a/test/features/data_validation.feature b/test/features/data_validation.feature index 711e140..b2ae56f 100644 --- a/test/features/data_validation.feature +++ b/test/features/data_validation.feature @@ -13,7 +13,6 @@ Feature: Data Validation | TestOrgAdmin | | TestOrgEditor | - Scenario: As any user, I can view the 'Data Schema' link in the 'Additional Info' table of the resource read-view page Given "SysAdmin" as the persona When I log in diff --git a/test/features/data_request.feature b/test/features/datarequest.feature similarity index 96% rename from test/features/data_request.feature rename to test/features/datarequest.feature index 69feebb..a5be6fe 100644 --- a/test/features/data_request.feature +++ b/test/features/datarequest.feature @@ -1,16 +1,18 @@ @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 @@ -22,7 +24,6 @@ Feature: Data Request 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 @@ -33,7 +34,6 @@ Feature: Data Request | 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 @@ -48,14 +48,12 @@ Feature: Data Request | 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 @@ -65,7 +63,6 @@ Feature: 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 diff --git a/test/features/datarequest_circumstances.feature b/test/features/datarequest_circumstances.feature new file mode 100644 index 0000000..f5992f5 --- /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(@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 + + 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(@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 + + 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(@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 + | 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(@class, 'btn-danger') and @name='close']" + Then I should see "Accepted dataset" within 1 seconds + And I should see "data_request_dataset" 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(@class, 'btn-danger') and @name='close']" + 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(@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 + + 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(@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 + + Examples: Users + | User | + | SysAdmin | + | DataRequestOrgAdmin | diff --git a/test/features/dataset_deletion.feature b/test/features/dataset_deletion.feature index 8eb9b59..c926186 100644 --- a/test/features/dataset_deletion.feature +++ b/test/features/dataset_deletion.feature @@ -11,14 +11,14 @@ Feature: Dataset deletion Then I select "False" from "private" Then I fill in "version" with "1" Then I fill in "author_email" with "test@test.com" - Then I select "NO" from "de_identified_data" + Then I fill in "de_identified_data" with "NO" if present And I press the element with xpath "//form[contains(@class, 'dataset-form')]//button[contains(@class, 'btn-primary')]" And I wait for 10 seconds Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" Then I fill in "name" with "res1" Then I fill in "description" with "description" - Then I fill in "size" with "1024" - Then I select "Resource NOT visible/Pending acknowledgement" from "resource_visibility" + Then I fill in "size" with "1024" if present + Then I fill in "resource_visibility" with "FALSE" if present Then I press the element with xpath "//button[@value='go-metadata']" And I wait for 10 seconds Then I should see "Data and Resources" diff --git a/test/features/datasets.feature b/test/features/datasets.feature index 8baecb6..635793d 100644 --- a/test/features/datasets.feature +++ b/test/features/datasets.feature @@ -6,3 +6,20 @@ Feature: Dataset APIs And I edit the "warandpeace" dataset Then I should see an element with xpath "//option[@value='cc-by-nc-sa-4']" + @ckan29 + 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']" diff --git a/test/features/de_identified_data.feature b/test/features/de_identified_data.feature index f456f9d..e80b4d7 100644 --- a/test/features/de_identified_data.feature +++ b/test/features/de_identified_data.feature @@ -8,10 +8,8 @@ Feature: De-identified data Then I should see an element with id "field-de_identified_data" Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='YES']" Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='NO']" - Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='']" Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='YES']" Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='NO']" - Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='']" Examples: Users | User | @@ -19,7 +17,6 @@ Feature: De-identified data | TestOrgAdmin | | TestOrgEditor | - Scenario Outline: An editor, admin or sysadmin user, when I go to the edit dataset page, the field field-de_identified_data should be visible with the correct values Given "" as the persona When I log in @@ -51,6 +48,7 @@ Feature: De-identified data | TestOrgAdmin | | TestOrgEditor | + @unauthenticated Scenario: Unauthenticated user cannot view the de-identified data Given "Unauthenticated" as the persona When I go to "/dataset/warandpeace" @@ -59,4 +57,3 @@ Feature: De-identified data And I go to "/api/3/action/package_show?id=warandpeace" Then I should not see an element with xpath "//body/*[contains(text(), '"de_identified_data":')]" - diff --git a/test/features/engagement_reporting.feature b/test/features/engagement_reporting.feature index 0a7918c..7ebc7cd 100644 --- a/test/features/engagement_reporting.feature +++ b/test/features/engagement_reporting.feature @@ -21,7 +21,6 @@ Feature: Engagement Reporting | TestOrgAdmin | | TestOrgEditor | - Scenario: As a data request organisation admin, when I view my engagement report, I can verify the number of data requests is correct and increments Given "DataRequestOrgAdmin" as the persona When I log in @@ -29,58 +28,62 @@ 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]" + And I should see an element with xpath "//tr[@id='datarequests-total']/td[contains(@class, 'metric-data') and string()='25' and position()=2]" + When I create a datarequest + And I go to my reports page And I click the link with text that contains "Engagement Report" And I press 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]" - + 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 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]" + And I go to dataset "reporting" comments + And I submit a comment with subject "Test subject" and comment "This is a test comment" - 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 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 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]" + 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')]" - 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 + 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='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 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='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/google_analytics.feature b/test/features/google_analytics.feature index 303ddf3..3818076 100644 --- a/test/features/google_analytics.feature +++ b/test/features/google_analytics.feature @@ -1,17 +1,95 @@ @google-analytics Feature: GoogleAnalytics + @unauthenticated Scenario: When viewing the HTML source code of a CKAN page, the GTM snippet is visible + Given "Unauthenticated" as the persona When I go to homepage Then I should see an element with xpath "//script[@src='//www.googletagmanager.com/gtm.js?id=False']" - Scenario: When viewing the HTML source code of a dataset, the organisation meta data is visible - When I go to Dataset page - And I click the link with text that contains "Department of Health Spend Data" - Then I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Department of Health' and @scheme='AGLSTERMS.GOLD']" + @unauthenticated + Scenario: When viewing the HTML source code of a group, the appropriate metadata is visible + Given "Unauthenticated" as the persona + When I go to group page + And I resize the browser to 1024x2048 + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Groups']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland;' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='List of all groups']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']" - Scenario: When viewing the HTML source code of a resource, the organisation meta data is visible + When I click the link with text that contains "Dave's books" + And I click the link with text that contains "About" + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and contains(@content, 'Dave')]" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and contains(@content, 'c=AU; o=The State of Queensland; ou=Dave') and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.created' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='These are books that David likes.']" + And I should see an element with xpath "//meta[@name='DCTERMS.identifier' and @content!='' and @content!='None']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='guidelines']" + + @unauthenticated + Scenario: When viewing the HTML source code of an organisation, the appropriate metadata is visible + Given "Unauthenticated" as the persona + When I go to organisation page + And I resize the browser to 1024x2048 + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Organisations']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland;' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='List of all organisations']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']" + + When I click the link with text that contains "Department of Health" + And I click the link with text that contains "About" + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Department of Health']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Department of Health' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.created' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='Department of Health']" + And I should see an element with xpath "//meta[@name='DCTERMS.identifier' and @content!='' and @content!='None']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='guidelines']" + + Scenario: When viewing the HTML source code of a resource, the appropriate metadata is visible + Given "TestOrgEditor" as the persona When I go to Dataset page - And I click the link with text that contains "A Novel By Tolstoy" - And I click the link with text that contains "Full text" - Then I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Test Organisation' and @scheme='AGLSTERMS.GOLD']" + And I resize the browser to 1024x2048 + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Datasets']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland;' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='List of all datasets']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']" + + When I log in + And I create a dataset with title "DCTERMS-testing" + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='DCTERMS-testing']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Test Organisation' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.created' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.modified' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='Description']" + And I should see an element with xpath "//meta[@name='DCTERMS.identifier' and @content!='' and @content!='None']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='index']" + + When I click the link with text that contains "Test Resource" + Then I should see an element with xpath "//meta[@name='DCTERMS.title' and @content='Test Resource']" + And I should see an element with xpath "//meta[@name='DCTERMS.publisher' and @content='corporateName=The State of Queensland; jurisdiction=Queensland' and @scheme='AGLSTERMS.AglsAgent']" + And I should see an element with xpath "//meta[@name='DCTERMS.creator' and @content='c=AU; o=The State of Queensland; ou=Test Organisation' and @scheme='AGLSTERMS.GOLD']" + And I should see an element with xpath "//meta[@name='DCTERMS.created' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.modified' and @content!='' and @content!='None']" + And I should see an element with xpath "//meta[@name='DCTERMS.description' and @content='Test Resource Description']" + And I should see an element with xpath "//meta[@name='DCTERMS.identifier' and @content!='' and @content!='None']" + 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']" + And I should see an element with xpath "//meta[@name='AGLSTERMS.documentType' and @content='dataset']" diff --git a/test/features/groups.feature b/test/features/groups.feature index ec9eb64..9333bbe 100644 --- a/test/features/groups.feature +++ b/test/features/groups.feature @@ -23,12 +23,19 @@ Feature: Group APIs | Organisation Admin | | Walker | + @unauthenticated Scenario: Group membership is not accessible anonymously + Given "Unauthenticated" as the persona When I view the "silly-walks" group API "including" users Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'Authorization Error')]" + @unauthenticated Scenario: Group overview is accessible to everyone + Given "Unauthenticated" as the persona When I go to "/group" Then I should see "silly-walks" + And I should not see an element with xpath "//a[contains(@href, '?action=read')]" + And I should see an element with xpath "//a[contains(@href, '/group/silly-walks')]" + When I view the "silly-walks" group API "not including" users Then I should see an element with xpath "//*[contains(string(), '"success": true,') and contains(string(), '"name": "silly-walks"')]" diff --git a/test/features/homepage.feature b/test/features/homepage.feature index b7b1f37..ff4bbcc 100644 --- a/test/features/homepage.feature +++ b/test/features/homepage.feature @@ -2,6 +2,10 @@ Feature: Homepage @homepage + @unauthenticated 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']" diff --git a/test/features/login.feature b/test/features/login.feature index ca7a0e5..9c77d30 100644 --- a/test/features/login.feature +++ b/test/features/login.feature @@ -4,4 +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/login_redirect.feature b/test/features/login_redirect.feature index 030db00..023cc70 100644 --- a/test/features/login_redirect.feature +++ b/test/features/login_redirect.feature @@ -22,23 +22,15 @@ Feature: Login Redirection When I log in directly Then I should see "Change details" - @dataset_setup - Scenario: As a Sysadmin I set the visibility of a public record to private for the following scenarios - Given "SysAdmin" as the persona - When I log in - Then I visit "/dataset/edit/annakarenina" - When I select "True" from "private" - And I fill in "author_email" with "test@example.com" - And I press "Update Dataset" - Then I should see an element with xpath "//span[contains(string(), 'Private')]" - @private_dataset + @unauthenticated Scenario: As an unauthenticated user, when I visit the URL of a private dataset I see the login page Given "Unauthenticated" as the persona - When I visit "/dataset/annakarenina" + When I visit "/dataset/test-dataset" Then I should see a login link @public_dataset + @unauthenticated Scenario: As an unauthenticated user, when I visit the URL of a public dataset I see the dataset without needing to login Given "Unauthenticated" as the persona When I visit "/dataset/warandpeace" @@ -48,16 +40,16 @@ Feature: Login Redirection @private_dataset Scenario: As an unauthenticated organisation member, when I visit the URL of a private dataset I see the login page. Upon logging in I am taken to the private dataset Given "TestOrgMember" as the persona - When I visit "/dataset/annakarenina" + When I visit "/dataset/test-dataset" Then I should see a login link When I log in directly - Then I should see an element with xpath "//h1[contains(string(), 'A Novel By Tolstoy')]" + Then I should see an element with xpath "//h1[contains(string(), 'test-dataset')]" And I should see an element with xpath "//span[contains(string(), 'Private')]" @private_dataset Scenario: As an authenticated organisation member, when I visit the URL of a dataset private to my organisation I am taken to the private dataset Given "TestOrgMember" as the persona When I log in - Then I visit "/dataset/annakarenina" - Then I should see an element with xpath "//h1[contains(string(), 'A Novel By Tolstoy')]" + Then I visit "/dataset/test-dataset" + Then I should see an element with xpath "//h1[contains(string(), 'test-dataset')]" And I should see an element with xpath "//span[contains(string(), 'Private')]" diff --git a/test/features/navigation.feature b/test/features/navigation.feature index 261e951..4980199 100644 --- a/test/features/navigation.feature +++ b/test/features/navigation.feature @@ -1,6 +1,8 @@ Feature: Navigation + @unauthenticated Scenario: Check for the presence of the 'Request data' link in header when visiting as a non-logged in user + Given "Unauthenticated" as the persona When I go to homepage # Make the comparison case-insensitive Then I should see an element with xpath "//a[contains(translate(., 'RD', 'rd'), "request data")]" @@ -13,10 +15,11 @@ Feature: Navigation Then I should see an element with xpath "//a[contains(translate(., 'RD', 'rd'), "request data")]" Scenario: Check for the presence of the 'Copyright' link in footer when visiting as a non-logged in user + Given "Unauthenticated" as the persona When I go to homepage Then I should see an element with xpath "//footer/div/ul/li/a[contains(string(), "Copyright")]" Scenario: Check for the presence of the 'Disclaimer' link in footer when visiting as a non-logged in user + Given "Unauthenticated" as the persona When I go to homepage Then I should see an element with xpath "//footer/div/ul/li/a[contains(string(), "Disclaimer")]" - diff --git a/test/features/organisations.feature b/test/features/organisations.feature index e7b97aa..60ed357 100644 --- a/test/features/organisations.feature +++ b/test/features/organisations.feature @@ -24,12 +24,19 @@ Feature: Organization APIs | Foodie | | Group Admin | + @unauthenticated Scenario: Organisation membership is not accessible anonymously + Given "Unauthenticated" as the persona When I view the "department-of-health" organisation API "including" users Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'Authorization Error')]" + @unauthenticated Scenario: Organisation overview is accessible to everyone - When I go to "/organization" + Given "Unauthenticated" as the persona + When I go to organisation page Then I should see "Department of Health" + And I should not see an element with xpath "//a[contains(@href, '?action=read')]" + And I should see an element with xpath "//a[contains(@href, '/organization/department-of-health')]" + When I view the "department-of-health" organisation API "not including" users Then I should see an element with xpath "//*[contains(string(), '"success": true,') and contains(string(), '"name": "department-of-health"')]" diff --git a/test/features/resource_availability.feature b/test/features/resource_availability.feature index 500d3ec..1e5a35d 100644 --- a/test/features/resource_availability.feature +++ b/test/features/resource_availability.feature @@ -1,106 +1,41 @@ @resource_visibility Feature: Re-identification risk governance acknowledgement or Resource visibility - - Scenario: Sysadmin creates dataset with Contains de-identified data is YES - Given "SysAdmin" as the persona - When I log in - And I go to "/dataset/new" - Then I fill in "title" with "Contains de-identified data - YES" - Then I fill in "notes" with "notes" - Then I execute the script "document.getElementById('field-organizations').value=jQuery('#field-organizations option').filter(function () { return $(this).html() == 'Test Organisation'; }).attr('value')" - Then I select "False" from "private" - Then I fill in "version" with "1" - Then I fill in "author_email" with "test@test.com" - Then I select "YES" from "de_identified_data" - And I press the element with xpath "//form[contains(@class, 'dataset-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "res1" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I select "Resource NOT visible/Pending acknowledgement" from "resource_visibility" - And I press the element with xpath "//button[@value='go-metadata']" - And I wait for 10 seconds - Then I should see "Data and Resources" - - - Scenario: Sysadmin creates dataset with Contains de-identified data is NO + Scenario: Sysadmin creates datasets with de_identified_data, resource_visible and governance_acknowledgement values to test resource visibility feature Given "SysAdmin" as the persona When I log in - And I go to "/dataset/new" - Then I fill in "title" with "Contains de-identified data - NO" - Then I fill in "notes" with "notes" - Then I execute the script "document.getElementById('field-organizations').value=jQuery('#field-organizations option').filter(function () { return $(this).html() == 'Test Organisation'; }).attr('value')" - Then I select "False" from "private" - Then I fill in "version" with "1" - Then I fill in "author_email" with "test@test.com" - Then I select "NO" from "de_identified_data" - And I press the element with xpath "//form[contains(@class, 'dataset-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "res1" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I select "Resource NOT visible/Pending acknowledgement" from "resource_visibility" - And I press the element with xpath "//button[@value='go-metadata']" - And I wait for 10 seconds - Then I should see "Data and Resources" - - - Scenario Outline: When a user creates a resource for a dataset with Contains de-identified data is YES, re-identification risks must be assessed and data can be hidden from the public. + And I create resource_availability test data with title:"Contains de-identified data YES visibility TRUE acknowledgment NO" de_identified_data:"YES" resource_name:"Hide Resource" resource_visible:"TRUE" governance_acknowledgement:"NO" + And I create resource_availability test data with title:"Contains de-identified data NO visibility TRUE acknowledgment NO" de_identified_data:"NO" resource_name:"Show Resource" resource_visible:"TRUE" governance_acknowledgement:"NO" + And I create resource_availability test data with title:"Contains de-identified data NO visibility FALSE acknowledgment NO" de_identified_data:"NO" resource_name:"Hide Resource" resource_visible:"FALSE" governance_acknowledgement:"NO" + And I create resource_availability test data with title:"Contains de-identified data YES visibility TRUE acknowledgment YES" de_identified_data:"NO" resource_name:"Show Resource" resource_visible:"TRUE" governance_acknowledgement:"NO" + + + Scenario Outline: Organisation users should see a hidden resource when de-identified data is YES and Resource visibility is TRUE and Acknowledgement is NO Given "" as the persona When I log in + And I go to "/dataset/contains-de-identified-data-yes-visibility-true-acknowledgment-no" + And I press the element with xpath "//a[@title='Hide Resource']" + Then I should see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" - ### - # Create resource that available for non-logged in user. - ### - And I go to "/dataset/new_resource/contains-de-identified-data-yes" - - # Check field visibility, xpath element start with 1. - Then I should see an element with id "field-resource_visibility" - And I should see an element with xpath "//select[@id='field-resource_visibility']/option[2][@disabled]" - - # Create the resource, with error. - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "resource created by and is available" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "This dataset has been recorded as containing de-identified data." - - # Create the resource, with success. - When I select "Appropriate steps have been taken to minimise personal information re-identification risk prior to publishing" from "resource_visibility" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "resource created by and is available" - When I press the element with xpath "//a[@title='resource created by and is available']" - Then I should see "Re-identification risk governance acknowledgement/Resource visibility" - - ### - # Create resource that NOT available for non-logged in user. - ### - And I go to "/dataset/new_resource/contains-de-identified-data-yes" - - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "resource created by and is NOT available" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I select "Resource NOT visible/Pending acknowledgement" from "resource_visibility" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "resource created by and is NOT available" - - # Verify the result as non-logged in user. + Examples: Users + | User | + | SysAdmin | + | TestOrgAdmin | + | TestOrgEditor | + + Scenario: Unauthenticated user should not see a hidden resource when de-identified data is YES and Resource visibility is TRUE and Acknowledgement is NO Given "Unauthenticated" as the persona - And I go to "/dataset/contains-de-identified-data-yes" - Then I should see "resource created by and is available" - Then I should not see "resource created by and is NOT available" + When I go to "/dataset/contains-de-identified-data-yes-visibility-true-acknowledged-no" + Then I should not see an element with xpath "//a[@title='Hide Resource']" + + Scenario Outline: Organisation users should see a visible resource when de-identified data is NO and Resource visibility is TRUE and Acknowledgement is NO + Given "" as the persona + And I log in + And I go to "/dataset/contains-de-identified-data-no-visibility-true-acknowledgment-no" + And I press the element with xpath "//a[@title='Show Resource']" + Then I should see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" Examples: Users | User | @@ -108,69 +43,60 @@ Feature: Re-identification risk governance acknowledgement or Resource visibilit | TestOrgAdmin | | TestOrgEditor | + Scenario: Unauthenticated user should see a visible resource when de-identified data is NO and Resource visibility is TRUE and Acknowledgement is NO + Given "Unauthenticated" as the persona + When I go to "/dataset/contains-de-identified-data-no-visibility-true-acknowledgment-no" + And I press the element with xpath "//a[@title='Show Resource']" + Then I should not see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should not see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" - Scenario Outline: When a user creates a resource for a dataset with Contains de-identified data is NO, re-identification risks do not need to be assessed, but data can still be hidden from the public. + Scenario Outline: Organisation users should see a hidden resource when de-identified data is NO and Resource visibility is FALSE and Acknowledgement is NO Given "" as the persona When I log in + And I go to "/dataset/contains-de-identified-data-no-visibility-false-acknowledgment-no" + And I press the element with xpath "//a[@title='Hide Resource']" + Then I should see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" - ### - # Create resource that available for non-logged in user. - ### - And I go to "/dataset/new_resource/contains-de-identified-data-no" - - # Check field visibility, xpath element start with 1. - Then I should see an element with id "field-resource_visibility" - And I should see an element with xpath "//select[@id='field-resource_visibility']/option[3][@disabled]" - - # Create the resource, with success. - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "resource created by and is available" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I select "Resource visible and re-identification risk governance acknowledgement not required" from "resource_visibility" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "resource created by and is available" - - ### - # Create resource that available for non-logged in user with resource_visibility blank. - ### - And I go to "/dataset/new_resource/contains-de-identified-data-no" - - # Create the resource, with success. - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "resource created by and is available with blank resource_visibility" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "resource created by and is available with blank resource_visibility" - - ### - # Create resource that NOT available for non-logged in user. - ### - And I go to "/dataset/new_resource/contains-de-identified-data-no" - - Then I execute the script "document.getElementById('field-image-url').value='https://example.com'" - And I fill in "name" with "resource created by and is NOT available" - And I select "HTML" from "format" - And I fill in "description" with "description" - And I fill in "size" with "1024" - And I select "Resource NOT visible/Pending acknowledgement" from "resource_visibility" - And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" - And I wait for 10 seconds - Then I should see "resource created by and is NOT available" - - # Verify the result as non-logged in user. + Examples: Users + | User | + | SysAdmin | + | TestOrgAdmin | + | TestOrgEditor | + + Scenario: Unauthenticated user should not see a hidden visible resource when de-identified data is NO and Resource visibility is FALSE and Acknowledgement is NO + Given "Unauthenticated" as the persona + When I go to "/dataset/contains-de-identified-data-no-visibility-false-acknowledgment-no" + Then I should not see an element with xpath "//a[@title='Hide Resource']" + + Scenario Outline: Organisation users should see a visible resource when de-identified data is YES and Resource visibility is TRUE and Acknowledgement is YES + Given "" as the persona + When I log in + And I go to "/dataset/contains-de-identified-data-yes-visibility-true-acknowledgment-yes" + And I press the element with xpath "//a[@title='Show Resource']" + Then I should see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" + + Examples: Users + | User | + | SysAdmin | + | TestOrgAdmin | + | TestOrgEditor | + + Scenario: Unauthenticated user should see a visible resource when de-identified data is YES and Resource visibility is TRUE and Acknowledgement is YES Given "Unauthenticated" as the persona - When I go to "/dataset/contains-de-identified-data-no" - Then I should see "resource created by and is available" - And I should see "resource created by and is available with blank resource_visibility" - And I should not see "resource created by and is NOT available" - Then I press the element with xpath "//a[@title='resource created by and is available']" - And I should not see "Re-identification risk governance acknowledgement/Resource visibility" + When I go to "/dataset/contains-de-identified-data-yes-visibility-true-acknowledgment-yes" + And I press the element with xpath "//a[@title='Show Resource']" + Then I should not see an element with xpath "//th[contains(text(), 'Resource visible')]" + And I should not see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]" + + Scenario Outline: Create resource and verify default values are set correct for resource visibility + Given "" as the persona + When I create a resource with name "Resource created by with default values" and URL "https://example.com" + And I press the element with xpath "//a[@title='Resource created by with default values']" + Then I should not see "Visibility/Governance Acknowledgment" + And I should see an element with xpath "//th[contains(text(), 'Resource visible')]/following-sibling::td[contains(text(), 'TRUE')]" + And I should see an element with xpath "//th[contains(text(), 'Re-identification risk governance completed?')]/following-sibling::td[contains(text(), 'NO')]" Examples: Users | User | diff --git a/test/features/resource_freshness.feature b/test/features/resource_freshness.feature index 706d4b4..7952089 100644 --- a/test/features/resource_freshness.feature +++ b/test/features/resource_freshness.feature @@ -13,7 +13,6 @@ Feature: Resource freshness | TestOrgAdmin | | TestOrgEditor | - Scenario Outline: An editor, admin or sysadmin user, when I go to the dataset new page and select 'monthly' update frequency, then the text 'Next update due' should be visible Given "" as the persona When I log in @@ -27,14 +26,17 @@ 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" + Then I should be able to patch dataset "test-dataset" via the API + 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/resources.feature b/test/features/resources.feature index 61b51bb..15a102c 100644 --- a/test/features/resources.feature +++ b/test/features/resources.feature @@ -3,8 +3,7 @@ Feature: Resource UI Scenario Outline: Link resource should create a link to its URL Given "SysAdmin" as the persona - When I resize the browser to 1024x2048 - And I create a resource with name "" and URL "" + When I create a resource with name "" and URL "" And I press the element with xpath "//a[contains(@title, '') and contains(string(), '')]" Then I should see "" diff --git a/test/features/schema_metadata.feature b/test/features/schema_metadata.feature index 3e45847..39dc4b7 100644 --- a/test/features/schema_metadata.feature +++ b/test/features/schema_metadata.feature @@ -1,7 +1,6 @@ @schema_metadata Feature: SchemaMetadata - Scenario: When a go to the dataset new page, the field field-author_email should not be visible Given "SysAdmin" as the persona When I log in @@ -23,9 +22,9 @@ Feature: SchemaMetadata Then I should see "Name: Missing value" And I should see "Description: Missing value" + @unauthenticated Scenario: When viewing the HTML source code of a dataset page, the structured data script is visible - Given "SysAdmin" as the persona - When I log in + Given "Unauthenticated" as the persona When I go to "/dataset/warandpeace" Then I should see an element with xpath "//link[@type='application/ld+json']" @@ -36,10 +35,8 @@ Feature: SchemaMetadata Then I should see an element with id "field-de_identified_data" Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='YES']" Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='NO']" - Then I should see an element with xpath "//select[@id='field-de_identified_data']/option[@value='']" Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='YES']" Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='NO']" - Then I should not see an element with xpath "//select[@id='field-de_identified_data']/option[@selected='' and @value='']" Examples: Users | User | @@ -47,7 +44,6 @@ Feature: SchemaMetadata | TestOrgAdmin | | TestOrgEditor | - Scenario Outline: Edit existing dataset, field de_identified_data value should be NO Given "" as the persona When I log in @@ -79,6 +75,7 @@ Feature: SchemaMetadata | TestOrgAdmin | | TestOrgEditor | + @unauthenticated Scenario: Non logged-in user should not see de_identified_data value. Given "Unauthenticated" as the persona When I go to "/dataset/warandpeace" diff --git a/test/features/search_facets.feature b/test/features/search_facets.feature index 8b640e7..9839ada 100644 --- a/test/features/search_facets.feature +++ b/test/features/search_facets.feature @@ -1,6 +1,6 @@ Feature: Search facets Scenario: When I go to the dataset list page, I can see the 'Data Portals' facet - When I go to "/dataset" + When I go to dataset page Then I should see "Data Portals" And I should see an element with xpath "//a[contains(@href, '?dataset_type=dataset')]/span[contains(@class, 'item-label') and contains(string(), 'data.qld.gov.au')]" diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index 3e1c8d5..50ba609 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -5,7 +5,8 @@ from behaving.web.steps.url import when_i_visit_url import email import quopri -import random +import requests +import uuid @step(u'I get the current URL') @@ -31,6 +32,7 @@ def log_in(context): assert context.persona context.execute_steps(u""" When I go to homepage + And I resize the browser to 1024x2048 And I click the link with text that contains "Log in" And I log in directly """) @@ -68,6 +70,24 @@ def login_link_visible(context): """) +@step(u'I request a password reset') +def request_reset(context): + assert context.persona + context.execute_steps(u""" + When I visit "/user/reset" + And I fill in "user" with "$name" + And I press the element with xpath "//button[contains(string(), 'Request Reset')]" + And I go to dataset page + """) + + +@step(u'I fill in "{name}" with "{value}" if present') +def fill_in_field_if_present(context, name, value): + context.execute_steps(u""" + When I execute the script "field = document.getElementById('field-{0}'); if (field) field.value = '{1}';" + """.format(name, value)) + + @step(u'I create a resource with name "{name}" and URL "{url}"') def add_resource(context, name, url): context.execute_steps(u""" @@ -76,18 +96,17 @@ def add_resource(context, name, url): And I execute the script "document.getElementById('field-image-url').value='{url}'" And I fill in "name" with "{name}" And I fill in "description" with "description" - And I execute the script "size_field = document.getElementById('field-size'); if (size_field) size_field.value = '1024';" + And I fill in "size" with "1024" if present And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" """.format(name=name, url=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}" - """.format(random.randrange(100000))) + """.format(uuid.uuid4())) @step(u'I go to dataset page') @@ -105,34 +124,16 @@ def edit_dataset(context, name): when_i_visit_url(context, '/dataset/edit/{}'.format(name)) +@step(u'I go to group page') +def go_to_group_page(context): + when_i_visit_url(context, '/group') + + @step(u'I go to organisation page') def go_to_organisation_page(context): when_i_visit_url(context, '/organization') -@step(u'I set persona var "{key}" to "{value}"') -def set_persona_var(context, key, value): - context.persona[key] = value - - -@step(u'I lock my account') -def lock_account(context): - when_i_visit_url(context, "/user/login") - for x in range(11): - attempt_login(context, "incorrect password") - - -@step(u'I request a password reset') -def request_reset(context): - assert context.persona - context.execute_steps(u""" - When I visit "/user/reset" - And I fill in "user" with "$name" - And I press the element with xpath "//button[contains(string(), 'Request Reset')]" - And I go to dataset page - """) - - @step(u'I search the autocomplete API for user "{username}"') def go_to_user_autocomplete(context, username): when_i_visit_url(context, '/api/2/util/user/autocomplete?q={}'.format(username)) @@ -168,103 +169,19 @@ 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 log in and go to the data requests page') -def log_in_go_to_datarequest_page(context): - assert context.persona - context.execute_steps(u""" - When I log in - And I go to the data requests page - """) - - -@step(u'I go to the data requests page') -def go_to_datarequest_page(context): - when_i_visit_url(context, '/datarequest') +@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 log in and create a datarequest') -def log_in_create_a_datarequest(context): - assert context.persona - context.execute_steps(u""" - When I log in and go to the data requests page - And I create a datarequest - """) - - -@step(u'I create a datarequest') -def create_datarequest(context): - - assert context.persona - context.execute_steps(u""" - When I go to the data requests page - And I click the link with text that contains "Add data request" - And I fill in title with random text - And I fill in "description" with "Test description" - And I press the element with xpath "//button[contains(@class, 'btn-primary')]" - """) - - -@step(u'I go to my reports page') -def go_to_reporting_page(context): - when_i_visit_url(context, '/dashboard/reporting') - - -@step(u'I go to dataset "{name}" comments') -def go_to_dataset_comments(context, name): - context.execute_steps(u""" - When I go to dataset "%s" - And I click the link with text that contains "Comments" - """ % (name)) - - -@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 click the link with text "%s" - Then I should see "%s" within 5 seconds - """ % (subject, subject)) - - -@step(u'I go to data request "{subject}" comments') -def go_to_data_request_comments(context, subject): - context.execute_steps(u""" - When I go to data request "%s" - And I click the link with text that contains "Comments" - """ % (subject)) - - -@step(u'I submit a comment with subject "{subject}" and comment "{comment}"') -def submit_comment_with_subject_and_comment(context, subject, comment): - """ - There can be multiple comment forms per page (add, edit, reply) each with fields named "subject" and "comment" - This step overcomes a limitation of the fill() method which only fills a form field by name - :param context: - :param subject: - :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();") - - -@step(u'I submit a reply with comment "{comment}"') -def submit_reply_with_comment(context, comment): - """ - There can be multiple comment forms per page (add, edit, reply) each with fields named "subject" and "comment" - This step overcomes a limitation of the fill() method which only fills a form field by name - :param context: - :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();") +@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}"') @@ -275,12 +192,13 @@ def create_dataset_titled(context, title): And I fill in "notes" with "Description" And I fill in "version" with "1.0" And I fill in "author_email" with "test@me.com" - And I select "NO" from "de_identified_data" + And I fill in "de_identified_data" with "NO" if present And I press "Add Data" And I execute the script "document.getElementById('field-image-url').value='https://example.com'" And I fill in "name" with "Test Resource" - And I select "HTML" from "format" + And I execute the script "document.getElementById('field-format').value='HTML'" And I fill in "description" with "Test Resource Description" + And I fill in "size" with "1024" if present And I press the element with xpath "//form[contains(@class, 'resource-form')]//button[contains(@class, 'btn-primary')]" """.format(title=title)) @@ -300,7 +218,7 @@ def create_dataset(context, license, file_format, file): And I fill in "version" with "1.0" And I fill in "author_email" with "test@me.com" And I execute the script "document.getElementById('field-license_id').value={license}" - Then I select "NO" from "de_identified_data" + Then I fill in "de_identified_data" with "NO" if present And I press "Add Data" And I attach the file {file} to "upload" And I fill in "name" with "Test Resource" @@ -310,10 +228,15 @@ def create_dataset(context, license, file_format, file): """.format(license=license, file=file, file_format=file_format)) -# The default behaving step does not convert base64 emails -# Modified the default step to decode the payload from base64 @step(u'I should receive a base64 email at "{address}" containing "{text}"') def should_receive_base64_email_containing_text(context, address, text): + should_receive_base64_email_containing_texts(context, address, text, None) + + +@step(u'I should receive a base64 email at "{address}" containing both "{text}" and "{text2}"') +def should_receive_base64_email_containing_texts(context, address, text, text2): + # The default behaving step does not convert base64 emails + # Modified the default step to decode the payload from base64 def filter_contents(mail): mail = email.message_from_string(mail) payload = mail.get_payload() @@ -323,7 +246,7 @@ def filter_contents(mail): payload_bytes += b'=' # do fix the padding error issue decoded_payload = payload_bytes.decode('base64') print('decoded_payload: ', decoded_payload) - return text in decoded_payload + return text in decoded_payload and (not text2 or text2 in decoded_payload) assert context.mail.user_messages(address, filter_contents) @@ -340,3 +263,182 @@ def log_in_go_to_admin_config(context): @step(u'I go to admin config page') def go_to_admin_config(context): when_i_visit_url(context, '/ckan-admin/config') + + +@step(u'I log out') +def log_out(context): + when_i_visit_url(context, '/user/logout') + + +# ckanext-data-qld + + +@step(u'I create resource_availability test data with title:"{title}" de_identified_data:"{de_identified_data}" resource_name:"{resource_name}" resource_visible:"{resource_visible}" governance_acknowledgement:"{governance_acknowledgement}"') +def create_dataset_resource_availability(context, title, de_identified_data, resource_name, resource_visible, governance_acknowledgement): + assert context.persona + context.execute_steps(u""" + When I go to "/dataset/new" + Then I fill in "title" with "{title}" + And I fill in "notes" with "test notes" + And I execute the script "{organisation_script}" + And I select "False" from "private" + And I fill in "version" with "1" + And I fill in "author_email" with "test@test.com" + And I select "{de_identified_data}" from "de_identified_data" + And I press the element with xpath "//form[contains(@class, 'dataset-form')]//button[contains(@class, 'btn-primary')]" + Then I wait for 1 seconds + And I execute the script "document.getElementById('field-image-url').value='https://example.com'" + And I fill in "name" with "{resource_name}" + And I fill in "description" with "test description" + And I select "{resource_visible}" from "resource_visible" + And I select "{governance_acknowledgement}" from "governance_acknowledgement" + And I execute the script "size_field = document.getElementById('field-size'); if (size_field) size_field.value = '1024';" + And I press the element with xpath "//button[@value='go-metadata']" + Then I wait for 1 seconds + and I should see "Data and Resources" + """.format(title=title, de_identified_data=de_identified_data, + organisation_script="document.getElementById('field-organizations').value=jQuery('#field-organizations option').filter(function () { return $(this).html() == 'Test Organisation'; }).attr('value')", + resource_name=resource_name, resource_visible=resource_visible, governance_acknowledgement=governance_acknowledgement)) + + +# ckanext-ytp-comments + + +@step(u'I go to dataset "{name}" comments') +def go_to_dataset_comments(context, name): + context.execute_steps(u""" + When I go to dataset "%s" + And I click the link with text that contains "Comments" + """ % (name)) + + +@step(u'I should see the add comment form') +def comment_form_visible(context): + context.execute_steps(u""" + Then I should see an element with xpath "//textarea[@name='comment']" + """) + + +@step(u'I should not see the add comment form') +def comment_form_not_visible(context): + context.execute_steps(u""" + Then I should not see an element with xpath "//input[@name='subject']" + And I should not see an element with xpath "//textarea[@name='comment']" + """) + + +@step(u'I submit a comment with subject "{subject}" and comment "{comment}"') +def submit_comment_with_subject_and_comment(context, subject, comment): + """ + There can be multiple comment forms per page (add, edit, reply) each with fields named "subject" and "comment" + This step overcomes a limitation of the fill() method which only fills a form field by name + :param context: + :param subject: + :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(); + """) + + +@step(u'I submit a reply with comment "{comment}"') +def submit_reply_with_comment(context, comment): + """ + There can be multiple comment forms per page (add, edit, reply) each with fields named "subject" and "comment" + This step overcomes a limitation of the fill() method which only fills a form field by name + :param context: + :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(); + """) + + +# ckanext-qgov + + +@step(u'I lock my account') +def lock_account(context): + when_i_visit_url(context, "/user/login") + for x in range(11): + attempt_login(context, "incorrect password") + + +# ckanext-datarequests + + +@step(u'I log in and go to the data requests page') +def log_in_go_to_datarequest_page(context): + assert context.persona + context.execute_steps(u""" + When I log in + And I go to the data requests page + """) + + +@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') + + +@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}" + 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') +def log_in_create_a_datarequest(context): + assert context.persona + context.execute_steps(u""" + When I log in and go to the data requests page + And I create a datarequest + """) + + +@step(u'I create a datarequest') +def create_datarequest(context): + + assert context.persona + context.execute_steps(u""" + When I go to the data requests page + And I click the link with text that contains "Add data request" + And I fill in title with random text + And I fill in "description" with "Test description" + And I press the element with xpath "//button[contains(@class, 'btn-primary')]" + """) + + +@step(u'I go to data request "{subject}" comments') +def go_to_data_request_comments(context, subject): + context.execute_steps(u""" + When I go to data request "%s" + And I click the link with text that contains "Comments" + """ % (subject)) + + +# ckanext-report + + +@step(u'I go to my reports page') +def go_to_reporting_page(context): + when_i_visit_url(context, '/dashboard/reporting') diff --git a/test/features/user_creation.feature b/test/features/user_creation.feature index 80104cf..e29db5b 100644 --- a/test/features/user_creation.feature +++ b/test/features/user_creation.feature @@ -9,7 +9,6 @@ Feature: User creation 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 @@ -23,9 +22,7 @@ Feature: User creation Then I should not see "The username cannot contain the word 'publisher'. Please enter another username." Then I should not see "The displayed name cannot contain certain words such as 'publisher', 'QLD Government' or similar. Please enter another display name." - Scenario: Non logged-in user register to the site. - Given "Unauthenticated" as the persona When I go to register page Then I should see an element with xpath "//input[@name='fullname']" And I should see "Displayed name" diff --git a/test/features/users.feature b/test/features/users.feature index 8e9ce14..dfe44d3 100644 --- a/test/features/users.feature +++ b/test/features/users.feature @@ -20,12 +20,13 @@ Feature: User APIs Then I should see an element with xpath "//body//div[contains(string(), 'Internal server error')]" And I should not see an element with xpath "//*[contains(string(), '"name": "admin"')]" + @unauthenticated Scenario: User autocomplete is not accessible anonymously + Given "Unauthenticated" as the persona When I search the autocomplete API for user "admin" Then I should see an element with xpath "//body//div[contains(string(), 'Internal server error')]" And I should not see an element with xpath "//*[contains(string(), '"name": "admin"')]" - Scenario Outline: User list is accessible to admins Given "" as the persona When I log in @@ -44,11 +45,12 @@ Feature: User APIs And I go to the user list API Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'Authorization Error')]" + @unauthenticated Scenario: User list is not accessible anonymously + Given "Unauthenticated" as the persona When I go to the user list API Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'requires an authenticated user')]" - Scenario Outline: User detail is accessible to admins Given "" as the persona When I log in @@ -73,10 +75,11 @@ Feature: User APIs And I go to the "admin" user API Then I should see an element with xpath "//*[contains(string(), '"success": false,') and contains(string(), 'Authorization Error')]" + @unauthenticated 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 @@ -102,18 +105,19 @@ Feature: User APIs And I go to the "admin" profile page Then I should see an element with xpath "//*[contains(string(), 'Not authorised to see this page')]" + @unauthenticated Scenario: User profile page is not accessible anonymously + Given "Unauthenticated" as the persona When I go to the "editor" profile page Then I should see an element with xpath "//*[contains(string(), 'Not authorised to see this page')]" - Scenario: Dashboard page is accessible to non-admins Given "Publisher" as the persona When I log in And I go to the dashboard Then I should see an element with xpath "//h2[contains(string(), 'News feed')]" - + @email Scenario: As a registered user, when I have locked my account with too many failed logins, I can reset my password to unlock it Given "Walker" as the persona When I lock my account @@ -133,7 +137,6 @@ Feature: User APIs And I press the element with xpath "//button[@class='btn btn-primary']" Then I log in - Scenario: Register user password must be 10 characters or longer and contain number, lowercase, capital, and symbol When I go to register page And I fill in "name" with "name" From 547e263d0fefc410b0a7e428cbe788780f924b19 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 8 Jul 2022 15:11:04 +1000 Subject: [PATCH 6/7] [QOL-9055] use 'six' to assist Py2 to 3 migration --- ckanext/harvester_data_qld_geoscience/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/harvester_data_qld_geoscience/plugin.py b/ckanext/harvester_data_qld_geoscience/plugin.py index 84a2a4f..5dbf451 100644 --- a/ckanext/harvester_data_qld_geoscience/plugin.py +++ b/ckanext/harvester_data_qld_geoscience/plugin.py @@ -1,7 +1,7 @@ import datetime import logging import six -import urllib +from six.moves.urllib.parse import urlencode import ckan.plugins as plugins import ckantoolkit as toolkit @@ -298,7 +298,7 @@ def _search_for_datasets(self, harvest_job, remote_ckan_base_url, fq_terms=None) pkg_ids = set() previous_content = None while True: - url = base_search_url + '?' + urllib.urlencode(params) + url = base_search_url + '?' + urlencode(params) log.debug('Searching for CKAN datasets: %s', url) try: content = self._get_content(url) From a973032680652a75518187e29697351d68160b91 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 8 Jul 2022 15:11:41 +1000 Subject: [PATCH 7/7] [QOL-9055] make relative imports explicit - Use . to mark relative imports. Newer Python insists on this. --- ckanext/harvester_data_qld_geoscience/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/harvester_data_qld_geoscience/plugin.py b/ckanext/harvester_data_qld_geoscience/plugin.py index 5dbf451..e860d5f 100644 --- a/ckanext/harvester_data_qld_geoscience/plugin.py +++ b/ckanext/harvester_data_qld_geoscience/plugin.py @@ -5,7 +5,7 @@ import ckan.plugins as plugins import ckantoolkit as toolkit -import helpers +from . import helpers from ckanext.harvest.harvesters.ckanharvester import CKANHarvester, ContentFetchError, SearchError from ckan.lib.helpers import json