-
Notifications
You must be signed in to change notification settings - Fork 8.6k
DEV: Only load specific plugin bundles during qunit test #33678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -60,7 +60,7 @@ document.addEventListener("discourse-init", () => { | |||
} | |||
|
|||
const isPlugin = name.match(/\/plugins\//); | |||
const isTheme = name.match(/\/theme-\d+\//); | |||
const isTheme = name.match(/\/theme--?\d+\//); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to account for the new system themes, which have negative IDs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already on main
btw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice! Will rebase to be 100% sure there aren't any conflicts with those changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! 🔥
@@ -60,7 +60,7 @@ document.addEventListener("discourse-init", () => { | |||
} | |||
|
|||
const isPlugin = name.match(/\/plugins\//); | |||
const isTheme = name.match(/\/theme-\d+\//); | |||
const isTheme = name.match(/\/theme--?\d+\//); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already on main
btw
@@ -213,6 +215,16 @@ export default function setupTests(config) { | |||
QUnit.config.hidepassed = true; | |||
QUnit.config.testTimeout = 60_000; | |||
|
|||
window.onunhandledrejection = (event) => { | |||
// reports test boot failures to testem, so the browser doesn't hang forever |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, we didn't have that before? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this explains why we sometimes get those CI jobs which hang forever instead of failing cleanly. (e.g. if there's an import of a non-existent module)
@@ -1,6 +1,9 @@ | |||
# frozen_string_literal: true | |||
|
|||
class QunitController < ApplicationController | |||
# Same list maintained in discourse-test-load-dynamic-js.js | |||
ALWAYS_LOADED_PLUGINS = %w[discourse-local-dates] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in the end only d-local-dates is widely needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, and it's the only core plugin with no 'enabled_setting'
8909daa
to
8b957e5
Compare
Previously, running qunit tests for a plugin would load the JS of all installed plugins. This can be problematic because, depending on the plugins installed in the current environment, there can be unexpected interactions between the plugins.
This commit updates our qunit system to check the
tests.requiredPlugins
list from the theme/pluginabout.json
file, and only loads the listed plugins. This means that the environment is much more consistent across CI and different development environments.Alongside that change, this commit also:
Starts storing the original
about.json
for themes in the databaseImproves qunit error handling when the test environment fails to boot (e.g. there's a bad import in a plugin)
Restores plugin CSS in theme qunit tests