hotstaq 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +123 -0
- package/.eslintignore +17 -0
- package/.eslintrc.js +11 -0
- package/.vscode/launch.json +201 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +88 -0
- package/CONTRIBUTING.md +157 -0
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/bin/hotstaq +3 -0
- package/bin/hotstaq.cmd +1 -0
- package/build/src/Hot.d.ts +167 -0
- package/build/src/Hot.d.ts.map +1 -0
- package/build/src/Hot.js +365 -0
- package/build/src/Hot.js.map +1 -0
- package/build/src/HotAPI.d.ts +137 -0
- package/build/src/HotAPI.d.ts.map +1 -0
- package/build/src/HotAPI.js +353 -0
- package/build/src/HotAPI.js.map +1 -0
- package/build/src/HotAgentAPI.d.ts +22 -0
- package/build/src/HotAgentAPI.d.ts.map +1 -0
- package/build/src/HotAgentAPI.js +85 -0
- package/build/src/HotAgentAPI.js.map +1 -0
- package/build/src/HotAgentRoute.d.ts +17 -0
- package/build/src/HotAgentRoute.d.ts.map +1 -0
- package/build/src/HotAgentRoute.js +109 -0
- package/build/src/HotAgentRoute.js.map +1 -0
- package/build/src/HotBuilder.d.ts +52 -0
- package/build/src/HotBuilder.d.ts.map +1 -0
- package/build/src/HotBuilder.js +242 -0
- package/build/src/HotBuilder.js.map +1 -0
- package/build/src/HotClient.d.ts +31 -0
- package/build/src/HotClient.d.ts.map +1 -0
- package/build/src/HotClient.js +19 -0
- package/build/src/HotClient.js.map +1 -0
- package/build/src/HotComponent.d.ts +118 -0
- package/build/src/HotComponent.d.ts.map +1 -0
- package/build/src/HotComponent.js +89 -0
- package/build/src/HotComponent.js.map +1 -0
- package/build/src/HotCreator.d.ts +88 -0
- package/build/src/HotCreator.d.ts.map +1 -0
- package/build/src/HotCreator.js +445 -0
- package/build/src/HotCreator.js.map +1 -0
- package/build/src/HotDB.d.ts +69 -0
- package/build/src/HotDB.d.ts.map +1 -0
- package/build/src/HotDB.js +29 -0
- package/build/src/HotDB.js.map +1 -0
- package/build/src/HotDBConnectionInterface.d.ts +40 -0
- package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
- package/build/src/HotDBConnectionInterface.js +3 -0
- package/build/src/HotDBConnectionInterface.js.map +1 -0
- package/build/src/HotFile.d.ts +134 -0
- package/build/src/HotFile.d.ts.map +1 -0
- package/build/src/HotFile.js +454 -0
- package/build/src/HotFile.js.map +1 -0
- package/build/src/HotGenerator.d.ts +80 -0
- package/build/src/HotGenerator.d.ts.map +1 -0
- package/build/src/HotGenerator.js +342 -0
- package/build/src/HotGenerator.js.map +1 -0
- package/build/src/HotHTTPServer.d.ts +162 -0
- package/build/src/HotHTTPServer.d.ts.map +1 -0
- package/build/src/HotHTTPServer.js +863 -0
- package/build/src/HotHTTPServer.js.map +1 -0
- package/build/src/HotIO.d.ts +47 -0
- package/build/src/HotIO.d.ts.map +1 -0
- package/build/src/HotIO.js +232 -0
- package/build/src/HotIO.js.map +1 -0
- package/build/src/HotLog.d.ts +60 -0
- package/build/src/HotLog.d.ts.map +1 -0
- package/build/src/HotLog.js +126 -0
- package/build/src/HotLog.js.map +1 -0
- package/build/src/HotPage.d.ts +125 -0
- package/build/src/HotPage.d.ts.map +1 -0
- package/build/src/HotPage.js +178 -0
- package/build/src/HotPage.js.map +1 -0
- package/build/src/HotRoute.d.ts +82 -0
- package/build/src/HotRoute.d.ts.map +1 -0
- package/build/src/HotRoute.js +83 -0
- package/build/src/HotRoute.js.map +1 -0
- package/build/src/HotRouteMethod.d.ts +129 -0
- package/build/src/HotRouteMethod.d.ts.map +1 -0
- package/build/src/HotRouteMethod.js +84 -0
- package/build/src/HotRouteMethod.js.map +1 -0
- package/build/src/HotServer.d.ts +152 -0
- package/build/src/HotServer.d.ts.map +1 -0
- package/build/src/HotServer.js +109 -0
- package/build/src/HotServer.js.map +1 -0
- package/build/src/HotSetAsWeb.d.ts +2 -0
- package/build/src/HotSetAsWeb.d.ts.map +1 -0
- package/build/src/HotSetAsWeb.js +5 -0
- package/build/src/HotSetAsWeb.js.map +1 -0
- package/build/src/HotStaq.d.ts +603 -0
- package/build/src/HotStaq.d.ts.map +1 -0
- package/build/src/HotStaq.js +1260 -0
- package/build/src/HotStaq.js.map +1 -0
- package/build/src/HotStaqWeb.d.ts +18 -0
- package/build/src/HotStaqWeb.d.ts.map +1 -0
- package/build/src/HotStaqWeb.js +44 -0
- package/build/src/HotStaqWeb.js.map +1 -0
- package/build/src/HotTestDriver.d.ts +63 -0
- package/build/src/HotTestDriver.d.ts.map +1 -0
- package/build/src/HotTestDriver.js +187 -0
- package/build/src/HotTestDriver.js.map +1 -0
- package/build/src/HotTestElement.d.ts +71 -0
- package/build/src/HotTestElement.d.ts.map +1 -0
- package/build/src/HotTestElement.js +37 -0
- package/build/src/HotTestElement.js.map +1 -0
- package/build/src/HotTestMap.d.ts +83 -0
- package/build/src/HotTestMap.d.ts.map +1 -0
- package/build/src/HotTestMap.js +58 -0
- package/build/src/HotTestMap.js.map +1 -0
- package/build/src/HotTestSeleniumDriver.d.ts +86 -0
- package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
- package/build/src/HotTestSeleniumDriver.js +400 -0
- package/build/src/HotTestSeleniumDriver.js.map +1 -0
- package/build/src/HotTester.d.ts +188 -0
- package/build/src/HotTester.d.ts.map +1 -0
- package/build/src/HotTester.js +622 -0
- package/build/src/HotTester.js.map +1 -0
- package/build/src/HotTesterAPI.d.ts +15 -0
- package/build/src/HotTesterAPI.d.ts.map +1 -0
- package/build/src/HotTesterAPI.js +161 -0
- package/build/src/HotTesterAPI.js.map +1 -0
- package/build/src/HotTesterMocha.d.ts +50 -0
- package/build/src/HotTesterMocha.d.ts.map +1 -0
- package/build/src/HotTesterMocha.js +205 -0
- package/build/src/HotTesterMocha.js.map +1 -0
- package/build/src/HotTesterMochaSelenium.d.ts +70 -0
- package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
- package/build/src/HotTesterMochaSelenium.js +257 -0
- package/build/src/HotTesterMochaSelenium.js.map +1 -0
- package/build/src/HotTesterServer.d.ts +114 -0
- package/build/src/HotTesterServer.d.ts.map +1 -0
- package/build/src/HotTesterServer.js +575 -0
- package/build/src/HotTesterServer.js.map +1 -0
- package/build/src/api copy.d.ts +2 -0
- package/build/src/api copy.d.ts.map +1 -0
- package/build/src/api copy.js +153 -0
- package/build/src/api copy.js.map +1 -0
- package/build/src/api-web.d.ts +2 -0
- package/build/src/api-web.d.ts.map +1 -0
- package/build/src/api-web.js +45 -0
- package/build/src/api-web.js.map +1 -0
- package/build/src/api.d.ts +33 -0
- package/build/src/api.d.ts.map +1 -0
- package/build/src/api.js +78 -0
- package/build/src/api.js.map +1 -0
- package/build/src/cli.d.ts +2 -0
- package/build/src/cli.d.ts.map +1 -0
- package/build/src/cli.js +1040 -0
- package/build/src/cli.js.map +1 -0
- package/build/src/schemas/HotDBInflux.d.ts +63 -0
- package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
- package/build/src/schemas/HotDBInflux.js +239 -0
- package/build/src/schemas/HotDBInflux.js.map +1 -0
- package/build/src/schemas/HotDBMigration.d.ts +19 -0
- package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
- package/build/src/schemas/HotDBMigration.js +15 -0
- package/build/src/schemas/HotDBMigration.js.map +1 -0
- package/build/src/schemas/HotDBMySQL.d.ts +65 -0
- package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
- package/build/src/schemas/HotDBMySQL.js +387 -0
- package/build/src/schemas/HotDBMySQL.js.map +1 -0
- package/build/src/schemas/HotDBSchema.d.ts +15 -0
- package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
- package/build/src/schemas/HotDBSchema.js +19 -0
- package/build/src/schemas/HotDBSchema.js.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.js +33 -0
- package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.js +151 -0
- package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
- package/build-web/HotStaq.js +2 -0
- package/build-web/HotStaq.min.js +119 -0
- package/build-web/HotStaqTests_HelloWorldAPI.js +133 -0
- package/builder/docker/Dockerfile.linux.gen +42 -0
- package/builder/docker/README.md +36 -0
- package/builder/docker/app/start.sh +8 -0
- package/builder/docker/dockerignore +3 -0
- package/builder/docker/scripts/build.bat +11 -0
- package/builder/docker/scripts/build.sh +11 -0
- package/builder/docker/scripts/start-app.bat +7 -0
- package/builder/docker/scripts/start-app.sh +7 -0
- package/builder/docker/scripts/stop-app.bat +5 -0
- package/builder/docker/scripts/stop-app.sh +5 -0
- package/builder/docker-compose/docker-compose.gen.yaml +41 -0
- package/builder/docker-compose/env-skeleton +4 -0
- package/creator/project/.vscode/launch.json +59 -0
- package/creator/project/README.md +20 -0
- package/creator/project/gitignore +118 -0
- package/creator/project/npmignore +118 -0
- package/creator/public/api-test.hott +28 -0
- package/creator/public/index.hott +12 -0
- package/creator/ts/src/AppAPI.ts +30 -0
- package/creator/ts/src/HelloWorld.ts +39 -0
- package/creator/ts/src/WebExport.ts +7 -0
- package/creator/ts/tsconfig-web.json +73 -0
- package/creator/ts/tsconfig.json +73 -0
- package/creator/ts/webpack-api.config.js +57 -0
- package/dbstart.sh +19 -0
- package/dbstop.sh +4 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +130 -0
- package/docs/classes/Hot.md +477 -0
- package/docs/classes/HotAPI.md +369 -0
- package/docs/classes/HotClient.md +95 -0
- package/docs/classes/HotComponent.md +279 -0
- package/docs/classes/HotDB.md +247 -0
- package/docs/classes/HotDBInflux.md +404 -0
- package/docs/classes/HotDBMigration.md +80 -0
- package/docs/classes/HotDBMySQL.md +310 -0
- package/docs/classes/HotDBSchema.md +51 -0
- package/docs/classes/HotFile.md +353 -0
- package/docs/classes/HotHTTPServer.md +700 -0
- package/docs/classes/HotLog.md +162 -0
- package/docs/classes/HotPage.md +357 -0
- package/docs/classes/HotRoute.md +312 -0
- package/docs/classes/HotRouteMethod.md +271 -0
- package/docs/classes/HotServer.md +311 -0
- package/docs/classes/HotStaq.md +1155 -0
- package/docs/classes/HotTestDestination.md +58 -0
- package/docs/classes/HotTestDriver.md +332 -0
- package/docs/classes/HotTestElement.md +88 -0
- package/docs/classes/HotTestElementOptions.md +71 -0
- package/docs/classes/HotTestMap.md +92 -0
- package/docs/classes/HotTestSeleniumDriver.md +542 -0
- package/docs/classes/HotTester.md +653 -0
- package/docs/classes/HotTesterAPI.md +493 -0
- package/docs/classes/HotTesterMocha.md +843 -0
- package/docs/classes/HotTesterMochaSelenium.md +896 -0
- package/docs/classes/HotTesterServer.md +633 -0
- package/docs/classes/InfluxSchema.md +74 -0
- package/docs/classes/MySQLSchema.md +199 -0
- package/docs/classes/MySQLSchemaField.md +330 -0
- package/docs/classes/MySQLSchemaTable.md +176 -0
- package/docs/enums/ConnectionStatus.md +43 -0
- package/docs/enums/DeveloperMode.md +38 -0
- package/docs/enums/EventExecutionType.md +43 -0
- package/docs/enums/HTTPMethod.md +32 -0
- package/docs/enums/HotDBGenerationType.md +30 -0
- package/docs/enums/HotLogLevel.md +88 -0
- package/docs/interfaces/HotDBConnectionInterface.md +116 -0
- package/docs/interfaces/HotDestination.md +62 -0
- package/docs/interfaces/HotSite.md +187 -0
- package/docs/interfaces/HotSiteMapPath.md +37 -0
- package/docs/interfaces/HotSiteRoute.md +79 -0
- package/docs/interfaces/HotStartOptions.md +115 -0
- package/docs/interfaces/HotTestPage.md +44 -0
- package/docs/interfaces/HotTestStop.md +62 -0
- package/docs/interfaces/IHotComponent.md +135 -0
- package/docs/interfaces/IHotStaq.md +118 -0
- package/docs/interfaces/IHotTestElement.md +54 -0
- package/docs/interfaces/IHotTestElementOptions.md +43 -0
- package/docs/interfaces/MySQLResults.md +43 -0
- package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
- package/docs/modules.md +182 -0
- package/package.json +65 -0
- package/selenium-start.sh +7 -0
- package/selenium-stop.sh +3 -0
- package/src/Hot.ts +319 -0
- package/src/HotAPI.ts +386 -0
- package/src/HotAgentAPI.ts +43 -0
- package/src/HotAgentRoute.ts +44 -0
- package/src/HotBuilder.ts +221 -0
- package/src/HotClient.ts +40 -0
- package/src/HotComponent.ts +158 -0
- package/src/HotCreator.ts +470 -0
- package/src/HotDB.ts +79 -0
- package/src/HotDBConnectionInterface.ts +40 -0
- package/src/HotFile.ts +617 -0
- package/src/HotGenerator.ts +446 -0
- package/src/HotHTTPServer.ts +954 -0
- package/src/HotIO.ts +160 -0
- package/src/HotLog.ts +158 -0
- package/src/HotPage.ts +206 -0
- package/src/HotRoute.ts +137 -0
- package/src/HotRouteMethod.ts +216 -0
- package/src/HotServer.ts +211 -0
- package/src/HotSetAsWeb.ts +3 -0
- package/src/HotStaq.ts +1881 -0
- package/src/HotTestDriver.ts +171 -0
- package/src/HotTestElement.ts +97 -0
- package/src/HotTestMap.ts +130 -0
- package/src/HotTestSeleniumDriver.ts +381 -0
- package/src/HotTester.ts +696 -0
- package/src/HotTesterAPI.ts +126 -0
- package/src/HotTesterMocha.ts +133 -0
- package/src/HotTesterMochaSelenium.ts +189 -0
- package/src/HotTesterServer.ts +551 -0
- package/src/api-web.ts +48 -0
- package/src/api.ts +103 -0
- package/src/cli.ts +1225 -0
- package/src/schemas/HotDBInflux.ts +211 -0
- package/src/schemas/HotDBMigration.ts +24 -0
- package/src/schemas/HotDBMySQL.ts +312 -0
- package/src/schemas/HotDBSchema.ts +21 -0
- package/src/schemas/influx/InfluxSchema.ts +19 -0
- package/src/schemas/mysql/MySQLSchema.ts +90 -0
- package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
- package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
- package/temp/HotStaqWeb.ts +59 -0
- package/tsconfig-generator.json +17 -0
- package/tsconfig-web.json +74 -0
- package/tsconfig.json +73 -0
- package/webpack.config.generator.js +41 -0
- package/webpack.config.js +53 -0
- package/webpack.config.tests.js +56 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { EventExecutionType, HotAPI } from "./HotAPI";
|
|
2
|
+
import { HotRoute } from "./HotRoute";
|
|
3
|
+
import { HotClient } from "./HotClient";
|
|
4
|
+
import { HotServer } from "./HotServer";
|
|
5
|
+
import { HotTestDriver } from "./HotTestDriver";
|
|
6
|
+
import { HotTester } from "./HotTester";
|
|
7
|
+
import { HotTestMap, HotTestPath, HotTestPage } from "./HotTestMap";
|
|
8
|
+
|
|
9
|
+
export class HotTesterAPI extends HotAPI
|
|
10
|
+
{
|
|
11
|
+
constructor (baseUrl: string, connection: HotServer | HotClient = null, db: any = null)
|
|
12
|
+
{
|
|
13
|
+
super(baseUrl, connection, db);
|
|
14
|
+
|
|
15
|
+
this.executeEventsUsing = EventExecutionType.HotAPI;
|
|
16
|
+
|
|
17
|
+
let route: HotRoute = new HotRoute (connection, "tester");
|
|
18
|
+
route.addMethod ("pageLoaded", this.pageLoaded);
|
|
19
|
+
route.addMethod ("executeTests", this.executeTests);
|
|
20
|
+
this.addRoute (route);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This is called when the page has finished loading in development mode.
|
|
25
|
+
*/
|
|
26
|
+
async pageLoaded (req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any): Promise<any>
|
|
27
|
+
{
|
|
28
|
+
let testerObj: {
|
|
29
|
+
testerName: string;
|
|
30
|
+
testerMap: string;
|
|
31
|
+
pageName: string;
|
|
32
|
+
testElements: any;
|
|
33
|
+
testPathsStrs: any;
|
|
34
|
+
} = {
|
|
35
|
+
testerName: jsonObj["testerName"],
|
|
36
|
+
testerMap: jsonObj["testerMap"],
|
|
37
|
+
pageName: jsonObj["pageName"],
|
|
38
|
+
testElements: jsonObj["testElements"],
|
|
39
|
+
testPathsStrs: jsonObj["testPaths"]
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
for (let key in testerObj)
|
|
43
|
+
{
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
let testObj: any = testerObj[key];
|
|
46
|
+
let throwError: boolean = false;
|
|
47
|
+
|
|
48
|
+
if (testObj == null)
|
|
49
|
+
throwError = true;
|
|
50
|
+
|
|
51
|
+
if ((testerObj.testerName == "") ||
|
|
52
|
+
(testerObj.testerMap === "") ||
|
|
53
|
+
(testerObj.testElements === "") ||
|
|
54
|
+
(testerObj.testPathsStrs === ""))
|
|
55
|
+
{
|
|
56
|
+
throwError = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (throwError === true)
|
|
60
|
+
throw new Error (`TesterAPI: Object ${key} was not passed.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
testerObj.testElements = JSON.parse (testerObj.testElements);
|
|
64
|
+
testerObj.testPathsStrs = JSON.parse (testerObj.testPathsStrs);
|
|
65
|
+
|
|
66
|
+
let testPaths: { [name: string]: HotTestPath; } = {};
|
|
67
|
+
|
|
68
|
+
for (let key in testerObj.testPathsStrs)
|
|
69
|
+
{
|
|
70
|
+
let testPath: (driver: HotTestDriver, ...args: any) => Promise<any> =
|
|
71
|
+
eval (testerObj.testPathsStrs[key]);
|
|
72
|
+
|
|
73
|
+
testPaths[key] = testPath;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let tester: HotTester = this.connection.processor.testers[testerObj.testerName];
|
|
77
|
+
|
|
78
|
+
if (tester == null)
|
|
79
|
+
throw new Error (`TesterAPI: Tester ${testerObj.testerMap} does not exist!`);
|
|
80
|
+
|
|
81
|
+
let testMap: HotTestMap = tester.testMaps[testerObj.testerMap];
|
|
82
|
+
|
|
83
|
+
if (testMap == null)
|
|
84
|
+
throw new Error (`TesterAPI: Tester map ${testerObj.testerMap} does not exist!`);
|
|
85
|
+
|
|
86
|
+
testMap.pages[testerObj.pageName] = {
|
|
87
|
+
"testElements": {},
|
|
88
|
+
"testPaths": {}
|
|
89
|
+
};
|
|
90
|
+
testMap.pages[testerObj.pageName].testElements = testerObj.testElements;
|
|
91
|
+
testMap.pages[testerObj.pageName].testPaths = testPaths;
|
|
92
|
+
|
|
93
|
+
tester.finishedLoading = true;
|
|
94
|
+
|
|
95
|
+
if (tester.onFinishedLoading != null)
|
|
96
|
+
await tester.onFinishedLoading ();
|
|
97
|
+
|
|
98
|
+
return (true);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Execute the tests for a page.
|
|
103
|
+
*/
|
|
104
|
+
async executeTests (req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any): Promise<any>
|
|
105
|
+
{
|
|
106
|
+
let testerName: string = jsonObj["testerName"];
|
|
107
|
+
let testerMap: string = jsonObj["testerMap"];
|
|
108
|
+
|
|
109
|
+
if ((testerName == null) || (testerMap == null))
|
|
110
|
+
throw new Error ("TesterAPI: Not all required json objects were passed.");
|
|
111
|
+
|
|
112
|
+
if ((testerName === "") || (testerMap === ""))
|
|
113
|
+
throw new Error ("TesterAPI: Not all required json objects were passed.");
|
|
114
|
+
|
|
115
|
+
let server: HotServer = (<HotServer>this.connection);
|
|
116
|
+
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
if (server.executeTests != null)
|
|
119
|
+
{
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
await server.executeTests (testerName, testerMap);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return (true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Mocha from "mocha";
|
|
2
|
+
import { Suite, Test } from "mocha";
|
|
3
|
+
|
|
4
|
+
import { HotTestMap, HotTestPage, HotTestPath } from "./HotTestMap";
|
|
5
|
+
import { HotDestination, HotTester, HotTestStop } from "./HotTester";
|
|
6
|
+
import { HotTestDriver } from "./HotTestDriver";
|
|
7
|
+
import { HotStaq } from "./HotStaq";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The tester that uses Mocha to executes all tests.
|
|
11
|
+
*/
|
|
12
|
+
export class HotTesterMocha extends HotTester
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* The mocha instance to run.
|
|
16
|
+
*/
|
|
17
|
+
mocha: Mocha;
|
|
18
|
+
/**
|
|
19
|
+
* The timeout for each test.
|
|
20
|
+
*/
|
|
21
|
+
timeout: number;
|
|
22
|
+
/**
|
|
23
|
+
* The suite to execute.
|
|
24
|
+
*/
|
|
25
|
+
suite: Suite;
|
|
26
|
+
/**
|
|
27
|
+
* The Mocha beforeAll event to call before any tests are executed.
|
|
28
|
+
*/
|
|
29
|
+
beforeAll: () => Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* The Mocha afterAll event to call before any tests are executed.
|
|
32
|
+
*/
|
|
33
|
+
afterAll: () => Promise<void>;
|
|
34
|
+
|
|
35
|
+
constructor (processor: HotStaq, name: string, baseUrl: string, driver: HotTestDriver,
|
|
36
|
+
testMaps: { [name: string]: HotTestMap; } = {}, beforeAll: () => Promise<void> = null,
|
|
37
|
+
afterAll: () => Promise<void> = null)
|
|
38
|
+
{
|
|
39
|
+
super (processor, name, baseUrl, driver, testMaps);
|
|
40
|
+
|
|
41
|
+
this.mocha = null;
|
|
42
|
+
this.timeout = 10000;
|
|
43
|
+
this.suite = null;
|
|
44
|
+
this.beforeAll = beforeAll;
|
|
45
|
+
this.afterAll = afterAll;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Executed when setting up the tester.
|
|
50
|
+
*/
|
|
51
|
+
async setup (): Promise<void>
|
|
52
|
+
{
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Executed when destroying up the tester.
|
|
57
|
+
*/
|
|
58
|
+
async destroy (): Promise<void>
|
|
59
|
+
{
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Executed when tests are started.
|
|
64
|
+
*/
|
|
65
|
+
async onTestStart (destination: HotDestination, destinationKey: string = ""): Promise<boolean>
|
|
66
|
+
{
|
|
67
|
+
let destinationName: string = "";
|
|
68
|
+
|
|
69
|
+
if (destinationKey !== "")
|
|
70
|
+
destinationName = ` - ${destinationKey}`;
|
|
71
|
+
|
|
72
|
+
this.mocha = new Mocha ();
|
|
73
|
+
this.suite = Mocha.Suite.create (this.mocha.suite, `${destination.page}${destinationName} Tests`);
|
|
74
|
+
this.suite.timeout (this.timeout);
|
|
75
|
+
|
|
76
|
+
if (this.beforeAll != null)
|
|
77
|
+
this.suite.beforeAll (this.beforeAll);
|
|
78
|
+
|
|
79
|
+
return (true);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async onTestPagePathStart (destination: HotDestination, page: HotTestPage,
|
|
83
|
+
stop: HotTestStop, continueWhenTestIsComplete: boolean = false): Promise<boolean>
|
|
84
|
+
{
|
|
85
|
+
let testPathName: string = stop.path;
|
|
86
|
+
|
|
87
|
+
if (continueWhenTestIsComplete === true)
|
|
88
|
+
{
|
|
89
|
+
await new Promise<void> ((resolve, reject) =>
|
|
90
|
+
{
|
|
91
|
+
this.suite.addTest (new Test (testPathName, async () =>
|
|
92
|
+
{
|
|
93
|
+
// The true is a dumb hack to prevent any recursion.
|
|
94
|
+
await this.executeTestPagePath (destination, stop, true);
|
|
95
|
+
resolve ();
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
{
|
|
101
|
+
this.suite.addTest (new Test (testPathName, async () =>
|
|
102
|
+
{
|
|
103
|
+
// The true is a dumb hack to prevent any recursion.
|
|
104
|
+
await this.executeTestPagePath (destination, stop, true);
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (false);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async onCommand (destination: HotDestination, page: HotTestPage, stop: HotTestStop,
|
|
112
|
+
cmd: string, args: string[], cmdFunc: ((cmdArgs: string[]) => Promise<void>)): Promise<void>
|
|
113
|
+
{
|
|
114
|
+
this.suite.addTest (new Test (cmd, async () =>
|
|
115
|
+
{
|
|
116
|
+
await cmdFunc (args);
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async onTestEnd (destination: HotDestination): Promise<void>
|
|
121
|
+
{
|
|
122
|
+
return (await new Promise ((resolve, reject) =>
|
|
123
|
+
{
|
|
124
|
+
if (this.afterAll != null)
|
|
125
|
+
this.suite.afterAll (this.afterAll);
|
|
126
|
+
|
|
127
|
+
this.mocha.run ((failures: number) =>
|
|
128
|
+
{
|
|
129
|
+
resolve ();
|
|
130
|
+
});
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import Mocha from "mocha";
|
|
2
|
+
import { Suite, Test } from "mocha";
|
|
3
|
+
|
|
4
|
+
import { HotTestMap, HotTestPage, HotTestPath } from "./HotTestMap";
|
|
5
|
+
import { HotDestination, HotTester, HotTestStop } from "./HotTester";
|
|
6
|
+
import { HotStaq } from "./HotStaq";
|
|
7
|
+
import { HotTestSeleniumDriver } from "./HotTestSeleniumDriver";
|
|
8
|
+
|
|
9
|
+
import { WebDriver } from "selenium-webdriver";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The tester that uses Mocha to executes all tests.
|
|
13
|
+
*/
|
|
14
|
+
export class HotTesterMochaSelenium extends HotTester
|
|
15
|
+
{
|
|
16
|
+
/**
|
|
17
|
+
* The driver to use when running tests.
|
|
18
|
+
*/
|
|
19
|
+
driver: HotTestSeleniumDriver;
|
|
20
|
+
/**
|
|
21
|
+
* The mocha instance to run.
|
|
22
|
+
*/
|
|
23
|
+
mocha: Mocha;
|
|
24
|
+
/**
|
|
25
|
+
* The timeout for each test.
|
|
26
|
+
*/
|
|
27
|
+
timeout: number;
|
|
28
|
+
/**
|
|
29
|
+
* The suite to execute.
|
|
30
|
+
*/
|
|
31
|
+
suite: Suite;
|
|
32
|
+
/**
|
|
33
|
+
* The Mocha beforeAll event to call before any tests are executed.
|
|
34
|
+
*/
|
|
35
|
+
beforeAll: () => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* The Mocha afterAll event to call before any tests are executed.
|
|
38
|
+
*/
|
|
39
|
+
afterAll: () => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* This event is executed after the Selenium driver and url have
|
|
42
|
+
* been loaded. If this returns true, Selenium will load the url.
|
|
43
|
+
*/
|
|
44
|
+
onSetup: (driver: WebDriver, url: string) => Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* If set to true, this will wait for the tester API data. If
|
|
47
|
+
* onSetup is used, it will have to return true in order to
|
|
48
|
+
* wait for the tester data.
|
|
49
|
+
*/
|
|
50
|
+
waitForTesterData: boolean;
|
|
51
|
+
|
|
52
|
+
constructor (processor: HotStaq, name: string, baseUrl: string,
|
|
53
|
+
testMaps: { [name: string]: HotTestMap; } = {},
|
|
54
|
+
onSetup: (driver: WebDriver) => Promise<boolean> = null,
|
|
55
|
+
beforeAll: () => Promise<void> = null,
|
|
56
|
+
afterAll: () => Promise<void> = null)
|
|
57
|
+
{
|
|
58
|
+
super (processor, name, baseUrl, null, testMaps);
|
|
59
|
+
|
|
60
|
+
this.driver = new HotTestSeleniumDriver ();
|
|
61
|
+
this.mocha = null;
|
|
62
|
+
this.timeout = 10000;
|
|
63
|
+
this.suite = null;
|
|
64
|
+
this.onSetup = onSetup;
|
|
65
|
+
this.beforeAll = beforeAll;
|
|
66
|
+
this.afterAll = afterAll;
|
|
67
|
+
this.waitForTesterData = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Setup the Mocha/Selenium frameworks.
|
|
72
|
+
*
|
|
73
|
+
* @param tester The
|
|
74
|
+
* @param url If this is set, this url will be used instead of the url associated with this
|
|
75
|
+
* tester.
|
|
76
|
+
*/
|
|
77
|
+
async setup (isWebRoute: boolean, url: string = "", destinationKey: string = ""): Promise<void>
|
|
78
|
+
{
|
|
79
|
+
// Only execute web routes using Selenium.
|
|
80
|
+
if (isWebRoute === false)
|
|
81
|
+
return;
|
|
82
|
+
|
|
83
|
+
let testDriver: HotTestSeleniumDriver = (<HotTestSeleniumDriver>this.driver);
|
|
84
|
+
|
|
85
|
+
await testDriver.loadSeleniumDriver ();
|
|
86
|
+
let driver: WebDriver = testDriver.driver;
|
|
87
|
+
let loadDriverUrl: boolean = true;
|
|
88
|
+
let tempUrl: string = this.baseUrl;
|
|
89
|
+
|
|
90
|
+
if (url !== "")
|
|
91
|
+
tempUrl = url;
|
|
92
|
+
|
|
93
|
+
if (this.onSetup != null)
|
|
94
|
+
{
|
|
95
|
+
loadDriverUrl = await this.onSetup (driver, tempUrl);
|
|
96
|
+
|
|
97
|
+
if (loadDriverUrl == null)
|
|
98
|
+
loadDriverUrl = true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (loadDriverUrl === true)
|
|
102
|
+
{
|
|
103
|
+
this.finishedLoading = false;
|
|
104
|
+
await driver.get (tempUrl);
|
|
105
|
+
await this.waitForData ();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Executed when destroying this tester.
|
|
111
|
+
*/
|
|
112
|
+
async destroy (): Promise<void>
|
|
113
|
+
{
|
|
114
|
+
if (this.driver != null)
|
|
115
|
+
await this.driver.destroy ();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Executed when tests are started.
|
|
120
|
+
*/
|
|
121
|
+
async onTestStart (destination: HotDestination, url: string, destinationKey: string = ""): Promise<boolean>
|
|
122
|
+
{
|
|
123
|
+
let destinationName: string = "";
|
|
124
|
+
|
|
125
|
+
if (destinationKey !== "")
|
|
126
|
+
destinationName = ` - ${destinationKey}`;
|
|
127
|
+
|
|
128
|
+
this.mocha = new Mocha ();
|
|
129
|
+
this.suite = Mocha.Suite.create (this.mocha.suite, `${destination.page}${destinationName} Tests`);
|
|
130
|
+
this.suite.timeout (this.timeout);
|
|
131
|
+
|
|
132
|
+
if (this.beforeAll != null)
|
|
133
|
+
this.suite.beforeAll (this.beforeAll);
|
|
134
|
+
|
|
135
|
+
return (true);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async onTestPagePathStart (destination: HotDestination, page: HotTestPage,
|
|
139
|
+
stop: HotTestStop, continueWhenTestIsComplete: boolean = false): Promise<boolean>
|
|
140
|
+
{
|
|
141
|
+
let testPathName: string = stop.path;
|
|
142
|
+
|
|
143
|
+
if (continueWhenTestIsComplete === true)
|
|
144
|
+
{
|
|
145
|
+
await new Promise<void> ((resolve, reject) =>
|
|
146
|
+
{
|
|
147
|
+
this.suite.addTest (new Test (testPathName, async () =>
|
|
148
|
+
{
|
|
149
|
+
// The true is a dumb hack to prevent any recursion.
|
|
150
|
+
await this.executeTestPagePath (destination, stop, true);
|
|
151
|
+
resolve ();
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
{
|
|
157
|
+
this.suite.addTest (new Test (testPathName, async () =>
|
|
158
|
+
{
|
|
159
|
+
// The true is a dumb hack to prevent any recursion.
|
|
160
|
+
await this.executeTestPagePath (destination, stop, true);
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return (false);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async onCommand (destination: HotDestination, page: HotTestPage, stop: HotTestStop,
|
|
168
|
+
cmd: string, args: string[], cmdFunc: ((cmdArgs: string[]) => Promise<void>)): Promise<void>
|
|
169
|
+
{
|
|
170
|
+
this.suite.addTest (new Test (cmd, async () =>
|
|
171
|
+
{
|
|
172
|
+
await cmdFunc (args);
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async onTestEnd (destination: HotDestination): Promise<void>
|
|
177
|
+
{
|
|
178
|
+
return (await new Promise ((resolve, reject) =>
|
|
179
|
+
{
|
|
180
|
+
if (this.afterAll != null)
|
|
181
|
+
this.suite.afterAll (this.afterAll);
|
|
182
|
+
|
|
183
|
+
this.mocha.run ((failures: number) =>
|
|
184
|
+
{
|
|
185
|
+
resolve ();
|
|
186
|
+
});
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
}
|