# WARNING: Please DO NOT edit this file! It is maintained in the Repository Template (https://github.com/nhs-england-tools/repository-template). Raise a PR instead.

# The test types listed here are both those which might run both locally and in CI, or
# in one but not the other.  All of the test types listed at
# https://github.com/NHSDigital/software-engineering-quality-framework/blob/main/quality-checks.md
# should be represented here with the exception of:
#   - dependency scanning, which we expect to be applied at the repository level
#   - secret scanning, which we expect to be a pre-commit hook
#   - code review, which is outside the scope of automated testing for the moment

test-unit: # Run your unit tests from scripts/test/unit @Testing
	make _test name="unit"

test-lint: # Lint your code from scripts/test/lint @Testing
	make _test name="lint"

test-coverage: # Evaluate code coverage from scripts/test/coverage @Testing
	make _test name="coverage"

test-accessibility: # Run your accessibility tests from scripts/test/accessibility @Testing
	make _test name="accessibility"

test-contract: # Run your contract tests from scripts/test/contract @Testing
	make _test name="contract"

test-integration: # Run your integration tests from scripts/test/integration @Testing
	make _test name="integration"

test-load: # Run all your load tests @Testing
	make \
		test-capacity \
		test-soak \
		test-response-time
		# You may wish to add more here, depending on your app

test-capacity: # Test what load level your app fails at from scripts/test/capacity @Testing
	make _test name="capacity"

test-soak: # Test that resources don't get exhausted over time from scripts/test/soak @Testing
	make _test name="soak"

test-response-time: # Test your API response times from scripts/test/response-time @Testing
	make _test name="response-time"

test-security: # Run your security tests from scripts/test/security @Testing
	make _test name="security"

test-ui: # Run your UI tests from scripts/test/ui @Testing
	make _test name="ui"

test-ui-performance: # Run UI render tests from scripts/test/ui-performance @Testing
	make _test name="ui-performance"

test: # Run all the test tasks @Testing
	make \
		test-unit \
		test-lint \
		test-coverage \
		test-contract \
		test-security \
		test-ui \
		test-ui-performance \
		test-integration \
		test-accessibility \
		test-load

_test:
	set -e
	script="./scripts/tests/${name}.sh"
	if [ -e "$${script}" ]; then
		exec $${script}
	else
		echo "make test-${name} not implemented: $${script} not found" >&2
	fi

${VERBOSE}.SILENT: \
	_test \
	test \
	test-accessibility \
	test-capacity \
	test-contract \
	test-coverage \
	test-soak \
	test-integration \
	test-lint \
	test-load \
	test-response-time \
	test-security \
	test-ui \
	test-ui-performance \
	test-unit \
