diff --git a/.ahoy.yml b/.ahoy.yml index 10a1745..eb633c7 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -12,7 +12,6 @@ commands: ahoy clean ahoy build-network ahoy up -- --build --force-recreate - ahoy install-site ahoy title "Build complete" ahoy doctor ahoy info 1 @@ -38,7 +37,9 @@ commands: cmd: | ahoy title "Building and starting Docker containers" sh bin/docker-compose.sh up -d "$@" - sleep 10 + echo "Initialising database schema" + ahoy cli '"${APP_DIR}"/bin/init.sh' + echo "Waiting for containers to start listening..." ahoy cli "dockerize -wait tcp://ckan:5000 -timeout 1m" if sh bin/docker-compose.sh logs | grep -q "\[Error\]"; then exit 1; fi if sh bin/docker-compose.sh logs | grep -q "Exception"; then exit 1; fi @@ -91,7 +92,7 @@ commands: usage: Install test site data. cmd: | ahoy title "Installing a fresh site" - ahoy cli '"${APP_DIR}"/bin/init.sh' + ahoy cli '"${APP_DIR}"/bin/init.sh && "${APP_DIR}"/bin/create-test-data.sh' clean: usage: Remove containers and all build files. @@ -144,7 +145,8 @@ commands: ahoy start-ckan-job-worker & ahoy start-mailmock & sleep 5 - ahoy cli "behave --junit -k ${*:-test/features} --tags=-format_autocomplete --junit-directory=test/junit/" || \ + JUNIT_OUTPUT="--junit --junit-directory=test/junit/" + ahoy cli "behave $JUNIT_OUTPUT -k ${*:-test/features} --tags=-format_autocomplete" || \ [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ] ahoy stop-mailmock ahoy stop-ckan-job-worker diff --git a/.env b/.env index 91896af..3314256 100644 --- a/.env +++ b/.env @@ -27,3 +27,4 @@ ALLOW_BDD_FAIL=0 # Disable amazeeio based health checks DOCTOR_CHECK_WEBSERVER=0 DOCTOR_CHECK_BOOTSTRAP=0 +DOCTOR_CHECK_PYGMY=0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab19f2c..51f6d40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,7 @@ jobs: run: echo HOME=/root >> "$GITHUB_ENV" - uses: actions/checkout@v4 + continue-on-error: ${{ matrix.experimental }} timeout-minutes: 2 - name: Build @@ -59,15 +60,18 @@ jobs: - name: Retrieve logs if: always() run: ahoy logs + continue-on-error: ${{ matrix.experimental }} timeout-minutes: 1 - name: Retrieve results if: always() run: bin/process-artifacts.sh + continue-on-error: ${{ matrix.experimental }} timeout-minutes: 1 - name: Test Summary uses: test-summary/action@v2 + continue-on-error: ${{ matrix.experimental }} with: paths: "/tmp/artifacts/junit/*.xml" if: always() @@ -75,6 +79,7 @@ jobs: - name: Upload screenshots if: always() uses: actions/upload-artifact@v4 + continue-on-error: ${{ matrix.experimental }} with: name: CKAN ${{ matrix.ckan-version }} screenshots path: /tmp/artifacts/behave/screenshots diff --git a/bin/create-test-data.sh b/bin/create-test-data.sh index 93f0efa..b188efe 100644 --- a/bin/create-test-data.sh +++ b/bin/create-test-data.sh @@ -19,6 +19,10 @@ add_user_if_needed () { password="${4:-Password123!}" } +api_call () { + wget -O - --header="Authorization: ${API_KEY}" --post-data "$1" ${CKAN_ACTION_URL}/$2 +} + add_user_if_needed "$CKAN_USER_NAME" "$CKAN_DISPLAY_NAME" "$CKAN_USER_EMAIL" ckan_cli sysadmin add "${CKAN_USER_NAME}" @@ -43,10 +47,6 @@ add_user_if_needed test_org_member "Test Member" test_org_member@localhost echo "Creating ${TEST_ORG_TITLE} organisation:" -api_call () { - wget -O - --header="Authorization: ${API_KEY}" --post-data "$1" ${CKAN_ACTION_URL}/$2 -} - TEST_ORG=$( \ api_call '{"name": "'"${TEST_ORG_NAME}"'", "title": "'"${TEST_ORG_TITLE}"'", "description": "Organisation for testing issues"}' organization_create diff --git a/bin/init.sh b/bin/init.sh index 52ecb15..5bdcc9b 100755 --- a/bin/init.sh +++ b/bin/init.sh @@ -12,6 +12,3 @@ ckan_cli db upgrade # Initialise report tables ckan_cli report initdb ckan_cli report generate tagless-datasets - -# Create some base test data -. "${APP_DIR}"/bin/create-test-data.sh diff --git a/test/features/steps/steps.py b/test/features/steps/steps.py index bbf14cc..a2a9907 100644 --- a/test/features/steps/steps.py +++ b/test/features/steps/steps.py @@ -99,7 +99,7 @@ def request_reset(context): @when(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}';" + When I execute the script "field = $('#{0}'); if (!field.length) field = $('[name={0}]'); if (!field.length) field = $('#field-{0}'); field.val('{1}'); field.keyup();" """.format(name, value)) @@ -119,10 +119,24 @@ def add_resource(context, name, url): @when(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(uuid.uuid4())) + When I fill in title with random text starting with "Test Title " + """) + + +@when(u'I fill in title with random text starting with "{prefix}"') +def title_random_text_with_prefix(context, prefix): + random_text = str(uuid.uuid4()) + title = prefix + random_text + name = prefix.lower().replace(" ", "-") + random_text + assert context.persona + context.execute_steps(f""" + When I fill in "title" with "{title}" + And I fill in "name" with "{name}" if present + And I set "last_generated_title" to "{title}" + And I set "last_generated_name" to "{name}" + And I take a debugging screenshot + """) @when(u'I go to dataset page') @@ -268,7 +282,7 @@ def go_to_admin_config(context): @when(u'I log out') def log_out(context): context.execute_steps(u""" - When I press the element with xpath "//*[@title='Log out']" + When I press the element with xpath "//*[@title='Log out' or @data-bs-title='Log out']" Then I should see "Log in" """)