@auxcode/auxta 1.3.19-beta.9 → 1.3.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.
- package/README.md +23 -3
- package/build/cjs/macros/helpers/AuxGoogleAuth.js +0 -1
- package/build/cjs/macros/helpers/code.helper.d.ts +2 -0
- package/build/cjs/macros/helpers/code.helper.js +47 -0
- package/build/esm/macros/helpers/AuxGoogleAuth.js +0 -1
- package/build/esm/macros/helpers/code.helper.d.ts +2 -0
- package/build/esm/macros/helpers/code.helper.js +47 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/cjs/macros/helpers/google.code.helper.d.ts +0 -7
- package/build/cjs/macros/helpers/google.code.helper.js +0 -58
- package/build/esm/macros/helpers/google.code.helper.d.ts +0 -7
- package/build/esm/macros/helpers/google.code.helper.js +0 -54
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AuxTA
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Implementing
|
|
4
4
|
|
|
5
5
|
The main thing is a `scenario`.
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ The main thing is a `scenario`.
|
|
|
10
10
|
|
|
11
11
|
All clicks wait for the selector by default and timeout w/ the standard timeout unless different is specified.
|
|
12
12
|
|
|
13
|
-
`timeout` It is recommended to have a standard timeout for the whole scenario and not to define spefici. `TODO`
|
|
13
|
+
`timeout` It is recommended to have a standard timeout for the whole scenario and not to define spefici. `TODO`
|
|
14
14
|
|
|
15
15
|
auxta.clickByText `TO BE FIXED BY GEORGE TO ADD THE WAIT FOR SELECTOR WHICH IS MISSING`
|
|
16
16
|
|
|
@@ -20,7 +20,27 @@ auxta.clickByClass
|
|
|
20
20
|
|
|
21
21
|
auxta.click() `THINK TO MAKE` `TODO`
|
|
22
22
|
|
|
23
|
-
waitforseelctorbytext `depreciated`
|
|
23
|
+
waitforseelctorbytext `depreciated`
|
|
24
|
+
|
|
25
|
+
### Complex Workflows
|
|
26
|
+
|
|
27
|
+
#### Email
|
|
28
|
+
|
|
29
|
+
* (AuxTA) We do some action on the website.
|
|
30
|
+
* (Website) Sends an email to the email address of the user who did the action.
|
|
31
|
+
* (AuxTA) Should check that that the email was correctly sent. So we check:
|
|
32
|
+
* `auxta.checkMail(_from_name_, _from_email_, _subject_, _body_text_)`
|
|
33
|
+
* The email login is in the main config of the test suite.
|
|
34
|
+
* email
|
|
35
|
+
* API TOKEN
|
|
36
|
+
* For the moment we do it synchroneous (AuxTA waits for the email).
|
|
37
|
+
* The email must be newser than the time of the action on the Website.
|
|
38
|
+
* Must be _from_name_ (substring)
|
|
39
|
+
* Must be _from_email_ (substring)
|
|
40
|
+
* Must have _subject_ (substring)
|
|
41
|
+
* Must cotnain _body_text_ (substring)
|
|
42
|
+
* Quality of Service, if the email does not arrive w/in eg. 5 minutes we return an error w/ timeout.
|
|
43
|
+
* * `auxta.clickInMail(_from_name_, _from_email_, _subject_, _click_on_)`
|
|
24
44
|
|
|
25
45
|
## Running
|
|
26
46
|
|
|
@@ -24,7 +24,6 @@ const SCOPES = [
|
|
|
24
24
|
'https://www.googleapis.com/auth/gmail.modify',
|
|
25
25
|
'https://www.googleapis.com/auth/gmail.compose',
|
|
26
26
|
'https://www.googleapis.com/auth/gmail.readonly',
|
|
27
|
-
'https://www.googleapis.com/auth/gmail.metadata',
|
|
28
27
|
'https://www.googleapis.com/auth/gmail.insert',
|
|
29
28
|
];
|
|
30
29
|
const TOKEN_PATH = 'token.json';
|
|
@@ -16,6 +16,8 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
16
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
17
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
18
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
+
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
private getHeader;
|
|
19
21
|
}
|
|
20
22
|
declare const _default: FunctionHelper;
|
|
21
23
|
export default _default;
|
|
@@ -19,6 +19,7 @@ const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
|
19
19
|
const AuxTA_1 = require("../../AuxTA");
|
|
20
20
|
const extend_default_page_1 = require("./extend-default-page");
|
|
21
21
|
const puppeteer_2 = require("puppeteer");
|
|
22
|
+
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
22
23
|
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
23
24
|
log(keyword, name, status) {
|
|
24
25
|
log_service_1.default.push(keyword, name, status);
|
|
@@ -187,6 +188,52 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
187
188
|
yield loginPage.waitForNetworkIdle();
|
|
188
189
|
});
|
|
189
190
|
}
|
|
191
|
+
clickInMail(from_name, from_email, subject) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
194
|
+
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
195
|
+
userId: "me",
|
|
196
|
+
maxResults: 3
|
|
197
|
+
});
|
|
198
|
+
const messagesIds = res.data.messages;
|
|
199
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
200
|
+
throw new Error('No messagesIds found.');
|
|
201
|
+
}
|
|
202
|
+
let timeoutCount = 12000;
|
|
203
|
+
yield this.timeout(12000);
|
|
204
|
+
while (timeoutCount <= 60000) {
|
|
205
|
+
for (const messageId of messagesIds) {
|
|
206
|
+
if (messageId.id) {
|
|
207
|
+
const message = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
208
|
+
userId: "me",
|
|
209
|
+
id: messageId.id.toString(),
|
|
210
|
+
format: 'FULL'
|
|
211
|
+
});
|
|
212
|
+
if (message.data.payload) {
|
|
213
|
+
const message_sender = this.getHeader('from', message.data.payload.headers);
|
|
214
|
+
const message_subject = this.getHeader('subject', message.data.payload.headers);
|
|
215
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) && message_subject.includes(subject.toLocaleLowerCase())) {
|
|
216
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, AuxTA_1.StepStatus.PASSED);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
yield this.timeout(12000);
|
|
224
|
+
timeoutCount += 12000;
|
|
225
|
+
}
|
|
226
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, AuxTA_1.StepStatus.PASSED);
|
|
227
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} is found`);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
getHeader(value, headers) {
|
|
231
|
+
for (const header of headers) {
|
|
232
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
233
|
+
return header.value.toLocaleLowerCase();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
190
237
|
}
|
|
191
238
|
exports.FunctionHelper = FunctionHelper;
|
|
192
239
|
exports.default = new FunctionHelper();
|
|
@@ -21,7 +21,6 @@ const SCOPES = [
|
|
|
21
21
|
'https://www.googleapis.com/auth/gmail.modify',
|
|
22
22
|
'https://www.googleapis.com/auth/gmail.compose',
|
|
23
23
|
'https://www.googleapis.com/auth/gmail.readonly',
|
|
24
|
-
'https://www.googleapis.com/auth/gmail.metadata',
|
|
25
24
|
'https://www.googleapis.com/auth/gmail.insert',
|
|
26
25
|
];
|
|
27
26
|
const TOKEN_PATH = 'token.json';
|
|
@@ -16,6 +16,8 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
16
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
17
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
18
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
+
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
private getHeader;
|
|
19
21
|
}
|
|
20
22
|
declare const _default: FunctionHelper;
|
|
21
23
|
export default _default;
|
|
@@ -13,6 +13,7 @@ import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
|
13
13
|
import { StepStatus } from "../../AuxTA";
|
|
14
14
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
15
15
|
import { KnownDevices } from "puppeteer";
|
|
16
|
+
import { AuxGoogleAuth } from "./AuxGoogleAuth";
|
|
16
17
|
export class FunctionHelper extends ExtendDefaultPage {
|
|
17
18
|
log(keyword, name, status) {
|
|
18
19
|
log.push(keyword, name, status);
|
|
@@ -181,5 +182,51 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
181
182
|
yield loginPage.waitForNetworkIdle();
|
|
182
183
|
});
|
|
183
184
|
}
|
|
185
|
+
clickInMail(from_name, from_email, subject) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
yield AuxGoogleAuth.setup();
|
|
188
|
+
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
189
|
+
userId: "me",
|
|
190
|
+
maxResults: 3
|
|
191
|
+
});
|
|
192
|
+
const messagesIds = res.data.messages;
|
|
193
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
194
|
+
throw new Error('No messagesIds found.');
|
|
195
|
+
}
|
|
196
|
+
let timeoutCount = 12000;
|
|
197
|
+
yield this.timeout(12000);
|
|
198
|
+
while (timeoutCount <= 60000) {
|
|
199
|
+
for (const messageId of messagesIds) {
|
|
200
|
+
if (messageId.id) {
|
|
201
|
+
const message = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
202
|
+
userId: "me",
|
|
203
|
+
id: messageId.id.toString(),
|
|
204
|
+
format: 'FULL'
|
|
205
|
+
});
|
|
206
|
+
if (message.data.payload) {
|
|
207
|
+
const message_sender = this.getHeader('from', message.data.payload.headers);
|
|
208
|
+
const message_subject = this.getHeader('subject', message.data.payload.headers);
|
|
209
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) && message_subject.includes(subject.toLocaleLowerCase())) {
|
|
210
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, StepStatus.PASSED);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
yield this.timeout(12000);
|
|
218
|
+
timeoutCount += 12000;
|
|
219
|
+
}
|
|
220
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, StepStatus.PASSED);
|
|
221
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} is found`);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
getHeader(value, headers) {
|
|
225
|
+
for (const header of headers) {
|
|
226
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
227
|
+
return header.value.toLocaleLowerCase();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
184
231
|
}
|
|
185
232
|
export default new FunctionHelper();
|