MagicMirror/tests/e2e/modules/calendar_spec.js

144 lines
4.4 KiB
JavaScript
Raw Normal View History

const helpers = require("../global-setup");
const serverBasicAuth = require("../../servers/basic-auth.js");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Calendar module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
2017-03-10 03:25:16 -03:00
});
afterEach(function () {
return helpers.stopApplication(app);
2017-03-10 03:25:16 -03:00
});
describe("Default configuration", function () {
before(function () {
2017-03-10 03:25:16 -03:00
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
});
2020-07-18 22:16:44 +02:00
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).equals(10);
});
2020-07-18 22:16:44 +02:00
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.equals(0);
});
});
describe("Custom configuration", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/custom.js";
});
2020-07-19 11:54:03 +02:00
it("should show the custom maximumEntries of 4", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const events = await app.client.$$(".calendar .event");
2020-07-19 11:54:03 +02:00
return expect(events.length).equals(4);
2017-03-10 03:25:16 -03:00
});
2020-07-18 22:16:44 +02:00
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");
2020-07-19 11:54:03 +02:00
return expect(icons.length).equals(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).equals(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).equals(2);
});
2017-03-10 03:25:16 -03:00
});
describe("Changed port", function () {
before(function () {
2017-03-10 04:33:27 -03:00
serverBasicAuth.listen(8010);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js";
2017-03-10 04:33:27 -03:00
});
after(function (done) {
serverBasicAuth.close(done());
});
2020-07-18 22:16:44 +02:00
it("should return TestEvents", function () {
2017-03-10 04:33:27 -03:00
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth", function () {
before(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 () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
});
2020-07-18 22:16:44 +02:00
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
});
2020-07-18 22:16:44 +02:00
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Fail Basic auth", function () {
before(function () {
serverBasicAuth.listen(8020);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
});
after(function (done) {
serverBasicAuth.close(done());
});
2020-07-18 22:16:44 +02:00
it("should return No upcoming events", function () {
return app.client.waitUntilTextExists(".calendar", "No upcoming events.", 10000);
});
});
2017-03-10 03:25:16 -03:00
});