Skip to content
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

add support for test mode detection in modulename.js via index.html #3631

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _This release is scheduled to be released on 2025-01-01._
- [linter] re-added `eslint-plugin-import`now that it supports ESLint v9 (#3586)
- [docs] Added step for npm publishing in release process (#3595)
- [core] Add GitHub workflow to run spellcheck a few days before each release.
- [core] Add intest flag to index.html to pass to module js for test mode detection (needed by #3630)

### Removed

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<script type="text/javascript">
window.mmVersion = "#VERSION#";
window.mmTestMode = "#TESTMODE#";
</script>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { getEnvVarsAsObj } = require(`${__dirname}/server_functions`);

// Get version number.
global.version = require(`${__dirname}/../package.json`).version;
global.mmTestMode = process.env.mmTestMode === "true" ? true : false;
Log.log(`Starting MagicMirror: v${global.version}`);

// Log system information.
Expand Down
1 change: 1 addition & 0 deletions js/server_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function geExpectedReceivedHeaders (url) {
function getHtml (req, res) {
let html = fs.readFileSync(path.resolve(`${global.root_path}/index.html`), { encoding: "utf8" });
html = html.replace("#VERSION#", global.version);
html = html.replace("#TESTMODE#", global.mmTestMode);

let configFile = "config/config.js";
if (typeof global.configuration_file !== "undefined") {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/helpers/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports.startApplication = async (configFilename, exec) => {
} else {
process.env.MM_CONFIG_FILE = configFilename;
}
process.env.mmTestMode = "true";
if (exec) exec;
global.app = require("../../../js/app");

Expand Down
1 change: 1 addition & 0 deletions tests/electron/helpers/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
if (systemDate) {
process.env.MOCK_DATE = systemDate;
}
process.env.mmTestMode = "true";

global.electronApp = await electron.launch({ args: electronParams });

Expand Down