From 9e716fb926007599ebc0b472d47e32591946e44c Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Wed, 31 Jan 2024 14:14:28 +1000 Subject: [PATCH 1/4] [QOLCHG-440] clean up scenario test syntax - Add title to test step - Fix Behave keyword --- .ahoy.yml | 6 ++++-- test/features/datarequest_circumstances.feature | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.ahoy.yml b/.ahoy.yml index 0e01a69..250f46d 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -66,7 +66,9 @@ commands: logs: usage: Show Docker logs. - cmd: sh bin/docker-compose.sh logs "$@" + cmd: | + ahoy title "Output logs" + sh bin/docker-compose.sh logs "$@" pull: usage: Pull latest docker images. @@ -142,7 +144,7 @@ commands: ahoy cli "rm -f test/screenshots/*" ahoy start-ckan-job-worker ahoy start-mailmock & - sleep 5 && + sleep 5 if [ "$BEHAVE_TAG" = "" ]; then (ahoy cli "behave -k ${*:-test/features} --tags=smoke" \ && ahoy cli "behave -k ${*:-test/features} --tags=-smoke" \ diff --git a/test/features/datarequest_circumstances.feature b/test/features/datarequest_circumstances.feature index e04146b..e956f79 100644 --- a/test/features/datarequest_circumstances.feature +++ b/test/features/datarequest_circumstances.feature @@ -129,7 +129,7 @@ Feature: Datarequest-circumstances And I wait for 1 seconds And I take a debugging 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 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' and contains(string(), 'Close Data Request')]" Then I should see "Accepted dataset" within 1 seconds And I should see "A Wonderful Story" within 1 seconds From 51316fe412d1079c3787a1adae150757c1ef8ae8 Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Wed, 31 Jan 2024 14:15:10 +1000 Subject: [PATCH 2/4] [QOLCHG-440] enable activity plugin during scenario tests so we can test integration - This plugin alters templates that affect activity streams, like the organisation read_base, so we should include activity streams in testing --- .ahoy.yml | 2 +- bin/init-ext.sh | 1 + bin/process-config.sh | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 bin/process-config.sh diff --git a/.ahoy.yml b/.ahoy.yml index 250f46d..03814e3 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -128,7 +128,7 @@ commands: cmd: | docker cp . $(sh bin/docker-compose.sh ps -q ckan):/srv/app/ docker cp bin/ckan_cli $(sh bin/docker-compose.sh ps -q ckan):/usr/bin/ - ahoy cli 'chmod -v u+x /usr/bin/ckan_cli $APP_DIR/bin/*; cp -v .docker/test.ini $CKAN_INI' + ahoy cli 'chmod -v u+x /usr/bin/ckan_cli $APP_DIR/bin/*; cp -v .docker/test.ini $CKAN_INI; $APP_DIR/bin/process-config.sh' test-unit: usage: Run unit tests. diff --git a/bin/init-ext.sh b/bin/init-ext.sh index 20b0a63..21107d3 100755 --- a/bin/init-ext.sh +++ b/bin/init-ext.sh @@ -44,4 +44,5 @@ installed_name=$(grep '^\s*name=' setup.py |sed "s|[^']*'\([-a-zA-Z0-9]*\)'.*|\1 # Validate that the extension was installed correctly. if ! pip list | grep "$installed_name" > /dev/null; then echo "Unable to find the extension in the list"; exit 1; fi +. $APP_DIR/bin/process-config.sh . ${APP_DIR}/bin/deactivate diff --git a/bin/process-config.sh b/bin/process-config.sh new file mode 100644 index 0000000..ba807fc --- /dev/null +++ b/bin/process-config.sh @@ -0,0 +1,4 @@ +if [ -d "$SRC_DIR/ckan/ckanext/activity" ]; then + sed -i 's|^ckan.plugins =|ckan.plugins = activity|' $CKAN_INI .docker/test*.ini +fi + From 8f8a89a6a2719a43fc61310836f039a56f503eba Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Wed, 31 Jan 2024 14:15:31 +1000 Subject: [PATCH 3/4] [QOLCHG-440] add scenario test to ensure organisation is accessible --- test/features/organisations.feature | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/features/organisations.feature diff --git a/test/features/organisations.feature b/test/features/organisations.feature new file mode 100644 index 0000000..679c4dd --- /dev/null +++ b/test/features/organisations.feature @@ -0,0 +1,17 @@ +@users +Feature: Organization APIs + + @unauthenticated + Scenario: Organisation overview is accessible to everyone + Given "Unauthenticated" as the persona + When I go to organisation page + Then I should see "Test Organisation" + 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/test-organisation')]" + When I press "Test Organisation" + And I press "Activity Stream" + Then I should see "created the organization" + + When I view the "test-organisation" organisation API "not including" users + Then I should see an element with xpath "//*[contains(string(), '"success": true') and contains(string(), '"name": "test-organisation"')]" + From 2e174ff8df00db1c4dca3ef5b36a34dad18a83ba Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Wed, 31 Jan 2024 14:16:04 +1000 Subject: [PATCH 4/4] [QOLCHG-440] fix organisation pages for CKAN 2.10 --- ckanext/datarequests/templates/organization/read_base.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/datarequests/templates/organization/read_base.html b/ckanext/datarequests/templates/organization/read_base.html index a572147..13ae84c 100644 --- a/ckanext/datarequests/templates/organization/read_base.html +++ b/ckanext/datarequests/templates/organization/read_base.html @@ -2,5 +2,6 @@ {% block content_primary_nav %} {{ super() }} - {{ h.build_nav_icon('datarequest.organization', _('Data Requests'), id=c.group_dict.name, icon=h.get_question_icon())}} + {% set group_dict = group_dict or c.group_dict %} + {{ h.build_nav_icon('datarequest.organization', _('Data Requests'), id=group_dict.name, icon=h.get_question_icon())}} {% endblock %}