@auxcode/auxta 1.3.65 → 1.3.67

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.
@@ -18,22 +18,28 @@ const log_service_1 = __importDefault(require("../services/log.service"));
18
18
  const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
19
19
  function captureScreenshot() {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- try {
22
- const pages = yield puppeteer_1.default.defaultPage.browser().pages();
23
- if (!pages.length)
24
- return undefined;
25
- const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
26
- const screenshotBuffer = yield lastPage.screenshot({
27
- fullPage: true,
28
- captureBeyondViewport: false,
29
- encoding: 'binary'
30
- });
31
- if (Buffer.isBuffer(screenshotBuffer))
32
- return screenshotBuffer;
33
- }
34
- catch (e) {
35
- log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
36
- return undefined;
21
+ let count = 0;
22
+ while (count <= 10) {
23
+ try {
24
+ const pages = yield puppeteer_1.default.defaultPage.browser().pages();
25
+ if (!pages.length)
26
+ return undefined;
27
+ const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
28
+ const screenshotBuffer = yield lastPage.screenshot({
29
+ fullPage: true,
30
+ captureBeyondViewport: false,
31
+ encoding: 'binary'
32
+ });
33
+ if (Buffer.isBuffer(screenshotBuffer))
34
+ return screenshotBuffer;
35
+ }
36
+ catch (e) {
37
+ if (count == 10) {
38
+ log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
39
+ return undefined;
40
+ }
41
+ }
42
+ count++;
37
43
  }
38
44
  return undefined;
39
45
  });
@@ -37,48 +37,57 @@ class EmailHelper {
37
37
  if (!messagesIds || messagesIds.length === 0) {
38
38
  throw new Error('No messagesIds found.');
39
39
  }
40
- const runs = [];
40
+ log_service_1.default.push('Then', `Getting the full details of the emails`, AuxTA_1.StepStatus.PASSED);
41
41
  for (const messageId of messagesIds) {
42
42
  if (messageId.id) {
43
- runs.push(yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
44
- userId: "me",
45
- id: messageId.id.toString(),
46
- format: 'FULL'
47
- }));
48
- }
49
- }
50
- yield Promise.all(runs);
51
- log_service_1.default.push('Then', `Getting the full details of the emails`, AuxTA_1.StepStatus.PASSED);
52
- for (const gmailResponse of runs) {
53
- if (gmailResponse) {
54
- if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
55
- const message_sender = this.getHeader('from', gmailResponse);
56
- const message_subject = this.getHeader('subject', gmailResponse);
57
- const message_body = this.getBody(subject, gmailResponse);
58
- if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
59
- message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
60
- log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
61
- yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
62
- userId: "me",
63
- id: gmailResponse.data.id,
64
- requestBody: {
65
- 'addLabelIds': [],
66
- 'removeLabelIds': ['UNREAD']
67
- }
68
- });
69
- if (link) {
70
- const html_link = yield this.getUrl(message_body);
71
- yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.delete({
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({
72
67
  userId: "me",
73
68
  id: gmailResponse.data.id,
69
+ requestBody: {
70
+ 'addLabelIds': [],
71
+ 'removeLabelIds': ['UNREAD']
72
+ }
74
73
  });
75
- return {
76
- id: gmailResponse.data.id,
77
- threadId: gmailResponse.data.threadId,
78
- link: html_link
79
- };
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: '' };
80
90
  }
81
- return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
82
91
  }
83
92
  }
84
93
  }
@@ -42,7 +42,6 @@ class Puppeteer {
42
42
  this.browser = yield puppeteer.default.launch({
43
43
  slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
44
44
  executablePath: puppeteer.default.executablePath(),
45
- protocolTimeout: 50000,
46
45
  args,
47
46
  env,
48
47
  ignoreDefaultArgs: ["--enable-automation"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.65",
3
+ "version": "1.3.67",
4
4
  "description": "",
5
5
  "main": "./build/AuxTA.js",
6
6
  "types": "./build/AuxTA.d.ts",