Преглед изворни кода

Allow debugging for web acceptance tests (#28883)

* adding debug option for web acceptance tests

fix: improving acceptance debug make target and removing duplicate service from docker-compose

* Switching debug mode to use DEBUG=true in test command

---------

Co-authored-by: Liam O'Brien <l.obrien@digital-science.com>
GitOrigin-RevId: 42a2ef53db08eccbf2a52f829a2fb7af997f911e
Jimmy Domagala-Tang пре 5 месеци
родитељ
комит
a7b4fdde9c
3 измењених фајлова са 20 додато и 2 уклоњено
  1. 9 1
      services/web/Makefile
  2. 9 1
      services/web/Makefile.module
  3. 2 0
      services/web/package.json

+ 9 - 1
services/web/Makefile

@@ -235,6 +235,14 @@ TEST_ACCEPTANCE_APP :=  \
 	test_acceptance_app_server_ce \
 	test_acceptance_app_server_pro \
 
+ifeq ($(DEBUG),true)
+TEST_ACCEPTANCE_DEBUG_PORT := -p 127.0.0.1:19999:19999
+TEST_ACCEPTANCE_NPM_SCRIPT := npm run --silent test:acceptance:app:debug
+else
+TEST_ACCEPTANCE_DEBUG_PORT :=
+TEST_ACCEPTANCE_NPM_SCRIPT := npm run --silent test:acceptance:app
+endif
+
 test_acceptance_app: $(TEST_ACCEPTANCE_APP)
 test_acceptance_app_saas: export JUNIT_ROOT_SUITE_NAME = SaaS app acceptance tests
 test_acceptance_app_saas: export COMPOSE_PROJECT_NAME=acceptance_test_saas_$(BUILD_DIR_NAME)
@@ -247,7 +255,7 @@ test_acceptance_app_server_pro: export COMPOSE_PROJECT_NAME=acceptance_test_serv
 test_acceptance_app_server_pro: export OVERLEAF_CONFIG=$(CFG_SERVER_PRO)
 
 $(TEST_ACCEPTANCE_APP):
-	$(DOCKER_COMPOSE) run --rm test_acceptance
+	$(DOCKER_COMPOSE) run --rm $(TEST_ACCEPTANCE_DEBUG_PORT) test_acceptance $(TEST_ACCEPTANCE_NPM_SCRIPT)
 	$(DOCKER_COMPOSE) down -v -t 0
 
 # We are using _make magic_ for turning these file-targets into calls to

+ 9 - 1
services/web/Makefile.module

@@ -46,6 +46,14 @@ $(ALL_TEST_ACCEPTANCE_VARIANTS) test_acceptance_merged_inner:
 clean_test_acceptance:
 
 else
+ifeq ($(DEBUG),true)
+TEST_ACCEPTANCE_DEBUG_PORT := -p 127.0.0.1:19999:19999
+TEST_ACCEPTANCE_NPM_SCRIPT := test:acceptance:debug:run_dir
+else
+TEST_ACCEPTANCE_DEBUG_PORT :=
+TEST_ACCEPTANCE_NPM_SCRIPT := test:acceptance:run_dir
+endif
+
 test_acceptance_saas: export BASE_CONFIG = $(CFG_SAAS)
 test_acceptance_server_ce: export BASE_CONFIG = $(CFG_SERVER_CE)
 test_acceptance_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO)
@@ -53,7 +61,7 @@ test_acceptance_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO)
 $(ALL_TEST_ACCEPTANCE_VARIANTS): export COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME)
 $(ALL_TEST_ACCEPTANCE_VARIANTS):
 	$(MAKE) --no-print-directory clean_test_acceptance
-	${DOCKER_COMPOSE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
+	${DOCKER_COMPOSE} run --rm $(TEST_ACCEPTANCE_DEBUG_PORT) test_acceptance npm -q run $(TEST_ACCEPTANCE_NPM_SCRIPT) -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
 	$(MAKE) --no-print-directory clean_test_acceptance
 
 test_acceptance_merged_inner:

+ 2 - 0
services/web/package.json

@@ -9,6 +9,8 @@
   "scripts": {
     "test:acceptance:run_dir": "bin/test_acceptance_run_dir",
     "test:acceptance:app": "npm run test:acceptance:run_dir -- test/acceptance/src",
+    "test:acceptance:app:debug": "npm run test:acceptance:debug:run_dir -- test/acceptance/src",
+    "test:acceptance:debug:run_dir": "mocha --recursive --timeout 25000 --grep=$MOCHA_GREP --require test/acceptance/bootstrap.js --inspect=0.0.0.0:19999 --inspect-brk",
     "test:unit:run_dir": "bin/test_unit_run_dir",
     "test:unit:all": "npm run test:unit:run_dir -- test/unit/src modules/*/test/unit/src",
     "test:unit:all:silent": "npm run test:unit:all -- --reporter dot",