@auxcode/auxta 1.3.78-beta.112 → 1.3.78-beta.114
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/build/auxta/services/report.service.d.ts +1 -0
- package/build/auxta/services/report.service.js +14 -1
- package/build/auxta/utilities/screenshot.helper.js +43 -19
- package/build/macros/helpers/emailHelper.d.ts +1 -10
- package/build/macros/helpers/emailHelper.js +12 -156
- package/package.json +1 -1
|
@@ -29,3 +29,4 @@ export declare function getLastDayResults(): Promise<any>;
|
|
|
29
29
|
export declare function compareScreenshots(key: string, screenshot: string): Promise<any>;
|
|
30
30
|
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
31
31
|
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|
|
32
|
+
export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.postNotificationsOnFail = exports.postNotifications = exports.compareScreenshots = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadScenario = exports.uploadStep = exports.createEmptyReport = void 0;
|
|
15
|
+
exports.getVerifyReceivedEmail = exports.postNotificationsOnFail = exports.postNotifications = exports.compareScreenshots = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadScenario = exports.uploadStep = exports.createEmptyReport = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const config_1 = require("../configs/config");
|
|
18
18
|
function headers(token) {
|
|
@@ -183,3 +183,16 @@ function postNotificationsOnFail(body) {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
exports.postNotificationsOnFail = postNotificationsOnFail;
|
|
186
|
+
function getVerifyReceivedEmail(from_name, from_email, subject, body, link) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
let token = yield auth();
|
|
189
|
+
return yield axios_1.default.post(`${config_1.config.auxtaURL}get-verify-received-email`, {
|
|
190
|
+
from_name: from_name,
|
|
191
|
+
from_email: from_email,
|
|
192
|
+
subject: subject,
|
|
193
|
+
body: body,
|
|
194
|
+
link: link
|
|
195
|
+
}, headers(token));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
exports.getVerifyReceivedEmail = getVerifyReceivedEmail;
|
|
@@ -19,28 +19,52 @@ const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
|
|
|
19
19
|
const RETRY_NUMBERS = 10;
|
|
20
20
|
function captureScreenshot() {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
23
|
+
if (!pages.length)
|
|
24
|
+
return undefined;
|
|
25
|
+
for (let i = 0; i < pages.length; i++) {
|
|
26
|
+
const page = pages[i];
|
|
27
|
+
if ((pages.length - 1) == i) {
|
|
28
|
+
let count = 0;
|
|
29
|
+
while (count <= RETRY_NUMBERS) {
|
|
30
|
+
try {
|
|
31
|
+
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
32
|
+
const screenshotBuffer = yield lastPage.screenshot({
|
|
33
|
+
captureBeyondViewport: false,
|
|
34
|
+
encoding: 'binary'
|
|
35
|
+
});
|
|
36
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
37
|
+
return screenshotBuffer;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (count == RETRY_NUMBERS) {
|
|
41
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
count++;
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
else {
|
|
49
|
+
let count = 0;
|
|
50
|
+
while (count <= RETRY_NUMBERS) {
|
|
51
|
+
try {
|
|
52
|
+
const screenshotBuffer = yield page.screenshot({
|
|
53
|
+
captureBeyondViewport: false,
|
|
54
|
+
encoding: 'binary'
|
|
55
|
+
});
|
|
56
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
57
|
+
log_service_1.default.push("When", `${i} Image`, status_of_step_1.default.FAILED, screenshotBuffer.toString("base64"));
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
if (count == RETRY_NUMBERS) {
|
|
61
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
count++;
|
|
41
66
|
}
|
|
42
67
|
}
|
|
43
|
-
count++;
|
|
44
68
|
}
|
|
45
69
|
return undefined;
|
|
46
70
|
});
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
export declare class EmailHelper {
|
|
2
2
|
verifyEmail(from_name: string, from_email: string, subject: string, body: string, link?: boolean): Promise<{
|
|
3
|
-
|
|
4
|
-
threadId: string;
|
|
5
|
-
link: string;
|
|
3
|
+
link: any;
|
|
6
4
|
} | undefined>;
|
|
7
|
-
sendEmail(to: string, subject: string, body: string): Promise<void>;
|
|
8
|
-
replyEmail(id: string, threadId: string, body: string): Promise<void>;
|
|
9
|
-
private static send;
|
|
10
|
-
private getHeader;
|
|
11
|
-
private getBody;
|
|
12
|
-
private getCurrentUserEmail;
|
|
13
|
-
private getUrl;
|
|
14
5
|
}
|
|
15
6
|
declare const _default: EmailHelper;
|
|
16
7
|
export default _default;
|
|
@@ -16,8 +16,7 @@ exports.EmailHelper = void 0;
|
|
|
16
16
|
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
17
|
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
18
18
|
const AuxTA_1 = require("../../AuxTA");
|
|
19
|
-
const
|
|
20
|
-
const MailComposer = require('nodemailer/lib/mail-composer');
|
|
19
|
+
const report_service_1 = require("../../auxta/services/report.service");
|
|
21
20
|
class EmailHelper {
|
|
22
21
|
verifyEmail(from_name, from_email, subject, body, link = false) {
|
|
23
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -28,70 +27,19 @@ class EmailHelper {
|
|
|
28
27
|
yield new Promise(r => setTimeout(r, 35000));
|
|
29
28
|
let timeoutCount = 12000;
|
|
30
29
|
while (timeoutCount <= 60000) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const messageId of messagesIds) {
|
|
42
|
-
if (messageId.id) {
|
|
43
|
-
let gmailResponse;
|
|
44
|
-
try {
|
|
45
|
-
gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
46
|
-
userId: "me",
|
|
47
|
-
id: messageId.id.toString(),
|
|
48
|
-
format: 'FULL'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (gmailResponse) {
|
|
55
|
-
log_service_1.default.push('Then', `I check payload && id && threadId`, AuxTA_1.StepStatus.PASSED);
|
|
56
|
-
if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
|
|
57
|
-
const message_sender = this.getHeader('from', gmailResponse);
|
|
58
|
-
log_service_1.default.push('Then', `I got message_sender`, AuxTA_1.StepStatus.PASSED);
|
|
59
|
-
const message_subject = this.getHeader('subject', gmailResponse);
|
|
60
|
-
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
61
|
-
const message_body = this.getBody(subject, gmailResponse);
|
|
62
|
-
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
63
|
-
if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
|
|
64
|
-
message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
|
|
65
|
-
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
66
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
67
|
-
userId: "me",
|
|
68
|
-
id: gmailResponse.data.id,
|
|
69
|
-
requestBody: {
|
|
70
|
-
'addLabelIds': [],
|
|
71
|
-
'removeLabelIds': ['UNREAD']
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
log_service_1.default.push('Then', `I got modify email`, AuxTA_1.StepStatus.PASSED);
|
|
75
|
-
if (link) {
|
|
76
|
-
const html_link = yield this.getUrl(message_body);
|
|
77
|
-
log_service_1.default.push('Then', `I get html lik`, AuxTA_1.StepStatus.PASSED);
|
|
78
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.delete({
|
|
79
|
-
userId: "me",
|
|
80
|
-
id: gmailResponse.data.id,
|
|
81
|
-
});
|
|
82
|
-
log_service_1.default.push('Then', `I deleted email`, AuxTA_1.StepStatus.PASSED);
|
|
83
|
-
return {
|
|
84
|
-
id: gmailResponse.data.id,
|
|
85
|
-
threadId: gmailResponse.data.threadId,
|
|
86
|
-
link: html_link
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
30
|
+
try {
|
|
31
|
+
const links = yield (0, report_service_1.getVerifyReceivedEmail)(from_name, from_email, subject, body, link);
|
|
32
|
+
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
33
|
+
if (links) {
|
|
34
|
+
return {
|
|
35
|
+
link: links.data.link
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return;
|
|
93
40
|
}
|
|
94
41
|
}
|
|
42
|
+
catch (e) { }
|
|
95
43
|
log_service_1.default.push('Then', `Failed two get the email with the given criteria and waiting 12 seconds`, AuxTA_1.StepStatus.PASSED);
|
|
96
44
|
yield new Promise(r => setTimeout(r, timeoutCount));
|
|
97
45
|
timeoutCount += 12000;
|
|
@@ -103,98 +51,6 @@ class EmailHelper {
|
|
|
103
51
|
}
|
|
104
52
|
});
|
|
105
53
|
}
|
|
106
|
-
sendEmail(to, subject, body) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
109
|
-
const options = {
|
|
110
|
-
to: to,
|
|
111
|
-
from: this.getCurrentUserEmail(),
|
|
112
|
-
subject: subject,
|
|
113
|
-
html: body
|
|
114
|
-
};
|
|
115
|
-
yield EmailHelper.send(options);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
replyEmail(id, threadId, body) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
121
|
-
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
122
|
-
userId: "me",
|
|
123
|
-
id: id,
|
|
124
|
-
format: 'FULL'
|
|
125
|
-
});
|
|
126
|
-
if (gmailResponse.data.payload) {
|
|
127
|
-
const message_subject = this.getHeader('subject', gmailResponse);
|
|
128
|
-
const message_messageID = this.getHeader('Message-ID', gmailResponse);
|
|
129
|
-
const reply_to = this.getHeader('reply-to', gmailResponse);
|
|
130
|
-
const options = {
|
|
131
|
-
to: reply_to,
|
|
132
|
-
from: this.getCurrentUserEmail(),
|
|
133
|
-
subject: `Re: ${message_subject}`,
|
|
134
|
-
references: message_messageID,
|
|
135
|
-
inReplyTo: [message_messageID],
|
|
136
|
-
html: body
|
|
137
|
-
};
|
|
138
|
-
yield EmailHelper.send(options, threadId);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
static send(options, threadId) {
|
|
143
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
const mailComposer = new MailComposer(options);
|
|
145
|
-
const message = yield mailComposer.compile().build();
|
|
146
|
-
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
147
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
148
|
-
userId: "me",
|
|
149
|
-
requestBody: {
|
|
150
|
-
threadId: threadId,
|
|
151
|
-
raw: encodeMessage
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
getHeader(value, headers) {
|
|
157
|
-
for (const header of headers.data.payload.headers) {
|
|
158
|
-
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
159
|
-
return header.value;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
getBody(subject, gmailResponse) {
|
|
164
|
-
try {
|
|
165
|
-
let decodedBody = '';
|
|
166
|
-
for (let i = 0; i < gmailResponse.data.payload.parts.length; i++) {
|
|
167
|
-
const part = gmailResponse.data.payload.parts[i].body;
|
|
168
|
-
if (part.size > 0) {
|
|
169
|
-
decodedBody += base64.decode(part.data);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (decodedBody) {
|
|
173
|
-
return decodedBody;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return '';
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
catch (e) {
|
|
180
|
-
console.log(e);
|
|
181
|
-
throw new Error(`Email with subject: ${subject} body ${gmailResponse.data.payload.parts[0].body.data} is empty`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
getCurrentUserEmail() {
|
|
185
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
187
|
-
const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
|
|
188
|
-
return profile.data.emailAddress;
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
getUrl(body) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
const httpsStartIndex = body.indexOf('https');
|
|
194
|
-
const bodyHttpsStartIndexString = body.toString().substring(httpsStartIndex);
|
|
195
|
-
return bodyHttpsStartIndexString.substring(0, bodyHttpsStartIndexString.indexOf(' ')).replace('"', '');
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
54
|
}
|
|
199
55
|
exports.EmailHelper = EmailHelper;
|
|
200
56
|
exports.default = new EmailHelper();
|