1 | "use strict";
|
2 |
|
3 | var _child_process = require("child_process");
|
4 |
|
5 | var _path = _interopRequireDefault(require("path"));
|
6 |
|
7 | var _shelljs = require("shelljs");
|
8 |
|
9 | var _terminate = _interopRequireDefault(require("terminate"));
|
10 |
|
11 | var _util = require("util");
|
12 |
|
13 | var _candyToolExecutable = require("./candyToolExecutable");
|
14 |
|
15 | var _clusterConfigSettingsUtils = require("./clusterConfigSettingsUtils");
|
16 |
|
17 | var _consoleApplication = require("./Commons/consoleApplication");
|
18 |
|
19 | var _NaiveArgumentParser = require("./NaiveArgumentParser");
|
20 |
|
21 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22 |
|
23 | const terminateAsync = (0, _util.promisify)(_terminate.default);
|
24 | (0, _consoleApplication.runConsoleApplication)(async () => {
|
25 | const pathToCandyApiExecutableDir = _path.default.resolve(_NaiveArgumentParser.NaiveArgumentParser.getDefaultOption(process.argv));
|
26 |
|
27 | const pathToApprovedScreenshots = _NaiveArgumentParser.NaiveArgumentParser.getNamedOption(process.argv, "approved-screenshots-directory");
|
28 |
|
29 | const replaceApprovedScreenshots = _NaiveArgumentParser.NaiveArgumentParser.getBooleanOption(process.argv, "replace-approved-screenshots");
|
30 |
|
31 | console.log(pathToCandyApiExecutableDir);
|
32 | await (0, _clusterConfigSettingsUtils.updateClusterConfigConfigurationFile)(_path.default.join(pathToCandyApiExecutableDir, "settings", "candy.api", "config"), {
|
33 | ResourcesPath: _path.default.join(__dirname, "..", "Tests", "TestForms", "TestResources"),
|
34 | ResourcesDefaultPath: _path.default.join(__dirname, "..", "Tests", "TestForms", "TestResources"),
|
35 | UseTestClassification: "true",
|
36 | KonturDomains: "*|*:*",
|
37 | ServiceDiscoveryZone: "teamcity-agents"
|
38 | });
|
39 | (0, _shelljs.pushd)(_path.default.join(__dirname, "..", "Tests", "TestForms", "TestFarm"));
|
40 | (0, _shelljs.exec)(`npx ${(0, _candyToolExecutable.getPathCandyToolExecutable)()} dev-build --no-reformat *`);
|
41 | (0, _shelljs.popd)();
|
42 | const child = (0, _child_process.spawn)(_path.default.join(pathToCandyApiExecutableDir, "Candy.Api.exe"), [], {
|
43 | cwd: pathToCandyApiExecutableDir,
|
44 | shell: true
|
45 | });
|
46 | (0, _shelljs.rm)(_path.default.join(pathToCandyApiExecutableDir, "settings", "ClusterConfig"));
|
47 | console.log(`Started candy api process: PID: ${child.pid}`);
|
48 | const args = ["--remote-selenium", "--reporter", "mocha-teamcity-reporter"];
|
49 |
|
50 | if (process.argv.includes("--approve")) {
|
51 | args.push("--approve");
|
52 | }
|
53 |
|
54 | if (pathToApprovedScreenshots != undefined) {
|
55 | args.push("--approved-screenshots-directory", _path.default.resolve(pathToApprovedScreenshots));
|
56 | }
|
57 |
|
58 | if (replaceApprovedScreenshots != undefined) {
|
59 | args.push("--replace-approved-screenshots");
|
60 | }
|
61 |
|
62 | try {
|
63 | (0, _shelljs.exec)(`npm run screenshot:test -- ${[...args, "--firefox"].join(" ")}`);
|
64 | (0, _shelljs.exec)(`npm run screenshot:test -- ${[...args, "--chrome"].join(" ")}`);
|
65 | } finally {
|
66 | console.log(`Killing canyd api process: PID: ${child.pid}`);
|
67 | await terminateAsync(child.pid);
|
68 | }
|
69 | });
|
70 |
|
\ | No newline at end of file |