@auxcode/auxta 1.3.52 → 1.3.53-beta.0
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.
|
@@ -145,11 +145,11 @@ function compareScreenshots(key, screenshot) {
|
|
|
145
145
|
data: screenshot,
|
|
146
146
|
mime_type: "image/png"
|
|
147
147
|
};
|
|
148
|
-
return yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
|
|
148
|
+
return (yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
|
|
149
149
|
organization: config_1.config.organization,
|
|
150
150
|
key: key,
|
|
151
151
|
embedding: embedding,
|
|
152
|
-
}, headers(token));
|
|
152
|
+
}, headers(token))).data;
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
exports.compareScreenshots = compareScreenshots;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,6 +42,7 @@ const code_helper_1 = __importDefault(require("../helpers/code.helper"));
|
|
|
19
42
|
const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
|
|
20
43
|
const fs = require('fs');
|
|
21
44
|
const readline = require('readline');
|
|
45
|
+
const process = __importStar(require("process"));
|
|
22
46
|
const { google } = require("googleapis");
|
|
23
47
|
const SCOPES = [
|
|
24
48
|
'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
|
|
@@ -34,9 +58,9 @@ const SCOPES = [
|
|
|
34
58
|
'https://www.googleapis.com/auth/gmail.insert',
|
|
35
59
|
];
|
|
36
60
|
const TOKEN_PATH = 'token.json';
|
|
37
|
-
let TOKEN
|
|
38
|
-
let EMAIL
|
|
39
|
-
let PASSWORD
|
|
61
|
+
let TOKEN;
|
|
62
|
+
let EMAIL;
|
|
63
|
+
let PASSWORD;
|
|
40
64
|
class AuxGoogleAuth {
|
|
41
65
|
static get oAuth2Client() {
|
|
42
66
|
return this._oAuth2Client;
|
|
@@ -150,35 +174,44 @@ class AuxGoogleAuth {
|
|
|
150
174
|
static LogIn(authUrl) {
|
|
151
175
|
var _a, _b;
|
|
152
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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();
|
|
177
|
+
const email = EMAIL ? EMAIL : process.env.google_account;
|
|
178
|
+
const password = PASSWORD ? PASSWORD : process.env.google_password;
|
|
179
|
+
if (email && password) {
|
|
180
|
+
const context = yield puppeteer_1.default.defaultPage.browser().createIncognitoBrowserContext();
|
|
181
|
+
const page = yield context.newPage();
|
|
182
|
+
yield page.goto(authUrl);
|
|
183
|
+
yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
|
|
184
|
+
yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(email));
|
|
185
|
+
yield (yield page.$$('button'))[3].click();
|
|
186
|
+
yield code_helper_1.default.timeout(3000);
|
|
187
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
|
|
188
|
+
yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(password));
|
|
189
|
+
yield (yield page.$$('button'))[1].click();
|
|
190
|
+
yield code_helper_1.default.timeout(3000);
|
|
191
|
+
yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
|
|
171
192
|
yield (yield page.$$('button'))[2].click();
|
|
193
|
+
yield code_helper_1.default.timeout(3000);
|
|
194
|
+
const checkbox = yield page.$$('input[type="checkbox"]');
|
|
195
|
+
if (checkbox.length > 0) {
|
|
196
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
|
|
197
|
+
yield checkbox[0].click();
|
|
198
|
+
yield (yield page.$$('button'))[2].click();
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page);
|
|
202
|
+
yield (yield page.$$('button'))[2].click();
|
|
203
|
+
}
|
|
204
|
+
yield code_helper_1.default.timeout(3000);
|
|
205
|
+
yield code_helper_1.default.waitForSelector('visible', '#app', config_1.config.timeout, page);
|
|
206
|
+
const currentUrl = page.url();
|
|
207
|
+
const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
|
|
208
|
+
code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
|
|
209
|
+
yield page.close();
|
|
210
|
+
return decodeURIComponent(code);
|
|
172
211
|
}
|
|
173
212
|
else {
|
|
174
|
-
|
|
213
|
+
throw new Error('The email or password for the google account are empty');
|
|
175
214
|
}
|
|
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
|
-
code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
|
|
180
|
-
yield page.close();
|
|
181
|
-
return decodeURIComponent(code);
|
|
182
215
|
});
|
|
183
216
|
}
|
|
184
217
|
}
|
|
@@ -39,8 +39,13 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
39
39
|
const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
|
|
40
40
|
if (screenshotBuffer) {
|
|
41
41
|
const screenshot = screenshotBuffer.toString('base64');
|
|
42
|
-
yield (0, report_service_1.compareScreenshots)(key, screenshot);
|
|
43
|
-
|
|
42
|
+
const result = yield (0, report_service_1.compareScreenshots)(key, screenshot);
|
|
43
|
+
if (result.presentDifference && Number(result.presentDifference) > 2) {
|
|
44
|
+
log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.FAILED, screenshot, key);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, screenshot, key);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
else {
|
|
@@ -23,10 +23,11 @@ class EmailHelper {
|
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
25
25
|
let timeoutCount = 12000;
|
|
26
|
+
yield new Promise(r => setTimeout(r, 45000));
|
|
26
27
|
while (timeoutCount <= 60000) {
|
|
27
28
|
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
28
29
|
userId: "me",
|
|
29
|
-
maxResults:
|
|
30
|
+
maxResults: 10
|
|
30
31
|
});
|
|
31
32
|
const messagesIds = res.data.messages;
|
|
32
33
|
if (!messagesIds || messagesIds.length === 0) {
|