2017-07-24 22:08:12 +02:00
|
|
|
const helpers = require("../global-setup");
|
|
|
|
const serverBasicAuth = require("../../servers/basic-auth.js");
|
2020-07-18 13:57:48 +02:00
|
|
|
const expect = require("chai").expect;
|
2017-07-24 22:08:12 +02:00
|
|
|
|
|
|
|
const describe = global.describe;
|
|
|
|
const it = global.it;
|
|
|
|
const beforeEach = global.beforeEach;
|
|
|
|
const afterEach = global.afterEach;
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Calendar module", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
helpers.setupTimeout(this);
|
|
|
|
|
|
|
|
var app = null;
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
beforeEach(function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
return helpers
|
|
|
|
.startApplication({
|
|
|
|
args: ["js/electron.js"]
|
|
|
|
})
|
2020-05-11 22:22:32 +02:00
|
|
|
.then(function (startedApp) {
|
2017-07-24 22:08:12 +02:00
|
|
|
app = startedApp;
|
|
|
|
});
|
2017-03-10 03:25:16 -03:00
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
afterEach(function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
return helpers.stopApplication(app);
|
2017-03-10 03:25:16 -03:00
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02: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 13:57:48 +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 21:10:36 +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);
|
|
|
|
});
|
2020-07-18 13:57:48 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Custom configuration", function () {
|
|
|
|
before(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 3", async () => {
|
|
|
|
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
|
|
const events = await app.client.$$(".calendar .event");
|
|
|
|
return expect(events.length).equals(3);
|
2017-03-10 03:25:16 -03:00
|
|
|
});
|
2020-07-18 21:10:36 +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");
|
|
|
|
return expect(icons.length).not.equals(0);
|
|
|
|
});
|
2017-03-10 03:25:16 -03:00
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Basic auth", 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/basic-auth.js";
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
after(function (done) {
|
2017-07-24 22:08:12 +02:00
|
|
|
serverBasicAuth.close(done());
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("Should return TestEvents", function () {
|
2017-03-10 04:33:27 -03:00
|
|
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Basic auth by default", function () {
|
|
|
|
before(function () {
|
2017-03-10 04:36:09 -03:00
|
|
|
serverBasicAuth.listen(8011);
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
after(function (done) {
|
2017-07-24 22:08:12 +02:00
|
|
|
serverBasicAuth.close(done());
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("Should return TestEvents", function () {
|
2017-03-10 04:36:09 -03:00
|
|
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
|
|
|
before(function () {
|
2017-03-10 04:40:59 -03:00
|
|
|
serverBasicAuth.listen(8012);
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
after(function (done) {
|
2017-07-24 22:08:12 +02:00
|
|
|
serverBasicAuth.close(done());
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("Should return TestEvents", function () {
|
2017-03-10 04:40:59 -03:00
|
|
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Fail Basic auth", function () {
|
|
|
|
before(function () {
|
2017-03-10 16:45:45 -03:00
|
|
|
serverBasicAuth.listen(8020);
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
after(function (done) {
|
2017-07-24 22:08:12 +02:00
|
|
|
serverBasicAuth.close(done());
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("Should return No upcoming events", function () {
|
2017-03-10 16:45:45 -03:00
|
|
|
return app.client.waitUntilTextExists(".calendar", "No upcoming events.", 10000);
|
|
|
|
});
|
|
|
|
});
|
2017-03-10 03:25:16 -03:00
|
|
|
});
|