Cleanup test directory (#2937)

Moves files around and renames some so that the structure is cleaner and
more consistent
This commit is contained in:
Veeck
2022-10-07 19:16:37 +02:00
committed by GitHub
parent 21ae79b386
commit a328ce537f
48 changed files with 739 additions and 825 deletions

View File

@@ -1,33 +0,0 @@
{
"LOADING": "Loading …",
"TODAY": "Today",
"TOMORROW": "Tomorrow",
"DAYAFTERTOMORROW": "In 2 days",
"RUNNING": "Ends in",
"EMPTY": "No upcoming events.",
"WEEK": "Week {weekNumber}",
"N": "N",
"NNE": "NNE",
"NE": "NE",
"ENE": "ENE",
"E": "E",
"ESE": "ESE",
"SE": "SE",
"SSE": "SSE",
"S": "S",
"SSW": "SSW",
"SW": "SW",
"WSW": "WSW",
"W": "W",
"WNW": "WNW",
"NW": "NW",
"NNW": "NNW",
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
"UPDATE_NOTIFICATION_MODULE": "Update available for MODULE_NAME module.",
"UPDATE_INFO_SINGLE": "The current installation is COMMIT_COUNT commit behind on the BRANCH_NAME branch.",
"UPDATE_INFO_MULTIPLE": "The current installation is COMMIT_COUNT commits behind on the BRANCH_NAME branch."
}

View File

@@ -14,7 +14,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
auth: {
user: "MagicMirror",
pass: "CallMeADog"

View File

@@ -14,7 +14,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
auth: {
user: "MagicMirror",
pass: "CallMeADog",

View File

@@ -14,7 +14,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8010/tests/configs/data/calendar_test.ics",
url: "http://localhost:8010/tests/mocks/calendar_test.ics",
auth: {
user: "MagicMirror",
pass: "CallMeADog"

View File

@@ -18,7 +18,7 @@ let config = {
symbol: "birthday-cake",
fullDaySymbol: "calendar-day",
recurringSymbol: "undo",
url: "http://localhost:8080/tests/configs/data/calendar_test_icons.ics"
url: "http://localhost:8080/tests/mocks/calendar_test_icons.ics"
}
]
}

View File

@@ -14,7 +14,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics"
url: "http://localhost:8080/tests/mocks/calendar_test.ics"
}
]
}

View File

@@ -16,7 +16,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8020/tests/configs/data/calendar_test.ics",
url: "http://localhost:8020/tests/mocks/calendar_test.ics",
auth: {
user: "MagicMirror",
pass: "StairwayToHeaven",

View File

@@ -14,7 +14,7 @@ let config = {
calendars: [
{
maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
user: "MagicMirror",
pass: "CallMeADog"
}

View File

@@ -15,7 +15,7 @@ let config = {
{
maximumEntries: 6,
maximumNumberOfDays: 3650,
url: "http://localhost:8080/tests/configs/data/calendar_test_recurring.ics"
url: "http://localhost:8080/tests/mocks/calendar_test_recurring.ics"
}
]
}

View File

@@ -9,7 +9,7 @@ let config = {
module: "compliments",
position: "middle_center",
config: {
remoteFile: "http://localhost:8080/tests/configs/data/compliments_test.json"
remoteFile: "http://localhost:8080/tests/mocks/compliments_test.json"
}
}
]

View File

@@ -14,7 +14,7 @@ let config = {
feeds: [
{
title: "Rodrigo Ramirez Blog",
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
}
]
}

View File

@@ -13,7 +13,7 @@ let config = {
feeds: [
{
title: "Rodrigo Ramirez Blog",
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
}
],
ignoreOldItems: true

View File

@@ -13,7 +13,7 @@ let config = {
feeds: [
{
title: "Rodrigo Ramirez Blog",
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
}
],
prohibitedWords: ["QPanel"],

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("App environment", () => {
beforeAll(async () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("All font files from roboto.css should be downloadable", () => {
const fontFiles = [];

View File

@@ -11,7 +11,7 @@ const basicAuth = auth({
app.use(basicAuth);
// Set available directories
const directories = ["/tests/configs"];
const directories = ["/tests/configs", "/tests/mocks"];
const rootPath = path.resolve(__dirname + "/../../../");
for (let directory of directories) {

View File

@@ -1,7 +1,7 @@
const helpers = require("../global-setup");
const helpers = require("./global-setup");
const path = require("path");
const fs = require("fs");
const { generateWeather, generateWeatherForecast } = require("./mocks");
const { generateWeather, generateWeatherForecast } = require("../../mocks/weather_test");
exports.getText = async (element, result) => {
const elem = await helpers.waitForElement(element);

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("ipWhitelist directive configuration", () => {
describe("Set ipWhitelist without access", () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Alert module", () => {
beforeAll(async () => {

View File

@@ -1,5 +1,5 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("./basic-auth.js");
const helpers = require("../helpers/global-setup");
const serverBasicAuth = require("../helpers/basic-auth.js");
describe("Calendar module", () => {
/**

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Clock set to spanish language module", () => {
afterAll(async () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
const moment = require("moment");
describe("Clock module", () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Compliments module", () => {
/**

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Test helloworld module", () => {
afterAll(async () => {

View File

@@ -1,4 +0,0 @@
const generateWeather = require("./weather_current");
const generateWeatherForecast = require("./weather_forecast");
module.exports = { generateWeather, generateWeatherForecast };

View File

@@ -1,64 +0,0 @@
const _ = require("lodash");
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked current weather data
*/
const generateWeather = (extendedData = {}) => {
return JSON.stringify(
_.merge(
{},
{
coord: {
lon: 11.58,
lat: 48.14
},
weather: [
{
id: 615,
main: "Snow",
description: "light rain and snow",
icon: "13d"
},
{
id: 500,
main: "Rain",
description: "light rain",
icon: "10d"
}
],
base: "stations",
main: {
temp: 1.49,
pressure: 1005,
humidity: 93.7,
temp_min: 1,
temp_max: 2
},
visibility: 7000,
wind: {
speed: 11.8,
deg: 250
},
clouds: {
all: 75
},
dt: 1547387400,
sys: {
type: 1,
id: 1267,
message: 0.0031,
country: "DE",
sunrise: 1547362817,
sunset: 1547394301
},
id: 2867714,
name: "Munich",
cod: 200
},
extendedData
)
);
};
module.exports = generateWeather;

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Newsfeed module", () => {
afterAll(async () => {

View File

@@ -1,6 +1,6 @@
const moment = require("moment");
const helpers = require("../global-setup");
const weatherFunc = require("./weather-functions");
const helpers = require("../helpers/global-setup");
const weatherFunc = require("../helpers/weather-functions");
describe("Weather module", () => {
afterAll(async () => {

View File

@@ -1,5 +1,5 @@
const helpers = require("../global-setup");
const weatherFunc = require("./weather-functions");
const helpers = require("../helpers/global-setup");
const weatherFunc = require("../helpers/weather-functions");
describe("Weather module: Weather Forecast", () => {
afterAll(async () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("Display of modules", () => {
beforeAll(async () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("Check configuration without modules", () => {
beforeAll(async () => {
@@ -15,7 +15,7 @@ describe("Check configuration without modules", () => {
expect(elem.textContent).toContain("MagicMirror²");
});
it("Show the text Michael's website", async () => {
it("Show the url of michael's website", async () => {
const elem = await helpers.waitForElement("#module_5_helloworld .module-content");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("www.michaelteeuw.nl");

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("Position of modules", () => {
beforeAll(async () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("port directive configuration", () => {
describe("Set port 8090", () => {

View File

@@ -1,4 +1,4 @@
const helpers = require("./global-setup");
const helpers = require("./helpers/global-setup");
describe("Vendors", () => {
beforeAll(() => {

View File

@@ -1,5 +1,66 @@
const _ = require("lodash");
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked current weather data
*/
const generateWeather = (extendedData = {}) => {
return JSON.stringify(
_.merge(
{},
{
coord: {
lon: 11.58,
lat: 48.14
},
weather: [
{
id: 615,
main: "Snow",
description: "light rain and snow",
icon: "13d"
},
{
id: 500,
main: "Rain",
description: "light rain",
icon: "10d"
}
],
base: "stations",
main: {
temp: 1.49,
pressure: 1005,
humidity: 93.7,
temp_min: 1,
temp_max: 2
},
visibility: 7000,
wind: {
speed: 11.8,
deg: 250
},
clouds: {
all: 75
},
dt: 1547387400,
sys: {
type: 1,
id: 1267,
message: 0.0031,
country: "DE",
sunrise: 1547362817,
sunset: 1547394301
},
id: 2867714,
name: "Munich",
cod: 200
},
extendedData
)
);
};
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked forecast weather data
@@ -112,4 +173,4 @@ const generateWeatherForecast = (extendedData = {}) => {
);
};
module.exports = generateWeatherForecast;
module.exports = { generateWeather, generateWeatherForecast };

View File

@@ -14,7 +14,7 @@ describe("Translator", () => {
res.header("Access-Control-Allow-Origin", "*");
next();
});
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "configs", "data")));
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "mocks")));
server = app.listen(3000);
@@ -160,10 +160,10 @@ describe("Translator", () => {
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
dom.window.onload = () => {
const { Translator } = dom.window;
const file = "TranslationTest.json";
const file = "translation_test.json";
Translator.load(mmm, file, false, () => {
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
const json = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", file));
expect(Translator.translations[mmm.name]).toEqual(json);
done();
});
@@ -174,10 +174,10 @@ describe("Translator", () => {
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
dom.window.onload = () => {
const { Translator } = dom.window;
const file = "TranslationTest.json";
const file = "translation_test.json";
Translator.load(mmm, file, true, () => {
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
const json = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", file));
expect(Translator.translationsFallback[mmm.name]).toEqual(json);
done();
});
@@ -188,7 +188,7 @@ describe("Translator", () => {
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
dom.window.onload = () => {
const { Translator, XMLHttpRequest } = dom.window;
const file = "TranslationTest.json";
const file = "translation_test.json";
XMLHttpRequest.prototype.send = () => {
throw "Shouldn't load files";
@@ -212,7 +212,7 @@ describe("Translator", () => {
describe("loadCoreTranslations", () => {
it("should load core translations and fallback", (done) => {
const dom = new JSDOM(
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
@@ -220,7 +220,7 @@ describe("Translator", () => {
const { Translator } = dom.window;
Translator.loadCoreTranslations("en");
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
setTimeout(() => {
expect(Translator.coreTranslations).toEqual(en);
expect(Translator.coreTranslationsFallback).toEqual(en);
@@ -231,7 +231,7 @@ describe("Translator", () => {
it("should load core fallback if language cannot be found", (done) => {
const dom = new JSDOM(
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
@@ -239,7 +239,7 @@ describe("Translator", () => {
const { Translator } = dom.window;
Translator.loadCoreTranslations("MISSINGLANG");
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
setTimeout(() => {
expect(Translator.coreTranslations).toEqual({});
expect(Translator.coreTranslationsFallback).toEqual(en);
@@ -252,7 +252,7 @@ describe("Translator", () => {
describe("loadCoreTranslationsFallback", () => {
it("should load core translations fallback", (done) => {
const dom = new JSDOM(
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
@@ -260,7 +260,7 @@ describe("Translator", () => {
const { Translator } = dom.window;
Translator.loadCoreTranslationsFallback();
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
setTimeout(() => {
expect(Translator.coreTranslationsFallback).toEqual(en);
done();