@auxcode/auxta 1.3.51-beta.2 → 1.3.51-beta.20

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 (79) hide show
  1. package/build/{cjs/auxta → auxta}/utilities/screenshot.helper.js +2 -0
  2. package/build/{cjs/macros → macros}/helpers/AuxGoogleAuth.d.ts +6 -1
  3. package/build/{cjs/macros → macros}/helpers/AuxGoogleAuth.js +93 -1
  4. package/build/{cjs/macros → macros}/helpers/code.helper.d.ts +1 -1
  5. package/build/{cjs/macros → macros}/helpers/code.helper.js +10 -6
  6. package/build/{cjs/macros → macros}/helpers/emailHelper.js +4 -4
  7. package/build/{cjs/puppeteer → puppeteer}/puppeteer.d.ts +2 -2
  8. package/build/{cjs/puppeteer → puppeteer}/puppeteer.js +10 -7
  9. package/package.json +7 -5
  10. package/build/esm/AuxTA.d.ts +0 -62
  11. package/build/esm/AuxTA.js +0 -125
  12. package/build/esm/auxta/configs/config.d.ts +0 -57
  13. package/build/esm/auxta/configs/config.js +0 -64
  14. package/build/esm/auxta/enums/status-of.step.d.ts +0 -7
  15. package/build/esm/auxta/enums/status-of.step.js +0 -8
  16. package/build/esm/auxta/helpers/response.helper.d.ts +0 -10
  17. package/build/esm/auxta/helpers/response.helper.js +0 -11
  18. package/build/esm/auxta/helpers/start.helper.d.ts +0 -1
  19. package/build/esm/auxta/helpers/start.helper.js +0 -24
  20. package/build/esm/auxta/hooks/report.hook.d.ts +0 -14
  21. package/build/esm/auxta/hooks/report.hook.js +0 -59
  22. package/build/esm/auxta/models/upload.model.d.ts +0 -35
  23. package/build/esm/auxta/models/upload.model.js +0 -78
  24. package/build/esm/auxta/services/log.service.d.ts +0 -31
  25. package/build/esm/auxta/services/log.service.js +0 -57
  26. package/build/esm/auxta/services/report.service.d.ts +0 -31
  27. package/build/esm/auxta/services/report.service.js +0 -168
  28. package/build/esm/auxta/services/runtime.service.d.ts +0 -16
  29. package/build/esm/auxta/services/runtime.service.js +0 -37
  30. package/build/esm/auxta/utilities/runtime.helper.d.ts +0 -15
  31. package/build/esm/auxta/utilities/runtime.helper.js +0 -15
  32. package/build/esm/auxta/utilities/screenshot.helper.d.ts +0 -4
  33. package/build/esm/auxta/utilities/screenshot.helper.js +0 -49
  34. package/build/esm/auxta/utilities/start-suite.helper.d.ts +0 -17
  35. package/build/esm/auxta/utilities/start-suite.helper.js +0 -26
  36. package/build/esm/macros/helpers/Aux2faAuth.d.ts +0 -7
  37. package/build/esm/macros/helpers/Aux2faAuth.js +0 -25
  38. package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +0 -17
  39. package/build/esm/macros/helpers/AuxGoogleAuth.js +0 -100
  40. package/build/esm/macros/helpers/code.helper.d.ts +0 -23
  41. package/build/esm/macros/helpers/code.helper.js +0 -214
  42. package/build/esm/macros/helpers/emailHelper.d.ts +0 -19
  43. package/build/esm/macros/helpers/emailHelper.js +0 -170
  44. package/build/esm/macros/helpers/extend-default-page.d.ts +0 -6
  45. package/build/esm/macros/helpers/extend-default-page.js +0 -82
  46. package/build/esm/puppeteer/puppeteer.d.ts +0 -25
  47. package/build/esm/puppeteer/puppeteer.js +0 -202
  48. package/build/tsconfig-cjs.tsbuildinfo +0 -1
  49. package/build/tsconfig.tsbuildinfo +0 -1
  50. /package/build/{cjs/AuxTA.d.ts → AuxTA.d.ts} +0 -0
  51. /package/build/{cjs/AuxTA.js → AuxTA.js} +0 -0
  52. /package/build/{cjs/auxta → auxta}/configs/config.d.ts +0 -0
  53. /package/build/{cjs/auxta → auxta}/configs/config.js +0 -0
  54. /package/build/{cjs/auxta → auxta}/enums/status-of.step.d.ts +0 -0
  55. /package/build/{cjs/auxta → auxta}/enums/status-of.step.js +0 -0
  56. /package/build/{cjs/auxta → auxta}/helpers/response.helper.d.ts +0 -0
  57. /package/build/{cjs/auxta → auxta}/helpers/response.helper.js +0 -0
  58. /package/build/{cjs/auxta → auxta}/helpers/start.helper.d.ts +0 -0
  59. /package/build/{cjs/auxta → auxta}/helpers/start.helper.js +0 -0
  60. /package/build/{cjs/auxta → auxta}/hooks/report.hook.d.ts +0 -0
  61. /package/build/{cjs/auxta → auxta}/hooks/report.hook.js +0 -0
  62. /package/build/{cjs/auxta → auxta}/models/upload.model.d.ts +0 -0
  63. /package/build/{cjs/auxta → auxta}/models/upload.model.js +0 -0
  64. /package/build/{cjs/auxta → auxta}/services/log.service.d.ts +0 -0
  65. /package/build/{cjs/auxta → auxta}/services/log.service.js +0 -0
  66. /package/build/{cjs/auxta → auxta}/services/report.service.d.ts +0 -0
  67. /package/build/{cjs/auxta → auxta}/services/report.service.js +0 -0
  68. /package/build/{cjs/auxta → auxta}/services/runtime.service.d.ts +0 -0
  69. /package/build/{cjs/auxta → auxta}/services/runtime.service.js +0 -0
  70. /package/build/{cjs/auxta → auxta}/utilities/runtime.helper.d.ts +0 -0
  71. /package/build/{cjs/auxta → auxta}/utilities/runtime.helper.js +0 -0
  72. /package/build/{cjs/auxta → auxta}/utilities/screenshot.helper.d.ts +0 -0
  73. /package/build/{cjs/auxta → auxta}/utilities/start-suite.helper.d.ts +0 -0
  74. /package/build/{cjs/auxta → auxta}/utilities/start-suite.helper.js +0 -0
  75. /package/build/{cjs/macros → macros}/helpers/Aux2faAuth.d.ts +0 -0
  76. /package/build/{cjs/macros → macros}/helpers/Aux2faAuth.js +0 -0
  77. /package/build/{cjs/macros → macros}/helpers/emailHelper.d.ts +0 -0
  78. /package/build/{cjs/macros → macros}/helpers/extend-default-page.d.ts +0 -0
  79. /package/build/{cjs/macros → macros}/helpers/extend-default-page.js +0 -0
@@ -25,6 +25,7 @@ function captureScreenshot() {
25
25
  const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
26
26
  const screenshotBuffer = yield lastPage.screenshot({
27
27
  fullPage: true,
28
+ captureBeyondViewport: false,
28
29
  encoding: 'binary'
29
30
  });
30
31
  if (Buffer.isBuffer(screenshotBuffer))
@@ -43,6 +44,7 @@ function captureScreenshotPage(page) {
43
44
  try {
44
45
  const screenshotBuffer = yield page.screenshot({
45
46
  fullPage: true,
47
+ captureBeyondViewport: false,
46
48
  encoding: 'binary'
47
49
  });
48
50
  if (Buffer.isBuffer(screenshotBuffer))
@@ -5,9 +5,14 @@ export declare class AuxGoogleAuth {
5
5
  static get oAuth2Client(): googleType.Auth.OAuth2Client;
6
6
  static get googleClient(): googleType.GoogleApis;
7
7
  static get gmailClient(): googleType.gmail_v1.Gmail;
8
- static setup(): Promise<void>;
8
+ static setupBrowser(): Promise<void>;
9
+ static setEmailPassword(email: string, password: string): Promise<void>;
10
+ static setupHeadless(): Promise<void>;
9
11
  private static authorize;
12
+ private static authorizeHeadless;
10
13
  private static getNewToken;
14
+ private static getNewTokenHeadless;
15
+ private static LogIn;
11
16
  }
12
17
  declare const _default: AuxGoogleAuth;
13
18
  export default _default;
@@ -8,8 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.AuxGoogleAuth = void 0;
16
+ const config_1 = require("../../auxta/configs/config");
17
+ const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
18
+ const code_helper_1 = __importDefault(require("../helpers/code.helper"));
13
19
  const fs = require('fs');
14
20
  const readline = require('readline');
15
21
  const { google } = require("googleapis");
@@ -27,6 +33,9 @@ const SCOPES = [
27
33
  'https://www.googleapis.com/auth/gmail.insert',
28
34
  ];
29
35
  const TOKEN_PATH = 'token.json';
36
+ let TOKEN = '';
37
+ let EMAIL = '';
38
+ let PASSWORD = '';
30
39
  class AuxGoogleAuth {
31
40
  static get oAuth2Client() {
32
41
  return this._oAuth2Client;
@@ -37,11 +46,22 @@ class AuxGoogleAuth {
37
46
  static get gmailClient() {
38
47
  return google.gmail({ version: 'v1', auth: this._oAuth2Client });
39
48
  }
40
- static setup() {
49
+ static setupBrowser() {
41
50
  return __awaiter(this, void 0, void 0, function* () {
42
51
  yield this.authorize(this.credentialsJson);
43
52
  });
44
53
  }
54
+ static setEmailPassword(email, password) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ EMAIL = email;
57
+ PASSWORD = password;
58
+ });
59
+ }
60
+ static setupHeadless() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ yield this.authorizeHeadless(this.credentialsJson);
63
+ });
64
+ }
45
65
  static authorize(credentials) {
46
66
  return __awaiter(this, void 0, void 0, function* () {
47
67
  const { client_secret, client_id, redirect_uris } = credentials.installed;
@@ -60,6 +80,23 @@ class AuxGoogleAuth {
60
80
  }
61
81
  });
62
82
  }
83
+ static authorizeHeadless(credentials) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const { client_secret, client_id, redirect_uris } = credentials.installed;
86
+ const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
87
+ try {
88
+ if (TOKEN) {
89
+ oAuth2Client.setCredentials(TOKEN);
90
+ this._oAuth2Client = oAuth2Client;
91
+ return;
92
+ }
93
+ yield this.getNewTokenHeadless(oAuth2Client);
94
+ }
95
+ catch (e) {
96
+ yield this.getNewTokenHeadless(oAuth2Client);
97
+ }
98
+ });
99
+ }
63
100
  static getNewToken(oAuth2Client) {
64
101
  return __awaiter(this, void 0, void 0, function* () {
65
102
  const authUrl = oAuth2Client.generateAuthUrl({
@@ -88,6 +125,61 @@ class AuxGoogleAuth {
88
125
  });
89
126
  });
90
127
  }
128
+ static getNewTokenHeadless(oAuth2Client) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const authUrl = oAuth2Client.generateAuthUrl({
131
+ access_type: 'offline',
132
+ prompt: 'consent',
133
+ scope: SCOPES,
134
+ });
135
+ const code = yield this.LogIn(authUrl);
136
+ this._oAuth2Client = yield (new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
137
+ yield oAuth2Client.getToken(code, (err, token) => {
138
+ if (err)
139
+ return console.error('Error retrieving access token', err);
140
+ oAuth2Client.setCredentials(token);
141
+ TOKEN = token;
142
+ this._oAuth2Client = oAuth2Client;
143
+ resolve(oAuth2Client);
144
+ });
145
+ })));
146
+ console.log(this._oAuth2Client);
147
+ console.log('sdf');
148
+ });
149
+ }
150
+ static LogIn(authUrl) {
151
+ var _a, _b;
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ const context = yield puppeteer_1.default.defaultPage.browser().createIncognitoBrowserContext();
154
+ const page = yield context.newPage();
155
+ yield page.goto(authUrl);
156
+ yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
157
+ yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(EMAIL));
158
+ yield (yield page.$$('button'))[3].click();
159
+ yield code_helper_1.default.timeout(3000);
160
+ yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
161
+ yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(PASSWORD));
162
+ yield (yield page.$$('button'))[1].click();
163
+ yield code_helper_1.default.timeout(3000);
164
+ yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
165
+ yield (yield page.$$('button'))[2].click();
166
+ yield code_helper_1.default.timeout(3000);
167
+ const checkbox = yield page.$$('input[type="checkbox"]');
168
+ if (checkbox.length > 0) {
169
+ yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
170
+ yield checkbox[0].click();
171
+ yield (yield page.$$('button'))[2].click();
172
+ }
173
+ else {
174
+ yield (yield page.$$('button'))[2].click();
175
+ }
176
+ yield code_helper_1.default.timeout(3000);
177
+ const currentUrl = page.url();
178
+ const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
179
+ yield page.close();
180
+ return decodeURIComponent(code);
181
+ });
182
+ }
91
183
  }
92
184
  exports.AuxGoogleAuth = AuxGoogleAuth;
93
185
  AuxGoogleAuth.credentialsJson = {
@@ -3,7 +3,7 @@ import { ExtendDefaultPage } from "./extend-default-page";
3
3
  export declare class FunctionHelper extends ExtendDefaultPage {
4
4
  log(keyword: string, name: string, status: StatusOfStep, screenshot?: string): void;
5
5
  screenshot(page?: import("puppeteer").Page): Promise<string | undefined>;
6
- screenshotCompare(key: string, page?: import("puppeteer").Page): Promise<any>;
6
+ screenshotCompare(key: string, page?: import("puppeteer").Page): Promise<void>;
7
7
  suggest(name: string): void;
8
8
  private getEscapedText;
9
9
  clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer").Page, time?: number, log_message?: boolean): Promise<void>;
@@ -35,12 +35,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
35
35
  }
36
36
  screenshotCompare(key, page = puppeteer_1.default.defaultPage) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
39
- if (screenshotBuffer) {
40
- const screenshot = screenshotBuffer.toString('base64');
41
- log_service_1.default.push('Then', `compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, undefined, key);
42
- const comparedImage = yield (0, report_service_1.compareScreenshots)(key, screenshot);
43
- return comparedImage;
38
+ if (process.env.ENVIRONMENT !== 'LOCAL') {
39
+ const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
40
+ if (screenshotBuffer) {
41
+ const screenshot = screenshotBuffer.toString('base64');
42
+ yield (0, report_service_1.compareScreenshots)(key, screenshot);
43
+ log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, screenshot, key);
44
+ }
45
+ }
46
+ else {
47
+ log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, undefined, key);
44
48
  }
45
49
  });
46
50
  }
@@ -21,7 +21,7 @@ const MailComposer = require('nodemailer/lib/mail-composer');
21
21
  class EmailHelper {
22
22
  verifyEmail(from_name, from_email, subject, body, link = false) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
24
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
25
25
  let timeoutCount = 12000;
26
26
  while (timeoutCount <= 60000) {
27
27
  const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
@@ -76,7 +76,7 @@ class EmailHelper {
76
76
  }
77
77
  sendEmail(to, subject, body) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
79
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
80
80
  const options = {
81
81
  to: to,
82
82
  from: this.getCurrentUserEmail(),
@@ -88,7 +88,7 @@ class EmailHelper {
88
88
  }
89
89
  replyEmail(id, threadId, body) {
90
90
  return __awaiter(this, void 0, void 0, function* () {
91
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
91
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
92
92
  const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
93
93
  userId: "me",
94
94
  id: id,
@@ -148,7 +148,7 @@ class EmailHelper {
148
148
  }
149
149
  getCurrentUserEmail() {
150
150
  return __awaiter(this, void 0, void 0, function* () {
151
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
151
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
152
152
  const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
153
153
  return profile.data.emailAddress;
154
154
  });
@@ -1,7 +1,7 @@
1
1
  import { UploadModel } from "../auxta/models/upload.model";
2
- import puppeteer = require("puppeteer");
2
+ import puppeteerN = require("puppeteer");
3
3
  export declare class Puppeteer {
4
- defaultPage: puppeteer.Page;
4
+ defaultPage: puppeteerN.Page;
5
5
  private browser;
6
6
  startBrowser(): Promise<void>;
7
7
  close(): Promise<void>;
@@ -21,24 +21,27 @@ const status_of_step_1 = require("../auxta/enums/status-of.step");
21
21
  const config_1 = require("../auxta/configs/config");
22
22
  const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
23
23
  const report_service_1 = require("../auxta/services/report.service");
24
- const puppeteer = require("puppeteer");
24
+ const puppeteer = require("puppeteer-extra");
25
25
  class Puppeteer {
26
26
  startBrowser() {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- let args = [
29
- '--start-maximized'
30
- ];
28
+ let args = [];
31
29
  let env = {};
30
+ if (process.env.ENVIRONMENT === 'LOCAL') {
31
+ args.push('--start-maximized');
32
+ }
32
33
  if (process.env.ENVIRONMENT != 'LOCAL') {
33
- args.push(`--window-size=${config_1.config.screenWidth},${config_1.config.screenHeight}`);
34
+ args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
34
35
  args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
35
36
  env = {
36
37
  DISPLAY: ":10.0"
37
38
  };
38
39
  }
39
- this.browser = yield puppeteer.launch({
40
+ const StealthPlugin = require('puppeteer-extra-plugin-stealth');
41
+ puppeteer.default.use(StealthPlugin());
42
+ this.browser = yield puppeteer.default.launch({
40
43
  slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
41
- executablePath: puppeteer.executablePath(),
44
+ executablePath: puppeteer.default.executablePath(),
42
45
  args,
43
46
  env,
44
47
  ignoreDefaultArgs: ["--enable-automation"],
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.51-beta.2",
3
+ "version": "1.3.51-beta.20",
4
4
  "description": "",
5
- "main": "./build/cjs/AuxTA.js",
6
- "module": "./build/esm/AuxTA.js",
5
+ "main": "./build/AuxTA.js",
6
+ "types": "./build/AuxTA.d.ts",
7
7
  "files": [
8
8
  "build/"
9
9
  ],
10
10
  "scripts": {
11
11
  "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
12
- "prepublish": "npm run tsc",
12
+ "prepublish": "tsc",
13
13
  "test": "npm run prepublish & node ./build/AuxTA.js"
14
14
  },
15
15
  "author": "auxcode",
@@ -26,7 +26,9 @@
26
26
  "nodemailer": "^6.9.2",
27
27
  "puppeteer": "^21.3.6",
28
28
  "readline": "^1.3.0",
29
- "typescript": "^5.2.2"
29
+ "typescript": "^5.2.2",
30
+ "puppeteer-extra": "^3.3.6",
31
+ "puppeteer-extra-plugin-stealth": "^2.11.2"
30
32
  },
31
33
  "devDependencies": {
32
34
  "@babel/preset-typescript": "^7.16.0"
@@ -1,62 +0,0 @@
1
- import { Puppeteer } from "./puppeteer/puppeteer";
2
- import { FunctionHelper } from "./macros/helpers/code.helper";
3
- import StatusOfStep from "./auxta/enums/status-of.step";
4
- import { UploadModel } from "./auxta/models/upload.model";
5
- import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
6
- declare class AuxTA extends FunctionHelper {
7
- puppeteer: Puppeteer;
8
- aux2fa: import("./macros/helpers/Aux2faAuth").Aux2faAuth;
9
- google: typeof AuxGoogleAuth;
10
- config: {
11
- auxtaURL: string;
12
- baseURL: string;
13
- siteURL: string;
14
- organization: string;
15
- netlifyPath: string;
16
- digitalProduct: string;
17
- bucket: string;
18
- token: string;
19
- screenWidth: number;
20
- screenHeight: number;
21
- timeout: number;
22
- suitesList: never[];
23
- googleEmail: string;
24
- auxtaCredentials: {
25
- email: string;
26
- password: string;
27
- };
28
- };
29
- email: import("./macros/helpers/emailHelper").EmailHelper;
30
- private readonly uploadModel;
31
- constructor();
32
- run(event: any, overrideConfig?: any): Promise<{
33
- nextSuites?: undefined;
34
- reportId?: undefined;
35
- currentSuite?: undefined;
36
- retries?: undefined;
37
- } | {
38
- nextSuites: string[];
39
- reportId: string | undefined;
40
- currentSuite: string | undefined;
41
- retries: string;
42
- }>;
43
- private changeModelData;
44
- startBrowser(event: any, callback: any, feature: string, scenario: string, overrideConfig?: any, singleFeature?: boolean, fileName?: string): Promise<{
45
- nextSuites?: undefined;
46
- reportId?: undefined;
47
- currentSuite?: undefined;
48
- retries?: undefined;
49
- } | {
50
- nextSuites: string[];
51
- reportId: string | undefined;
52
- currentSuite: string | undefined;
53
- retries: string;
54
- } | {
55
- statusCode: number;
56
- } | undefined>;
57
- startBrowserRPA(event: any, callback: any, baseURL: string, fileName?: string): Promise<any>;
58
- getUploadModel(): UploadModel;
59
- }
60
- export declare const StepStatus: typeof StatusOfStep;
61
- declare const auxta: AuxTA;
62
- export default auxta;
@@ -1,125 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import puppeteer from "./puppeteer/puppeteer";
11
- import { FunctionHelper } from "./macros/helpers/code.helper";
12
- import path from "path";
13
- import fs from "fs";
14
- import StatusOfStep from "./auxta/enums/status-of.step";
15
- import { UploadModel } from "./auxta/models/upload.model";
16
- import * as dotenv from "dotenv";
17
- import { setupConfig, config as c, setupOverrideConfig } from "./auxta/configs/config";
18
- import { startSuite } from "./auxta/utilities/start-suite.helper";
19
- import { createEmptyReport } from "./auxta/services/report.service";
20
- import Aux2faAuth from "./macros/helpers/Aux2faAuth";
21
- import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
22
- import emailHelper from "./macros/helpers/emailHelper";
23
- dotenv.config();
24
- class AuxTA extends FunctionHelper {
25
- constructor() {
26
- super();
27
- this.puppeteer = puppeteer;
28
- this.aux2fa = Aux2faAuth;
29
- this.google = AuxGoogleAuth;
30
- this.config = c;
31
- this.email = emailHelper;
32
- let file;
33
- if (!process.env.RPA) {
34
- try {
35
- let currentDir = "";
36
- while (true) {
37
- file = path.join(__dirname, currentDir, "auxta.json");
38
- if (!fs.existsSync(file)) {
39
- currentDir += "../";
40
- if (currentDir.length >= 30) {
41
- console.log("auxta.json file not found!");
42
- process.exit(1);
43
- return;
44
- }
45
- continue;
46
- }
47
- break;
48
- }
49
- const jsonConfig = JSON.parse(fs.readFileSync(file).toString());
50
- try {
51
- this.config = setupConfig(jsonConfig);
52
- }
53
- catch (e) {
54
- console.log("Missing field in auxta.json:", e);
55
- }
56
- this.uploadModel = new UploadModel(jsonConfig.organization, jsonConfig.baseURL, jsonConfig.digitalProduct, jsonConfig.environment, jsonConfig.bucket);
57
- }
58
- catch (e) {
59
- console.log("Missing or corrupted config: auxta.json. Searching in location:", file);
60
- console.log(e);
61
- process.exit(1);
62
- }
63
- }
64
- else {
65
- this.uploadModel = new UploadModel('', '', '', '', '');
66
- }
67
- }
68
- run(event, overrideConfig) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- this.changeModelData(overrideConfig);
71
- let reportId;
72
- try {
73
- if (event.reportId) {
74
- reportId = event.reportId;
75
- }
76
- }
77
- catch (e) {
78
- reportId = undefined;
79
- }
80
- const suites = this.config.suitesList.slice(0);
81
- return startSuite(suites, reportId || (yield createEmptyReport(this.uploadModel)));
82
- });
83
- }
84
- changeModelData(overrideConfig) {
85
- if (overrideConfig) {
86
- if (overrideConfig.digitalProduct)
87
- this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
88
- if (overrideConfig.environment)
89
- this.uploadModel.environment = overrideConfig.environment;
90
- if (overrideConfig.baseURL)
91
- this.uploadModel.baseUrl = overrideConfig.baseURL;
92
- if (overrideConfig.bucket)
93
- this.uploadModel.bucket = overrideConfig.bucket;
94
- this.config = setupOverrideConfig(overrideConfig);
95
- }
96
- }
97
- startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false, fileName = '') {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- this.changeModelData(overrideConfig);
100
- if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
101
- this.uploadModel.reportId = yield createEmptyReport(this.uploadModel);
102
- this.uploadModel.currentSuite = fileName;
103
- this.uploadModel.nextSuites = [];
104
- }
105
- return this.puppeteer.run(event, callback, feature, scenario);
106
- });
107
- }
108
- startBrowserRPA(event, callback, baseURL, fileName = '') {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- this.changeModelData({
111
- baseURL: baseURL,
112
- environment: '',
113
- digitalProduct: ''
114
- });
115
- this.uploadModel.currentSuite = fileName;
116
- return this.puppeteer.runRPA(event, callback);
117
- });
118
- }
119
- getUploadModel() {
120
- return this.uploadModel;
121
- }
122
- }
123
- export const StepStatus = StatusOfStep;
124
- const auxta = new AuxTA();
125
- export default auxta;
@@ -1,57 +0,0 @@
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
- };
@@ -1,64 +0,0 @@
1
- export function setupConfig(jsonConfig) {
2
- if (!jsonConfig.baseURL)
3
- throw new Error("baseURL");
4
- config.baseURL = jsonConfig.baseURL;
5
- if (!jsonConfig.digitalProduct)
6
- throw new Error("digitalProduct");
7
- config.digitalProduct = jsonConfig.digitalProduct;
8
- if (!jsonConfig.testsURL)
9
- throw new Error("testsURL");
10
- config.bucket = jsonConfig.bucket;
11
- if (!jsonConfig.testsURL)
12
- throw new Error("testsURL");
13
- config.netlifyPath = (process.env.ENVIRONMENT == 'LOCAL') ? 'http://localhost:9999/' : jsonConfig.testsURL;
14
- if (!jsonConfig.organization)
15
- throw new Error("organization");
16
- config.organization = jsonConfig.organization;
17
- if (!jsonConfig.email)
18
- throw new Error("email");
19
- config.auxtaCredentials.email = jsonConfig.email;
20
- if (!process.env.auxta_password)
21
- throw new Error("password");
22
- config.auxtaCredentials.password = process.env.auxta_password;
23
- if (!jsonConfig.suitesList)
24
- throw new Error("suitesList");
25
- config.suitesList = jsonConfig.suitesList;
26
- config.googleEmail = jsonConfig.googleEmail;
27
- if (jsonConfig.timeout)
28
- config.timeout = jsonConfig.timeout;
29
- if (jsonConfig.screenWidth)
30
- config.screenWidth = jsonConfig.screenWidth;
31
- if (jsonConfig.screenHeight)
32
- config.screenHeight = jsonConfig.screenHeight;
33
- return config;
34
- }
35
- export function setupOverrideConfig(overrideConfig) {
36
- if (overrideConfig.baseURL)
37
- config.baseURL = overrideConfig.baseURL;
38
- if (overrideConfig.digitalProduct)
39
- config.digitalProduct = overrideConfig.digitalProduct;
40
- if (overrideConfig.screenWidth)
41
- config.screenWidth = overrideConfig.screenWidth;
42
- if (overrideConfig.screenHeight)
43
- config.screenHeight = overrideConfig.screenHeight;
44
- return config;
45
- }
46
- export let config = {
47
- auxtaURL: "http://localhost:8888/.netlify/functions/",
48
- baseURL: "",
49
- siteURL: "",
50
- organization: "",
51
- netlifyPath: "",
52
- digitalProduct: "",
53
- bucket: "",
54
- token: "",
55
- screenWidth: 1920,
56
- screenHeight: 1080,
57
- timeout: 60000,
58
- suitesList: [],
59
- googleEmail: "",
60
- auxtaCredentials: {
61
- email: "",
62
- password: "",
63
- },
64
- };
@@ -1,7 +0,0 @@
1
- export declare enum StatusOfStep {
2
- PASSED = "passed",
3
- FAILED = "failed",
4
- SKIPPED = "skipped",
5
- SUGGESTION = "suggestion"
6
- }
7
- export default StatusOfStep;
@@ -1,8 +0,0 @@
1
- export var StatusOfStep;
2
- (function (StatusOfStep) {
3
- StatusOfStep["PASSED"] = "passed";
4
- StatusOfStep["FAILED"] = "failed";
5
- StatusOfStep["SKIPPED"] = "skipped";
6
- StatusOfStep["SUGGESTION"] = "suggestion";
7
- })(StatusOfStep || (StatusOfStep = {}));
8
- export default StatusOfStep;
@@ -1,10 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
1
- export function returnImage(code, screenshot) {
2
- return {
3
- isBase64Encoded: true,
4
- statusCode: code,
5
- headers: {
6
- "Content-Type": "image/png",
7
- "Content-Length": screenshot.length.toString()
8
- },
9
- body: screenshot.toString("base64")
10
- };
11
- }