@auxcode/auxta 1.3.61 → 1.3.63

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.
Files changed (32) hide show
  1. package/build/auxta/configs/config.d.ts +57 -0
  2. package/build/auxta/configs/config.js +69 -0
  3. package/build/auxta/enums/status-of.step.d.ts +7 -0
  4. package/build/auxta/enums/status-of.step.js +11 -0
  5. package/build/auxta/helpers/response.helper.d.ts +10 -0
  6. package/build/auxta/helpers/response.helper.js +15 -0
  7. package/build/auxta/helpers/start.helper.d.ts +1 -0
  8. package/build/auxta/helpers/start.helper.js +26 -0
  9. package/build/auxta/hooks/report.hook.d.ts +14 -0
  10. package/build/auxta/hooks/report.hook.js +67 -0
  11. package/build/auxta/models/upload.model.d.ts +35 -0
  12. package/build/auxta/models/upload.model.js +82 -0
  13. package/build/auxta/services/log.service.d.ts +31 -0
  14. package/build/auxta/services/log.service.js +61 -0
  15. package/build/auxta/services/report.service.d.ts +31 -0
  16. package/build/auxta/services/report.service.js +183 -0
  17. package/build/auxta/services/runtime.service.d.ts +16 -0
  18. package/build/auxta/services/runtime.service.js +41 -0
  19. package/build/auxta/utilities/runtime.helper.d.ts +15 -0
  20. package/build/auxta/utilities/runtime.helper.js +19 -0
  21. package/build/auxta/utilities/screenshot.helper.js +59 -0
  22. package/build/auxta/utilities/start-suite.helper.d.ts +17 -0
  23. package/build/auxta/utilities/start-suite.helper.js +31 -0
  24. package/build/macros/helpers/Aux2faAuth.d.ts +7 -0
  25. package/build/macros/helpers/Aux2faAuth.js +29 -0
  26. package/build/macros/helpers/AuxGoogleAuth.js +232 -0
  27. package/build/macros/helpers/code.helper.js +230 -0
  28. package/build/macros/helpers/emailHelper.js +5 -0
  29. package/build/macros/helpers/extend-default-page.d.ts +6 -0
  30. package/build/macros/helpers/extend-default-page.js +89 -0
  31. package/build/puppeteer/puppeteer.js +213 -0
  32. package/package.json +1 -1
@@ -0,0 +1,57 @@
1
+ export declare function setupConfig(jsonConfig: any): {
2
+ auxtaURL: string;
3
+ baseURL: string;
4
+ siteURL: string;
5
+ organization: string;
6
+ netlifyPath: string;
7
+ digitalProduct: string;
8
+ bucket: string;
9
+ token: string;
10
+ screenWidth: number;
11
+ screenHeight: number;
12
+ timeout: number;
13
+ suitesList: never[];
14
+ googleEmail: string;
15
+ auxtaCredentials: {
16
+ email: string;
17
+ password: string;
18
+ };
19
+ };
20
+ export declare function setupOverrideConfig(overrideConfig: any): {
21
+ auxtaURL: string;
22
+ baseURL: string;
23
+ siteURL: string;
24
+ organization: string;
25
+ netlifyPath: string;
26
+ digitalProduct: string;
27
+ bucket: string;
28
+ token: string;
29
+ screenWidth: number;
30
+ screenHeight: number;
31
+ timeout: number;
32
+ suitesList: never[];
33
+ googleEmail: string;
34
+ auxtaCredentials: {
35
+ email: string;
36
+ password: string;
37
+ };
38
+ };
39
+ export declare let config: {
40
+ auxtaURL: string;
41
+ baseURL: string;
42
+ siteURL: string;
43
+ organization: string;
44
+ netlifyPath: string;
45
+ digitalProduct: string;
46
+ bucket: string;
47
+ token: string;
48
+ screenWidth: number;
49
+ screenHeight: number;
50
+ timeout: number;
51
+ suitesList: never[];
52
+ googleEmail: string;
53
+ auxtaCredentials: {
54
+ email: string;
55
+ password: string;
56
+ };
57
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = exports.setupOverrideConfig = exports.setupConfig = void 0;
4
+ function setupConfig(jsonConfig) {
5
+ if (!jsonConfig.baseURL)
6
+ throw new Error("baseURL");
7
+ exports.config.baseURL = jsonConfig.baseURL;
8
+ if (!jsonConfig.digitalProduct)
9
+ throw new Error("digitalProduct");
10
+ exports.config.digitalProduct = jsonConfig.digitalProduct;
11
+ if (!jsonConfig.testsURL)
12
+ throw new Error("testsURL");
13
+ exports.config.bucket = jsonConfig.bucket;
14
+ if (!jsonConfig.testsURL)
15
+ throw new Error("testsURL");
16
+ exports.config.netlifyPath = (process.env.ENVIRONMENT == 'LOCAL') ? 'http://localhost:9999/' : jsonConfig.testsURL;
17
+ if (!jsonConfig.organization)
18
+ throw new Error("organization");
19
+ exports.config.organization = jsonConfig.organization;
20
+ if (!jsonConfig.email)
21
+ throw new Error("email");
22
+ exports.config.auxtaCredentials.email = jsonConfig.email;
23
+ if (!process.env.auxta_password)
24
+ throw new Error("password");
25
+ exports.config.auxtaCredentials.password = process.env.auxta_password;
26
+ if (!jsonConfig.suitesList)
27
+ throw new Error("suitesList");
28
+ exports.config.suitesList = jsonConfig.suitesList;
29
+ exports.config.googleEmail = jsonConfig.googleEmail;
30
+ if (jsonConfig.timeout)
31
+ exports.config.timeout = jsonConfig.timeout;
32
+ if (jsonConfig.screenWidth)
33
+ exports.config.screenWidth = jsonConfig.screenWidth;
34
+ if (jsonConfig.screenHeight)
35
+ exports.config.screenHeight = jsonConfig.screenHeight;
36
+ return exports.config;
37
+ }
38
+ exports.setupConfig = setupConfig;
39
+ function setupOverrideConfig(overrideConfig) {
40
+ if (overrideConfig.baseURL)
41
+ exports.config.baseURL = overrideConfig.baseURL;
42
+ if (overrideConfig.digitalProduct)
43
+ exports.config.digitalProduct = overrideConfig.digitalProduct;
44
+ if (overrideConfig.screenWidth)
45
+ exports.config.screenWidth = overrideConfig.screenWidth;
46
+ if (overrideConfig.screenHeight)
47
+ exports.config.screenHeight = overrideConfig.screenHeight;
48
+ return exports.config;
49
+ }
50
+ exports.setupOverrideConfig = setupOverrideConfig;
51
+ exports.config = {
52
+ auxtaURL: "https://auxta.live/.netlify/functions/",
53
+ baseURL: "",
54
+ siteURL: "",
55
+ organization: "",
56
+ netlifyPath: "",
57
+ digitalProduct: "",
58
+ bucket: "",
59
+ token: "",
60
+ screenWidth: 1920,
61
+ screenHeight: 1080,
62
+ timeout: 60000,
63
+ suitesList: [],
64
+ googleEmail: "",
65
+ auxtaCredentials: {
66
+ email: "",
67
+ password: "",
68
+ },
69
+ };
@@ -0,0 +1,7 @@
1
+ export declare enum StatusOfStep {
2
+ PASSED = "passed",
3
+ FAILED = "failed",
4
+ SKIPPED = "skipped",
5
+ SUGGESTION = "suggestion"
6
+ }
7
+ export default StatusOfStep;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatusOfStep = void 0;
4
+ var StatusOfStep;
5
+ (function (StatusOfStep) {
6
+ StatusOfStep["PASSED"] = "passed";
7
+ StatusOfStep["FAILED"] = "failed";
8
+ StatusOfStep["SKIPPED"] = "skipped";
9
+ StatusOfStep["SUGGESTION"] = "suggestion";
10
+ })(StatusOfStep || (exports.StatusOfStep = StatusOfStep = {}));
11
+ exports.default = StatusOfStep;
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ export declare function returnImage(code: number, screenshot: Buffer): {
3
+ isBase64Encoded: boolean;
4
+ statusCode: number;
5
+ headers: {
6
+ "Content-Type": string;
7
+ "Content-Length": string;
8
+ };
9
+ body: string;
10
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.returnImage = void 0;
4
+ function returnImage(code, screenshot) {
5
+ return {
6
+ isBase64Encoded: true,
7
+ statusCode: code,
8
+ headers: {
9
+ "Content-Type": "image/png",
10
+ "Content-Length": screenshot.length.toString()
11
+ },
12
+ body: screenshot.toString("base64")
13
+ };
14
+ }
15
+ exports.returnImage = returnImage;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const path_1 = require("path");
13
+ (() => __awaiter(void 0, void 0, void 0, function* () {
14
+ const r = /^--params\.suite=(.*)$/g;
15
+ let suite = process.argv.find(el => !!el.match(r));
16
+ if (!suite)
17
+ throw `Locale is undefined`;
18
+ let suites = suite.replace('--params.suite=', '');
19
+ let suitesArr = suites.split(',');
20
+ if (!suitesArr)
21
+ suitesArr = [suites];
22
+ for (const suite of suitesArr) {
23
+ let f = require((0, path_1.join)(process.cwd(), 'build', 'functions', 'controllers', suite));
24
+ yield f.handler();
25
+ }
26
+ }))();
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import { UploadModel } from "../models/upload.model";
3
+ export declare function onTestEnd(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer?: Buffer, errMessage?: object): Promise<{
4
+ nextSuites?: undefined;
5
+ reportId?: undefined;
6
+ currentSuite?: undefined;
7
+ retries?: undefined;
8
+ } | {
9
+ nextSuites: string[];
10
+ reportId: string | undefined;
11
+ currentSuite: string | undefined;
12
+ retries: string;
13
+ } | undefined>;
14
+ export declare function afterComplete(body: UploadModel): Promise<void>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.afterComplete = exports.onTestEnd = void 0;
16
+ const path_1 = require("path");
17
+ const log_service_1 = __importDefault(require("../services/log.service"));
18
+ const report_service_1 = require("../services/report.service");
19
+ const start_suite_helper_1 = require("../utilities/start-suite.helper");
20
+ const status_of_step_1 = require("../enums/status-of.step");
21
+ function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ let isFinal = false;
24
+ if (process.env.ENVIRONMENT == "LIVE") {
25
+ console.log('--- Uploading scenario and feature for AUXTA report ---');
26
+ const stepsArr = log_service_1.default.returnScenarioReport();
27
+ try {
28
+ const stepRes = yield (0, report_service_1.uploadStep)(stepsArr, scenarioName, screenshotBuffer, errMessage);
29
+ const scenarioRes = yield (0, report_service_1.uploadScenario)(stepRes, featureName, (0, path_1.basename)(__filename), (statusCode != 200));
30
+ const scenario = {
31
+ scenarioId: scenarioRes.scenarioRef,
32
+ scenarioName: scenarioRes.name,
33
+ scenarioUri: scenarioRes.uri,
34
+ status: scenarioRes.status,
35
+ scenariosCount: scenarioRes.scenariosCount,
36
+ lastFiveStepsHash: scenarioRes.lastFiveStepsHash
37
+ };
38
+ const stepCounts = {
39
+ failedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.FAILED),
40
+ passedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.PASSED),
41
+ skippedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SKIPPED),
42
+ suggestedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SUGGESTION)
43
+ };
44
+ isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
45
+ yield (0, report_service_1.updateReport)(body.reportId, scenario, stepCounts, isFinal);
46
+ console.log('--- Finished uploading report data to AUXTA ---');
47
+ }
48
+ catch (error) {
49
+ console.log('--- Failed to update report in AUXTA ---');
50
+ console.log(error);
51
+ }
52
+ }
53
+ if (isFinal)
54
+ yield afterComplete(body);
55
+ else if (body && body.nextSuites) {
56
+ return yield (0, start_suite_helper_1.startSuite)(body.nextSuites, body.reportId);
57
+ }
58
+ });
59
+ }
60
+ exports.onTestEnd = onTestEnd;
61
+ function afterComplete(body) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ if (process.env.ENVIRONMENT == "LIVE")
64
+ yield (0, report_service_1.postNotifications)(body);
65
+ });
66
+ }
67
+ exports.afterComplete = afterComplete;
@@ -0,0 +1,35 @@
1
+ export declare class UploadModel {
2
+ private _reportId;
3
+ private _nextSuites;
4
+ private _digitalProduct;
5
+ private _baseUrl;
6
+ private readonly _organization;
7
+ private _bucket;
8
+ private _environment;
9
+ private _currentSuite;
10
+ private _retries;
11
+ private _featureName;
12
+ private _scenarioName;
13
+ constructor(org: string, baseUrl: string, digitalProduct: string, environment: string, bucket: string);
14
+ set currentSuite(value: string);
15
+ set retries(value: number);
16
+ get currentSuite(): string;
17
+ get bucket(): string;
18
+ set bucket(value: string);
19
+ get retries(): number;
20
+ get reportId(): string;
21
+ set reportId(value: string);
22
+ get nextSuites(): [];
23
+ set nextSuites(value: []);
24
+ get digitalProduct(): string;
25
+ set digitalProduct(value: string);
26
+ get organization(): string;
27
+ get baseUrl(): string;
28
+ set baseUrl(value: string);
29
+ get environment(): string;
30
+ set environment(value: string);
31
+ get featureName(): string;
32
+ set featureName(value: string);
33
+ get scenarioName(): string;
34
+ set scenarioName(value: string);
35
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadModel = void 0;
4
+ class UploadModel {
5
+ constructor(org, baseUrl, digitalProduct, environment, bucket) {
6
+ this._reportId = '';
7
+ this._nextSuites = [];
8
+ this._currentSuite = '';
9
+ this._retries = 0;
10
+ this._organization = org;
11
+ this._bucket = bucket;
12
+ this._digitalProduct = digitalProduct;
13
+ this._environment = environment;
14
+ this._baseUrl = baseUrl;
15
+ this._featureName = '';
16
+ this._scenarioName = '';
17
+ }
18
+ set currentSuite(value) {
19
+ this._currentSuite = value;
20
+ }
21
+ set retries(value) {
22
+ this._retries = value;
23
+ }
24
+ get currentSuite() {
25
+ return this._currentSuite;
26
+ }
27
+ get bucket() {
28
+ return this._bucket;
29
+ }
30
+ set bucket(value) {
31
+ this._bucket = value;
32
+ }
33
+ get retries() {
34
+ return this._retries;
35
+ }
36
+ get reportId() {
37
+ return this._reportId;
38
+ }
39
+ set reportId(value) {
40
+ this._reportId = value;
41
+ }
42
+ get nextSuites() {
43
+ return this._nextSuites;
44
+ }
45
+ set nextSuites(value) {
46
+ this._nextSuites = value;
47
+ }
48
+ get digitalProduct() {
49
+ return this._digitalProduct;
50
+ }
51
+ set digitalProduct(value) {
52
+ this._digitalProduct = value;
53
+ }
54
+ get organization() {
55
+ return this._organization;
56
+ }
57
+ get baseUrl() {
58
+ return this._baseUrl;
59
+ }
60
+ set baseUrl(value) {
61
+ this._baseUrl = value;
62
+ }
63
+ get environment() {
64
+ return this._environment;
65
+ }
66
+ set environment(value) {
67
+ this._environment = value;
68
+ }
69
+ get featureName() {
70
+ return this._featureName;
71
+ }
72
+ set featureName(value) {
73
+ this._featureName = value;
74
+ }
75
+ get scenarioName() {
76
+ return this._scenarioName;
77
+ }
78
+ set scenarioName(value) {
79
+ this._scenarioName = value;
80
+ }
81
+ }
82
+ exports.UploadModel = UploadModel;
@@ -0,0 +1,31 @@
1
+ import { StatusOfStep } from "../enums/status-of.step";
2
+ export interface Step {
3
+ keyword: string;
4
+ name: string;
5
+ imageCompareKey: string;
6
+ result: {
7
+ status: StatusOfStep;
8
+ duration: number;
9
+ embedding?: {
10
+ data: string;
11
+ mime_type: string;
12
+ };
13
+ };
14
+ }
15
+ export declare class LogSteps {
16
+ private stepLog;
17
+ private lastStepTime;
18
+ statusCounter: {
19
+ passed: number;
20
+ failed: number;
21
+ skipped: number;
22
+ suggestion: number;
23
+ };
24
+ addSuggestion(text: string): void;
25
+ clear(): void;
26
+ push(keyword: string, name: string, status: StatusOfStep, screenshot?: string, imageCompareKey?: string): void;
27
+ returnScenarioReport(): Step[];
28
+ getStatusCount(status: StatusOfStep): number;
29
+ }
30
+ declare const log: LogSteps;
31
+ export default log;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogSteps = void 0;
4
+ const status_of_step_1 = require("../enums/status-of.step");
5
+ class LogSteps {
6
+ constructor() {
7
+ this.stepLog = [];
8
+ this.lastStepTime = new Date().getTime();
9
+ this.statusCounter = {
10
+ [status_of_step_1.StatusOfStep.PASSED]: 0,
11
+ [status_of_step_1.StatusOfStep.FAILED]: 0,
12
+ [status_of_step_1.StatusOfStep.SKIPPED]: 0,
13
+ [status_of_step_1.StatusOfStep.SUGGESTION]: 0,
14
+ };
15
+ }
16
+ addSuggestion(text) {
17
+ this.statusCounter[status_of_step_1.StatusOfStep.SUGGESTION]++;
18
+ this.stepLog.push({
19
+ keyword: 'Suggestion', name: text, imageCompareKey: '', result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
20
+ });
21
+ }
22
+ clear() {
23
+ this.stepLog = [];
24
+ this.statusCounter = {
25
+ [status_of_step_1.StatusOfStep.PASSED]: 0,
26
+ [status_of_step_1.StatusOfStep.FAILED]: 0,
27
+ [status_of_step_1.StatusOfStep.SKIPPED]: 0,
28
+ [status_of_step_1.StatusOfStep.SUGGESTION]: 0,
29
+ };
30
+ }
31
+ push(keyword, name, status, screenshot = '', imageCompareKey = '') {
32
+ console.log(`System log -- status: ${status} -- : ${name} `);
33
+ this.statusCounter[status]++;
34
+ const currentStep = new Date().getTime();
35
+ if (screenshot != '') {
36
+ const embedding = {
37
+ data: screenshot,
38
+ mime_type: "image/png"
39
+ };
40
+ this.stepLog.push({
41
+ keyword,
42
+ name,
43
+ imageCompareKey,
44
+ result: { status, duration: currentStep - this.lastStepTime, embedding: embedding }
45
+ });
46
+ }
47
+ else {
48
+ this.stepLog.push({ keyword, name, imageCompareKey, result: { status, duration: currentStep - this.lastStepTime } });
49
+ }
50
+ this.lastStepTime = currentStep;
51
+ }
52
+ returnScenarioReport() {
53
+ return this.stepLog;
54
+ }
55
+ getStatusCount(status) {
56
+ return this.statusCounter[status];
57
+ }
58
+ }
59
+ exports.LogSteps = LogSteps;
60
+ const log = new LogSteps();
61
+ exports.default = log;
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import { Step } from "./log.service";
3
+ import { UploadModel } from "../models/upload.model";
4
+ export interface Scenarios {
5
+ scenarioId: string;
6
+ scenarioName: string;
7
+ scenarioUri: string;
8
+ status: string;
9
+ scenariosCount: number;
10
+ lastFiveStepsHash: number;
11
+ }
12
+ export interface Steps {
13
+ failedSteps: number;
14
+ passedSteps: number;
15
+ skippedSteps: number;
16
+ suggestedSteps: number;
17
+ }
18
+ export declare function createEmptyReport(body: any): Promise<string>;
19
+ export declare function uploadStep(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object): Promise<{
20
+ stepRef: any;
21
+ name: any;
22
+ status: any;
23
+ stepsCount: any;
24
+ }[]>;
25
+ export declare function uploadScenario(stepRes: any[], scenarioName: string, uri: string, hasFailed: boolean): Promise<any>;
26
+ export declare function updateReport(reportId: string, scenario: Scenarios, steps: Steps, isFinal: boolean): Promise<void>;
27
+ export declare function getReport(reportId: string): Promise<any>;
28
+ export declare function getLastDayResults(): Promise<any>;
29
+ export declare function compareScreenshots(key: string, screenshot: string): Promise<any>;
30
+ export declare function postNotifications(body: UploadModel): Promise<void>;
31
+ export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;