Fix calendar test

This commit is contained in:
rejas 2021-05-02 14:43:12 +02:00 committed by veeck
parent 4c8508b0a9
commit bdfd6e5e9f
5 changed files with 7 additions and 2 deletions

View File

@ -126,6 +126,8 @@ NodeHelper.checkFetchError = function (error) {
let error_type = "MODULE_ERROR_UNSPECIFIED";
if (error.code === "EAI_AGAIN") {
error_type = "MODULE_ERROR_NO_CONNECTION";
} else if (error.message === "Unauthorized") {
error_type = "MODULE_ERROR_UNAUTHORIZED";
}
return error_type;
};

View File

@ -147,7 +147,8 @@ Module.register("calendar", {
}
}
} else if (notification === "CALENDAR_ERROR") {
this.error = this.translate("MODULE_CONFIG_ERROR", { MODULE_NAME: this.name, ERROR: payload.error });
let error_message = this.translate(payload.error_type);
this.error = this.translate("MODULE_CONFIG_ERROR", { MODULE_NAME: this.name, ERROR: error_message });
this.loaded = true;
}

View File

@ -58,6 +58,7 @@ module.exports = NodeHelper.create({
Log.error("Calendar Error. Could not fetch calendar: ", fetcher.url(), error);
let error_type = NodeHelper.checkFetchError(error);
this.sendSocketNotification("CALENDAR_ERROR", {
id: identifier,
error_type
});
});

View File

@ -150,7 +150,7 @@ describe("Calendar module", function () {
});
it("should show Unauthorized error", function () {
return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Unauthorized", 10000);
return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Authorization failed", 10000);
});
});
});

View File

@ -32,6 +32,7 @@
"MODULE_CONFIG_ERROR": "Error in the {MODULE_NAME} module. {ERROR}",
"MODULE_ERROR_MALFORMED_URL": "Malformed url.",
"MODULE_ERROR_NO_CONNECTION": "No internet connection.",
"MODULE_ERROR_UNAUTHORIZED": "Authorization failed.",
"MODULE_ERROR_UNSPECIFIED": "Check logs for more details.",
"UPDATE_NOTIFICATION": "MagicMirror² update available.",