From 072faa08bb20c159ee115dee2985395c91a1a92f Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 25 May 2022 14:43:49 +0800 Subject: [PATCH] DEV: Reenable wizard test after fixing auto start for wizard qunit tests `run-qunit.js` does not expect QUnit tests to start automatically but our wizard QUnit setup did not respect the `qunit_disable_auto_start` URL param. Hence, tests would start running automatically and when a subsequent `QUnit.start()` function call is made, we ended up getting a `QUnit.start cannot be called inside a test context.` error. This error can be consistently reproduced in the `discourse:discourse_test` container but not in the local development environment. I do not know why and did not feel like it is important at this point in time to know why. --- .github/workflows/tests.yml | 9 ++++----- app/assets/javascripts/wizard/test/test_helper.js | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93bf56d8f5..6ab6fa2dfc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -158,11 +158,10 @@ jobs: run: QUNIT_EMBER_CLI=0 bin/rake qunit:test['1200000'] timeout-minutes: 30 - # Wizard tests are failing so disabled for now while we investigate - # - name: Wizard QUnit (Legacy) - # if: matrix.build_type == 'frontend-legacy' && matrix.target == 'core' - # run: QUNIT_EMBER_CLI=0 bin/rake qunit:test['600000','/wizard/qunit'] - # timeout-minutes: 10 + - name: Wizard QUnit (Legacy) + if: matrix.build_type == 'frontend-legacy' && matrix.target == 'core' + run: QUNIT_EMBER_CLI=0 bin/rake qunit:test['600000','/wizard/qunit'] + timeout-minutes: 10 - name: Plugin QUnit (Legacy) if: matrix.build_type == 'frontend-legacy' && matrix.target == 'plugins' diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js index 9194035e88..39ed80b0dd 100644 --- a/app/assets/javascripts/wizard/test/test_helper.js +++ b/app/assets/javascripts/wizard/test/test_helper.js @@ -50,6 +50,13 @@ let createPretendServer = requirejs( ).default; let server; + +const queryParams = new URLSearchParams(window.location.search); + +if (queryParams.get("qunit_disable_auto_start") === "1") { + QUnit.config.autostart = false; +} + QUnit.testStart(function () { server = createPretendServer(); });