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

fixes for running tests for MM_MODULES_DIR #3550

Merged
merged 1 commit into from
Sep 24, 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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
modules/*
!modules/default/
!modules/default/
js/positions.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _This release is scheduled to be released on 2024-10-01._
- [weather] Fixed issue for respecting unit config on broadcasted notifications
- [tests] Fixes calendar test by moving it from e2e to electron with fixed date (#3532)
- [calendar] fixed sliceMultiDayEvents getting wrong count and displaying incorrect entries, Europe/Berlin (#3542)
- [tests] ignore `js/positions.js` when linting (this file is created at runtime)

## [2.28.0] - 2024-07-01

Expand Down
10 changes: 9 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ function App () {
let moduleFolder = `${__dirname}/../${env.modulesDir}/${module}`;

if (defaultModules.includes(moduleName)) {
moduleFolder = `${__dirname}/../modules/default/${module}`;
const defaultModuleFolder = `${__dirname}/../modules/default/${module}`;
if (process.env.JEST_WORKER_ID === undefined) {
moduleFolder = defaultModuleFolder;
} else {
// running in Jest, allow defaultModules placed under moduleDir for testing
if (env.modulesDir === "modules") {
moduleFolder = defaultModuleFolder;
}
}
}

const moduleFile = `${moduleFolder}/${module}.js`;
Expand Down
10 changes: 9 additions & 1 deletion js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ const Loader = (function () {
let moduleFolder = `${envVars.modulesDir}/${module}`;

if (defaultModules.indexOf(moduleName) !== -1) {
moduleFolder = `modules/default/${module}`;
const defaultModuleFolder = `modules/default/${module}`;
if (window.name !== "jsdom") {
moduleFolder = defaultModuleFolder;
} else {
// running in Jest, allow defaultModules placed under moduleDir for testing
if (envVars.modulesDir === "modules") {
moduleFolder = defaultModuleFolder;
}
}
}

if (moduleData.disabled === true) {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/modules/newsfeed_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ describe("Newsfeed module", () => {
});

describe("Newsfeed module located in config directory", () => {
beforeAll(async () => {
beforeAll(() => {
const baseDir = `${__dirname}/../../..`;
if (!fs.existsSync(`${baseDir}/config/newsfeed`)) {
await fs.cp(`${baseDir}/modules/default/newsfeed`, `${baseDir}/config/newsfeed`, { recursive: true }, (err) => err && console.error(err));
fs.cpSync(`${baseDir}/modules/default/newsfeed`, `${baseDir}/config/newsfeed`, { recursive: true });
}
process.env.MM_MODULES_DIR = "config";
});
Expand Down