-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstore_test.js
80 lines (65 loc) · 2.48 KB
/
store_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*let accounts = new DataTable(['email', 'password']);
accounts.add(['210327042022@test.com', '.VhGDZ!wqiKy@59']);
accounts.add(['151527042022@test.com', '.VhGDZ!wqiKy@59']);
const FileHandler = require("./helpers/file_handler");
const ReadFile = require("./helpers/read_file");
let logins = ReadFile.getContentFromFile('./data/logins.txt');
console.log(logins);
let array = ReadFile.convertStringToArray(logins);
console.log(array);
*/
Feature('Store');
/*Scenario('first', async ({ I, homePage, authPage, createAccountPage, userData }) => {
homePage.openStore();
homePage.clickSignIn();
//custom Helper sample:
authPage.fillNewUserEmail(await I.getRandomEmail());
//tryTo sample
const result = await tryTo(() => I.see('Welcome'));
console.log(result);
//usage of external object data/user:
createAccountPage.fillNewUserForm(userData);
//steps_file sample:
I.login(username, pass);
I.logout();
}).tag('@reg');*/
/*Scenario('second', async ({ I, homePage, authPage, createAccountPage, userData }) => {
I.login(username, pass);
homePage.openStore();
homePage.clickSignIn();
authPage.fillNewUserEmail(I.getRandomEmail());
authPage.clickCreateAccount();
createAccountPage.fillNewUserForm(user);
pause();
I.see('My Account');
}).tag('@login');*/
/*Data(FileHandler.getData()).Scenario('multi login', async ({ I, current }) => {
console.log('Email: ' + current.email + '\nPassword: ' + current.password);
}).tag('@multi');*/
/*Data(accounts).Scenario('Users from data', ({ current }) => {
//console.log('Email: ' + current.email + '\nPassword: ' + current.password);
}).tag('@account');*/
/*Data(ReadFile.getData()).Scenario('Users from data', ({ current }) => {
console.log('Email: ' + current.email + '\nPassword: ' + current.password);
}).tag('@account2');*/
Scenario('api', async ({ I }) => {
//https://codecept.io/helpers/REST/#rest
//https://jsonplaceholder.typicode.com/guide/
//Get
let response = await I.sendGetRequest('https://jsonplaceholder.typicode.com/posts/1');
I.seeResponseCodeIsSuccessful();
console.log(response.data);
//Post
response = await I.sendPostRequest('https://jsonplaceholder.typicode.com/posts/', {
title: 'foo',
body: 'bar',
userId: 1,
})
I.seeResponseCodeIsSuccessful();
console.log(response.data);
//https://swapi.dev/
//Search at SWAPI via get
let searchItem = 'Skywalker';
response = await I.sendGetRequest('https://swapi.dev/api/people/?search=' + searchItem);
console.log(response.data)
}).tag('@api');