mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
move calendar tests from category electron
to e2e
This commit is contained in:
parent
e4a0a517d5
commit
1d12e57606
@ -13,6 +13,8 @@ _This release is scheduled to be released on 2022-01-01._
|
|||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
- Move calendar tests from category `electron` to `e2e`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
## [2.17.1] - 2021-10-01
|
## [2.17.1] - 2021-10-01
|
||||||
|
@ -114,8 +114,7 @@
|
|||||||
],
|
],
|
||||||
"testPathIgnorePatterns": [
|
"testPathIgnorePatterns": [
|
||||||
"<rootDir>/tests/electron/modules/mocks",
|
"<rootDir>/tests/electron/modules/mocks",
|
||||||
"<rootDir>/tests/electron/global-setup.js",
|
"<rootDir>/tests/electron/global-setup.js"
|
||||||
"<rootDir>/tests/electron/modules/basic-auth.js"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -131,7 +130,8 @@
|
|||||||
],
|
],
|
||||||
"testPathIgnorePatterns": [
|
"testPathIgnorePatterns": [
|
||||||
"<rootDir>/tests/e2e/global-setup.js",
|
"<rootDir>/tests/e2e/global-setup.js",
|
||||||
"<rootDir>/tests/e2e/mock-console.js"
|
"<rootDir>/tests/e2e/mock-console.js",
|
||||||
|
"<rootDir>/tests/e2e/modules/basic-auth.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -25,7 +25,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rejas
|
* By Rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -27,7 +27,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -22,7 +22,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* By Rejas
|
* By Rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@ -21,7 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @param {string} err The error message.
|
* @param {string} err The error message.
|
||||||
*/
|
*/
|
||||||
function mockError(err) {
|
function mockError(err) {
|
||||||
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) {
|
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined") || err.includes("write EPIPE")) {
|
||||||
jest.fn();
|
jest.fn();
|
||||||
} else {
|
} else {
|
||||||
console.dir(err);
|
console.dir(err);
|
||||||
|
139
tests/e2e/modules/calendar_spec.js
Normal file
139
tests/e2e/modules/calendar_spec.js
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
const helpers = require("../global-setup");
|
||||||
|
const serverBasicAuth = require("./basic-auth.js");
|
||||||
|
|
||||||
|
describe("Calendar module", function () {
|
||||||
|
/**
|
||||||
|
* @param {string} element css selector
|
||||||
|
* @param {string} result expected number
|
||||||
|
* @param {string} not reverse result
|
||||||
|
*/
|
||||||
|
function testElementLength(element, result, not) {
|
||||||
|
const elem = document.querySelectorAll(element);
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
if (not === "not") {
|
||||||
|
expect(elem.length).not.toBe(result);
|
||||||
|
} else {
|
||||||
|
expect(elem.length).toBe(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Default configuration", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/default.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the default maximumEntries of 10", () => {
|
||||||
|
testElementLength(".calendar .event", 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the default calendar symbol in each event", () => {
|
||||||
|
testElementLength(".calendar .event .fa-calendar", 0, "not");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Custom configuration", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the custom maximumEntries of 4", () => {
|
||||||
|
testElementLength(".calendar .event", 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the custom calendar symbol in each event", () => {
|
||||||
|
testElementLength(".calendar .event .fa-birthday-cake", 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show two custom icons for repeating events", () => {
|
||||||
|
testElementLength(".calendar .event .fa-undo", 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show two custom icons for day events", () => {
|
||||||
|
testElementLength(".calendar .event .fa-calendar-day", 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Recurring event", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the recurring birthday event 6 times", () => {
|
||||||
|
testElementLength(".calendar .event", 6);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Changed port", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
||||||
|
serverBasicAuth.listen(8010);
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(function (done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return TestEvents", function () {
|
||||||
|
testElementLength(".calendar .event", 0, "not");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Basic auth", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return TestEvents", function () {
|
||||||
|
testElementLength(".calendar .event", 0, "not");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Basic auth by default", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return TestEvents", function () {
|
||||||
|
testElementLength(".calendar .event", 0, "not");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return TestEvents", function () {
|
||||||
|
testElementLength(".calendar .event", 0, "not");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Fail Basic auth", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
||||||
|
serverBasicAuth.listen(8020);
|
||||||
|
helpers.getDocument(done, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(function (done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show Unauthorized error", function () {
|
||||||
|
const elem = document.querySelector(".calendar");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toContain("Error in the calendar module. Authorization failed");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,150 +0,0 @@
|
|||||||
const helpers = require("../global-setup");
|
|
||||||
const serverBasicAuth = require("./basic-auth.js");
|
|
||||||
|
|
||||||
describe("Calendar module", function () {
|
|
||||||
helpers.setupTimeout(this);
|
|
||||||
|
|
||||||
let app = null;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
return helpers
|
|
||||||
.startApplication({
|
|
||||||
args: ["js/electron.js"]
|
|
||||||
})
|
|
||||||
.then(function (startedApp) {
|
|
||||||
app = startedApp;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
return helpers.stopApplication(app);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Default configuration", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the default maximumEntries of 10", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
const events = await app.client.$$(".calendar .event");
|
|
||||||
return expect(events.length).toBe(10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the default calendar symbol in each event", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
const icons = await app.client.$$(".calendar .event .fa-calendar");
|
|
||||||
return expect(icons.length).not.toBe(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Custom configuration", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/custom.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the custom maximumEntries of 4", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
const events = await app.client.$$(".calendar .event");
|
|
||||||
return expect(events.length).toBe(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the custom calendar symbol in each event", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
const icons = await app.client.$$(".calendar .event .fa-birthday-cake");
|
|
||||||
return expect(icons.length).toBe(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show two custom icons for repeating events", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEventRepeat", 10000);
|
|
||||||
const icons = await app.client.$$(".calendar .event .fa-undo");
|
|
||||||
return expect(icons.length).toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show two custom icons for day events", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "TestEventDay", 10000);
|
|
||||||
const icons = await app.client.$$(".calendar .event .fa-calendar-day");
|
|
||||||
return expect(icons.length).toBe(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Recurring event", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/recurring.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the recurring birthday event 6 times", async () => {
|
|
||||||
await app.client.waitUntilTextExists(".calendar", "Mar 25th", 10000);
|
|
||||||
const events = await app.client.$$(".calendar .event");
|
|
||||||
return expect(events.length).toBe(6);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Changed port", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
serverBasicAuth.listen(8010);
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(function (done) {
|
|
||||||
serverBasicAuth.close(done());
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Basic auth", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Basic auth by default", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Fail Basic auth", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
serverBasicAuth.listen(8020);
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(function (done) {
|
|
||||||
serverBasicAuth.close(done());
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show Unauthorized error", function () {
|
|
||||||
return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Authorization failed", 10000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user