mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
## [2.27.0] - 2024-04-01 Thanks to: @bugsounet, @crazyscot, @illimarkangur, @jkriegshauser, @khassel, @KristjanESPERANTO, @Paranoid93, @rejas, @sdetweil and @vppencilsharpener. This release marks the first release without Michael Teeuw (@michmich). A very special thanks to him for creating MagicMirror and leading the project for so many years. For more info, please read the following post: [A New Chapter for MagicMirror: The Community Takes the Lead](https://forum.magicmirror.builders/topic/18329/a-new-chapter-for-magicmirror-the-community-takes-the-lead). ### Added - Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64 (#3349) - [chore] Add `eslint-plugin-package-json` to lint the `package.json` files (#3368) - [weather] `showHumidity` config is now a string describing where to show this element. Supported values: "wind", "temp", "feelslike", "below", "none". (#3330) - electron-rebuild test suite for electron and 3rd party modules compatibility (#3392) - Create MM² icon and attach it to electron process (#3407) ### Updated - Update updatenotification (update_helper.js): Recode with pm2 library (#3332) - Removing lodash dependency by replacing merge by spread operator (#3339) - Use node prefix for build-in modules (#3340) - Rework logging colors (#3350) - Update pm2 to v5.3.1 with no allow-ghsas (#3364) - [chore] Update husky and let lint-staged fix ESLint issues - [chore] Update dependencies including electron to v29 (#3357) and node-ical - Update translations for estonian (#3371) - Update electron to v29 and update other dependencies - [calendar] fullDay events over several days now show the left days from the first day on and 'today' on the last day - Update layout of current weather indoor values ### Fixed - Correct apibase of weathergov weatherprovider to match documentation (#2926) - Worked around several issues in the RRULE library that were causing deleted calender events to still show, some initial and recurring events to not show, and some event times to be off an hour. (#3291) - Skip changelog requirement when running tests for dependency updates (#3320) - Display precipitation probability when it is 0% instead of blank/empty (#3345) - [newsfeed] Suppress unsightly animation cases when there are 0 or 1 active news items (#3336) - [newsfeed] Always compute the feed item URL using the same helper function (#3336) - Ignore all custom css files (#3359) - [newsfeed] Fix newsfeed stall issue introduced by #3336 (#3361) - Changed `log.debug` to `log.log` in `app.js` where logLevel is not set because config is not loaded at this time (#3353) - [calendar] deny fetch interval < 60000 and set 60000 in this case (prevent fetch loop failed) (#3382) - added message in case where config.js is missing the module.export line PR #3383 - Fixed an issue where recurring events could extend past their recurrence end date (#3393) - Don't display any `npm WARN <....>` on install (#3399) - Fixed move suncalc dependency to production from dev, as it is used by clock module - [compliments] Fix mirror not responding anymore when no compliments are to be shown (#3385) ### Deleted - Unneeded file headers (#3358) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Michael Teeuw <michael@xonaymedia.nl> Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Karsten Hassel <hassel@gmx.de> Co-authored-by: Ross Younger <crazyscot@gmail.com> Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr> Co-authored-by: jkriegshauser <joshuakr@nvidia.com> Co-authored-by: illimarkangur <116028111+illimarkangur@users.noreply.github.com> Co-authored-by: sam detweiler <sdetweil@gmail.com> Co-authored-by: vppencilsharpener <tim.pray@gmail.com> Co-authored-by: Paranoid93 <6515818+Paranoid93@users.noreply.github.com>
254 lines
8.6 KiB
JavaScript
254 lines
8.6 KiB
JavaScript
jest.mock("node:util", () => ({
|
|
...jest.requireActual("util"),
|
|
promisify: jest.fn()
|
|
}));
|
|
|
|
jest.mock("node:fs", () => ({
|
|
...jest.requireActual("fs"),
|
|
statSync: jest.fn()
|
|
}));
|
|
|
|
jest.mock("logger", () => ({
|
|
...jest.requireActual("logger"),
|
|
error: jest.fn(),
|
|
info: jest.fn()
|
|
}));
|
|
|
|
describe("Updatenotification", () => {
|
|
const execMock = jest.fn();
|
|
|
|
let gitHelper;
|
|
|
|
let gitRemoteOut;
|
|
let gitRevParseOut;
|
|
let gitStatusOut;
|
|
let gitFetchOut;
|
|
let gitRevListCountOut;
|
|
let gitRevListOut;
|
|
let gitFetchErr;
|
|
let gitTagListOut;
|
|
|
|
beforeAll(async () => {
|
|
const { promisify } = require("node:util");
|
|
promisify.mockReturnValue(execMock);
|
|
|
|
const GitHelper = require("../../../modules/default/updatenotification/git_helper");
|
|
gitHelper = new GitHelper();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
gitRemoteOut = "";
|
|
gitRevParseOut = "";
|
|
gitStatusOut = "";
|
|
gitFetchOut = "";
|
|
gitRevListCountOut = "";
|
|
gitRevListOut = "";
|
|
gitFetchErr = "";
|
|
gitTagListOut = "";
|
|
|
|
execMock.mockImplementation((command) => {
|
|
if (command.includes("git remote -v")) {
|
|
return { stdout: gitRemoteOut };
|
|
} else if (command.includes("git rev-parse HEAD")) {
|
|
return { stdout: gitRevParseOut };
|
|
} else if (command.includes("git status -sb")) {
|
|
return { stdout: gitStatusOut };
|
|
} else if (command.includes("git fetch -n --dry-run")) {
|
|
return { stdout: gitFetchOut, stderr: gitFetchErr };
|
|
} else if (command.includes("git rev-list --ancestry-path --count")) {
|
|
return { stdout: gitRevListCountOut };
|
|
} else if (command.includes("git rev-list --ancestry-path")) {
|
|
return { stdout: gitRevListOut };
|
|
} else if (command.includes("git ls-remote -q --tags --refs")) {
|
|
return { stdout: gitTagListOut };
|
|
}
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
gitHelper.gitRepos = [];
|
|
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
describe("MagicMirror on develop", () => {
|
|
const moduleName = "MagicMirror";
|
|
|
|
beforeEach(async () => {
|
|
gitRemoteOut = "origin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (fetch)\norigin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (push)\n";
|
|
gitRevParseOut = "332e429a41f1a2339afd4f0ae96dd125da6beada";
|
|
gitStatusOut = "## develop...origin/develop\n M tests/unit/functions/updatenotification_spec.js\n";
|
|
gitFetchErr = "From github.com:MagicMirrorOrg/MagicMirror\n60e0377..332e429 develop -> origin/develop\n";
|
|
gitRevListCountOut = "5";
|
|
|
|
await gitHelper.add(moduleName);
|
|
});
|
|
|
|
it("returns status information", async () => {
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(5);
|
|
});
|
|
|
|
it("returns status information early if isBehindInStatus", async () => {
|
|
gitStatusOut = "## develop...origin/develop [behind 5]";
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(3);
|
|
});
|
|
|
|
it("excludes repo if status can't be retrieved", async () => {
|
|
const errorMessage = "Failed to retrieve status";
|
|
execMock.mockRejectedValueOnce(errorMessage);
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos).toHaveLength(0);
|
|
|
|
const { error } = require("logger");
|
|
expect(error).toHaveBeenCalledWith(`Failed to retrieve repo info for ${moduleName}: Failed to retrieve status`);
|
|
});
|
|
});
|
|
|
|
describe("MagicMirror on master (empty taglist)", () => {
|
|
const moduleName = "MagicMirror";
|
|
|
|
beforeEach(async () => {
|
|
gitRemoteOut = "origin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (fetch)\norigin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (push)\n";
|
|
gitRevParseOut = "332e429a41f1a2339afd4f0ae96dd125da6beada";
|
|
gitStatusOut = "## master...origin/master\n M tests/unit/functions/updatenotification_spec.js\n";
|
|
gitFetchErr = "From github.com:MagicMirrorOrg/MagicMirror\n60e0377..332e429 master -> origin/master\n";
|
|
gitRevListCountOut = "5";
|
|
|
|
await gitHelper.add(moduleName);
|
|
});
|
|
|
|
it("returns status information", async () => {
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("returns status information early if isBehindInStatus", async () => {
|
|
gitStatusOut = "## master...origin/master [behind 5]";
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("excludes repo if status can't be retrieved", async () => {
|
|
const errorMessage = "Failed to retrieve status";
|
|
execMock.mockRejectedValueOnce(errorMessage);
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos).toHaveLength(0);
|
|
|
|
const { error } = require("logger");
|
|
expect(error).toHaveBeenCalledWith(`Failed to retrieve repo info for ${moduleName}: Failed to retrieve status`);
|
|
});
|
|
});
|
|
|
|
describe("MagicMirror on master with match in taglist", () => {
|
|
const moduleName = "MagicMirror";
|
|
|
|
beforeEach(async () => {
|
|
gitRemoteOut = "origin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (fetch)\norigin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (push)\n";
|
|
gitRevParseOut = "332e429a41f1a2339afd4f0ae96dd125da6beada";
|
|
gitStatusOut = "## master...origin/master\n M tests/unit/functions/updatenotification_spec.js\n";
|
|
gitFetchErr = "From github.com:MagicMirrorOrg/MagicMirror\n60e0377..332e429 master -> origin/master\n";
|
|
gitRevListCountOut = "5";
|
|
gitTagListOut = "332e429a41f1a2339afd4f0ae96dd125da6beada...tag...\n";
|
|
gitRevListOut = "332e429a41f1a2339afd4f0ae96dd125da6beada\n";
|
|
|
|
await gitHelper.add(moduleName);
|
|
});
|
|
|
|
it("returns status information", async () => {
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("returns status information early if isBehindInStatus", async () => {
|
|
gitStatusOut = "## master...origin/master [behind 5]";
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("excludes repo if status can't be retrieved", async () => {
|
|
const errorMessage = "Failed to retrieve status";
|
|
execMock.mockRejectedValueOnce(errorMessage);
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos).toHaveLength(0);
|
|
|
|
const { error } = require("logger");
|
|
expect(error).toHaveBeenCalledWith(`Failed to retrieve repo info for ${moduleName}: Failed to retrieve status`);
|
|
});
|
|
});
|
|
|
|
describe("MagicMirror on master without match in taglist", () => {
|
|
const moduleName = "MagicMirror";
|
|
|
|
beforeEach(async () => {
|
|
gitRemoteOut = "origin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (fetch)\norigin\tgit@github.com:MagicMirrorOrg/MagicMirror.git (push)\n";
|
|
gitRevParseOut = "332e429a41f1a2339afd4f0ae96dd125da6beada";
|
|
gitStatusOut = "## master...origin/master\n M tests/unit/functions/updatenotification_spec.js\n";
|
|
gitFetchErr = "From github.com:MagicMirrorOrg/MagicMirror\n60e0377..332e429 master -> origin/master\n";
|
|
gitRevListCountOut = "5";
|
|
gitTagListOut = "xxxe429a41f1a2339afd4f0ae96dd125da6beada...tag...\n";
|
|
gitRevListOut = "332e429a41f1a2339afd4f0ae96dd125da6beada\n";
|
|
|
|
await gitHelper.add(moduleName);
|
|
});
|
|
|
|
it("returns status information", async () => {
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("returns status information early if isBehindInStatus", async () => {
|
|
gitStatusOut = "## master...origin/master [behind 5]";
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(7);
|
|
});
|
|
|
|
it("excludes repo if status can't be retrieved", async () => {
|
|
const errorMessage = "Failed to retrieve status";
|
|
execMock.mockRejectedValueOnce(errorMessage);
|
|
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos).toHaveLength(0);
|
|
|
|
const { error } = require("logger");
|
|
expect(error).toHaveBeenCalledWith(`Failed to retrieve repo info for ${moduleName}: Failed to retrieve status`);
|
|
});
|
|
});
|
|
|
|
describe("custom module", () => {
|
|
const moduleName = "MMM-Fuel";
|
|
|
|
beforeEach(async () => {
|
|
gitRemoteOut = `origin\thttps://github.com/fewieden/${moduleName}.git (fetch)\norigin\thttps://github.com/fewieden/${moduleName}.git (push)\n`;
|
|
gitRevParseOut = "9d8310163da94441073a93cead711ba43e8888d0";
|
|
gitStatusOut = "## master...origin/master";
|
|
gitFetchErr = `From https://github.com/fewieden/${moduleName}\n19f7faf..9d83101 master -> origin/master`;
|
|
gitRevListCountOut = "7";
|
|
|
|
await gitHelper.add(moduleName);
|
|
});
|
|
|
|
it("returns status information without hash", async () => {
|
|
const repos = await gitHelper.getRepos();
|
|
expect(repos[0]).toMatchSnapshot();
|
|
expect(execMock).toHaveBeenCalledTimes(4);
|
|
});
|
|
});
|
|
});
|