Merge master

This commit is contained in:
Pieter Vander Vennet 2021-06-13 15:15:13 +02:00
commit d7004cd3dc
93 changed files with 2670 additions and 828 deletions

View file

@ -0,0 +1,46 @@
import T from "./TestHelper";
import UserDetails, {OsmConnection} from "../Logic/Osm/OsmConnection";
import {UIEventSource} from "../Logic/UIEventSource";
import ScriptUtils from "../scripts/ScriptUtils";
export default class OsmConnectionSpec extends T {
/*
This token gives access to the TESTING-instance of OSM. No real harm can be done with it, so it can be commited to the repo
*/
private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n"
constructor() {
super("OsmConnectionSpec-test", [
["login on dev",
() => {
const osmConn = new OsmConnection(false,
new UIEventSource<string>(undefined),
"Unit test",
true,
"osm-test"
)
osmConn.userDetails.map((userdetails : UserDetails) => {
if(userdetails.loggedIn){
console.log("Logged in with the testing account. Writing some random data to test preferences")
const data = Math.random().toString()
osmConn.GetPreference("test").setData(data)
osmConn.GetPreference("https://raw.githubusercontent.com/AgusQui/MapCompleteRailway/main/railway")
.setData(data)
}
});
ScriptUtils.sleep(1000)
}
]
]);
}
}

View file

@ -9,7 +9,26 @@ import TagQuestionSpec from "./TagQuestion.spec";
import ImageSearcherSpec from "./ImageSearcher.spec";
import ThemeSpec from "./Theme.spec";
import UtilsSpec from "./Utils.spec";
import OsmConnectionSpec from "./OsmConnection.spec";
import T from "./TestHelper";
import {FixedUiElement} from "../UI/Base/FixedUiElement";
import Combine from "../UI/Base/Combine";
export default class TestAll {
private needsBrowserTests: T[] = [new OsmConnectionSpec()]
public testAll(): void {
Utils.runningFromConsole = false
for (const test of this.needsBrowserTests.concat(allTests)) {
if (test.failures.length > 0) {
new Combine([new FixedUiElement("TEST FAILED: " + test.name).SetStyle("background: red"),
...test.failures])
.AttachTo("maindiv")
throw "Some test failed"
}
}
}
}
const allTests = [
new TagSpec(),
@ -20,8 +39,9 @@ const allTests = [
new ThemeSpec(),
new UtilsSpec()]
for (const test of allTests) {
if(test.failures.length > 0){
if (test.failures.length > 0) {
throw "Some test failed"
}
}

View file

@ -1,8 +1,10 @@
export default class T {
public readonly failures = []
public readonly failures : string[] = []
public readonly name : string;
constructor(testsuite: string, tests: [string, () => void][]) {
this.name = testsuite
for (const [name, test] of tests) {
try {
test();