Skip to content

Commit ff1bd58

Browse files
committed
DOC: Autogenerate and update documentation
1 parent f669be0 commit ff1bd58

16 files changed

+3440
-3113
lines changed

docs/helpers/AI.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Use it only in development mode. It is recommended to run it only inside pause()
2222

2323
This helper should be configured in codecept.conf.{js|ts}
2424

25-
- `chunkSize`: - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
25+
* `chunkSize`: - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
2626

2727
### Parameters
2828

29-
- `config`  
29+
* `config`  
3030

3131
### askForPageObject
3232

@@ -37,22 +37,22 @@ Prompt can be customized in a global config file.
3737

3838
```js
3939
// create page object for whole page
40-
I.askForPageObject('home')
40+
I.askForPageObject('home');
4141

4242
// create page object with extra prompt
43-
I.askForPageObject('home', 'implement signIn(username, password) method')
43+
I.askForPageObject('home', 'implement signIn(username, password) method');
4444

4545
// create page object for a specific element
46-
I.askForPageObject('home', null, '.detail')
46+
I.askForPageObject('home', null, '.detail');
4747
```
4848

4949
Asks for a page object based on the provided page name, locator, and extra prompt.
5050

5151
#### Parameters
5252

53-
- `pageName` **[string][1]** The name of the page to retrieve the object for.
54-
- `extraPrompt` **([string][1] | null)** An optional extra prompt for additional context or information.
55-
- `locator` **([string][1] | null)** An optional locator to find a specific element on the page.
53+
* `pageName` **[string][1]** The name of the page to retrieve the object for.
54+
* `extraPrompt` **([string][1] | null)** An optional extra prompt for additional context or information.
55+
* `locator` **([string][1] | null)** An optional locator to find a specific element on the page.
5656

5757
Returns **[Promise][2]<[Object][3]>** A promise that resolves to the requested page object.
5858

@@ -62,7 +62,7 @@ Send a general request to AI and return response.
6262

6363
#### Parameters
6464

65-
- `prompt` **[string][1]**&#x20;
65+
* `prompt` **[string][1]**&#x20;
6666

6767
Returns **[Promise][2]<[string][1]>** A Promise that resolves to the generated response from the GPT model.
6868

@@ -71,12 +71,12 @@ Returns **[Promise][2]<[string][1]>** A Promise that resolves to the generated r
7171
Asks the AI GPT language model a question based on the provided prompt within the context of the current page's HTML.
7272

7373
```js
74-
I.askGptOnPage('what does this page do?')
74+
I.askGptOnPage('what does this page do?');
7575
```
7676

7777
#### Parameters
7878

79-
- `prompt` **[string][1]** The question or prompt to ask the GPT model.
79+
* `prompt` **[string][1]** The question or prompt to ask the GPT model.
8080

8181
Returns **[Promise][2]<[string][1]>** A Promise that resolves to the generated responses from the GPT model, joined by newlines.
8282

@@ -85,16 +85,18 @@ Returns **[Promise][2]<[string][1]>** A Promise that resolves to the generated r
8585
Asks the AI a question based on the provided prompt within the context of a specific HTML fragment on the current page.
8686

8787
```js
88-
I.askGptOnPageFragment('describe features of this screen', '.screen')
88+
I.askGptOnPageFragment('describe features of this screen', '.screen');
8989
```
9090

9191
#### Parameters
9292

93-
- `prompt` **[string][1]** The question or prompt to ask the GPT-3.5 model.
94-
- `locator` **[string][1]** The locator or selector used to identify the HTML fragment on the page.
93+
* `prompt` **[string][1]** The question or prompt to ask the GPT-3.5 model.
94+
* `locator` **[string][1]** The locator or selector used to identify the HTML fragment on the page.
9595

9696
Returns **[Promise][2]<[string][1]>** A Promise that resolves to the generated response from the GPT model.
9797

9898
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
99+
99100
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
101+
100102
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

docs/helpers/ApiDataFactory.md

+54-50
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Most of web application have API, and it can be used to create and delete test r
2828
By combining REST API with Factories you can easily create records for tests:
2929

3030
```js
31-
I.have('user', { login: 'davert', email: 'davert@mail.com' })
32-
let id = await I.have('post', { title: 'My first post' })
33-
I.haveMultiple('comment', 3, { post_id: id })
31+
I.have('user', { login: 'davert', email: 'davert@mail.com' });
32+
let id = await I.have('post', { title: 'My first post'});
33+
I.haveMultiple('comment', 3, {post_id: id});
3434
```
3535

3636
To make this work you need
@@ -53,14 +53,14 @@ See the example for Posts factories:
5353
```js
5454
// tests/factories/posts.js
5555

56-
const { Factory } = require('rosie')
57-
const { faker } = require('@faker-js/faker')
56+
const { Factory } = require('rosie');
57+
const { faker } = require('@faker-js/faker');
5858

5959
module.exports = new Factory()
60-
// no need to set id, it will be set by REST API
61-
.attr('author', () => faker.person.findName())
62-
.attr('title', () => faker.lorem.sentence())
63-
.attr('body', () => faker.lorem.paragraph())
60+
// no need to set id, it will be set by REST API
61+
.attr('author', () => faker.person.findName())
62+
.attr('title', () => faker.lorem.sentence())
63+
.attr('body', () => faker.lorem.paragraph());
6464
```
6565

6666
For more options see [rosie documentation][1].
@@ -71,12 +71,12 @@ Then configure ApiDataHelper to match factories and REST API:
7171

7272
ApiDataFactory has following config options:
7373

74-
- `endpoint`: base URL for the API to send requests to.
75-
- `cleanup` (default: true): should inserted records be deleted up after tests
76-
- `factories`: list of defined factories
77-
- `returnId` (default: false): return id instead of a complete response when creating items.
78-
- `headers`: list of headers
79-
- `REST`: configuration for REST requests
74+
* `endpoint`: base URL for the API to send requests to.
75+
* `cleanup` (default: true): should inserted records be deleted up after tests
76+
* `factories`: list of defined factories
77+
* `returnId` (default: false): return id instead of a complete response when creating items.
78+
* `headers`: list of headers
79+
* `REST`: configuration for REST requests
8080

8181
See the example:
8282

@@ -121,19 +121,19 @@ For instance, to set timeout you should add:
121121

122122
By default to create a record ApiDataFactory will use endpoint and plural factory name:
123123

124-
- create: `POST {endpoint}/{resource} data`
125-
- delete: `DELETE {endpoint}/{resource}/id`
124+
* create: `POST {endpoint}/{resource} data`
125+
* delete: `DELETE {endpoint}/{resource}/id`
126126

127127
Example (`endpoint`: `http://app.com/api`):
128128

129-
- create: POST request to `http://app.com/api/users`
130-
- delete: DELETE request to `http://app.com/api/users/1`
129+
* create: POST request to `http://app.com/api/users`
130+
* delete: DELETE request to `http://app.com/api/users/1`
131131

132132
This behavior can be configured with following options:
133133

134-
- `uri`: set different resource uri. Example: `uri: account` => `http://app.com/api/account`.
135-
- `create`: override create options. Expected format: `{ method: uri }`. Example: `{ "post": "/users/create" }`
136-
- `delete`: override delete options. Expected format: `{ method: uri }`. Example: `{ "post": "/users/delete/{id}" }`
134+
* `uri`: set different resource uri. Example: `uri: account` => `http://app.com/api/account`.
135+
* `create`: override create options. Expected format: `{ method: uri }`. Example: `{ "post": "/users/create" }`
136+
* `delete`: override delete options. Expected format: `{ method: uri }`. Example: `{ "post": "/users/delete/{id}" }`
137137

138138
Requests can also be overridden with a function which returns [axois request config][4].
139139

@@ -146,31 +146,31 @@ delete: (id) => ({ method: 'delete', url: '/posts', data: { id } })
146146
Requests can be updated on the fly by using `onRequest` function. For instance, you can pass in current session from a cookie.
147147

148148
```js
149-
onRequest: async request => {
150-
// using global codeceptjs instance
151-
let cookie = await codeceptjs.container.helpers('WebDriver').grabCookie('session')
152-
request.headers = { Cookie: `session=${cookie.value}` }
153-
}
149+
onRequest: async (request) => {
150+
// using global codeceptjs instance
151+
let cookie = await codeceptjs.container.helpers('WebDriver').grabCookie('session');
152+
request.headers = { Cookie: `session=${cookie.value}` };
153+
}
154154
```
155155

156156
### Responses
157157

158158
By default `I.have()` returns a promise with a created data:
159159

160160
```js
161-
let client = await I.have('client')
161+
let client = await I.have('client');
162162
```
163163

164164
Ids of created records are collected and used in the end of a test for the cleanup.
165165
If you need to receive `id` instead of full response enable `returnId` in a helper config:
166166

167167
```js
168168
// returnId: false
169-
let clientId = await I.have('client')
169+
let clientId = await I.have('client');
170170
// clientId == 1
171171

172172
// returnId: true
173-
let clientId = await I.have('client')
173+
let clientId = await I.have('client');
174174
// client == { name: 'John', email: 'john@snow.com' }
175175
```
176176

@@ -190,47 +190,47 @@ By default `id` property of response is taken. This behavior can be changed by s
190190

191191
### Parameters
192192

193-
- `config` &#x20;
193+
* `config` &#x20;
194194

195-
### \_requestCreate
195+
### _requestCreate
196196

197197
Executes request to create a record in API.
198198
Can be replaced from a in custom helper.
199199

200200
#### Parameters
201201

202-
- `factory` **any**&#x20;
203-
- `data` **any**&#x20;
202+
* `factory` **any**&#x20;
203+
* `data` **any**&#x20;
204204

205-
### \_requestDelete
205+
### _requestDelete
206206

207207
Executes request to delete a record in API
208208
Can be replaced from a custom helper.
209209

210210
#### Parameters
211211

212-
- `factory` **any**&#x20;
213-
- `id` **any**&#x20;
212+
* `factory` **any**&#x20;
213+
* `id` **any**&#x20;
214214

215215
### have
216216

217217
Generates a new record using factory and saves API request to store it.
218218

219219
```js
220220
// create a user
221-
I.have('user')
221+
I.have('user');
222222
// create user with defined email
223223
// and receive it when inside async function
224-
const user = await I.have('user', { email: 'user@user.com' })
224+
const user = await I.have('user', { email: 'user@user.com'});
225225
// create a user with options that will not be included in the final request
226-
I.have('user', {}, { age: 33, height: 55 })
226+
I.have('user', { }, { age: 33, height: 55 })
227227
```
228228

229229
#### Parameters
230230

231-
- `factory` **any** factory to use
232-
- `params` **any?** predefined parameters
233-
- `options` **any?** options for programmatically generate the attributes
231+
* `factory` **any** factory to use
232+
* `params` **any?** predefined parameters
233+
* `options` **any?** options for programmatically generate the attributes
234234

235235
Returns **[Promise][5]<any>**&#x20;
236236

@@ -240,24 +240,28 @@ Generates bunch of records and saves multiple API requests to store them.
240240

241241
```js
242242
// create 3 posts
243-
I.haveMultiple('post', 3)
243+
I.haveMultiple('post', 3);
244244

245245
// create 3 posts by one author
246-
I.haveMultiple('post', 3, { author: 'davert' })
246+
I.haveMultiple('post', 3, { author: 'davert' });
247247

248248
// create 3 posts by one author with options
249-
I.haveMultiple('post', 3, { author: 'davert' }, { publish_date: '01.01.1997' })
249+
I.haveMultiple('post', 3, { author: 'davert' }, { publish_date: '01.01.1997' });
250250
```
251251

252252
#### Parameters
253253

254-
- `factory` **any**&#x20;
255-
- `times` **any**&#x20;
256-
- `params` **any?**&#x20;
257-
- `options` **any?**&#x20;
254+
* `factory` **any**&#x20;
255+
* `times` **any**&#x20;
256+
* `params` **any?**&#x20;
257+
* `options` **any?**&#x20;
258258

259259
[1]: https://github.com/rosiejs/rosie
260+
260261
[2]: https://www.npmjs.com/package/faker
262+
261263
[3]: http://codecept.io/helpers/REST/
264+
262265
[4]: https://github.com/axios/axios#request-config
266+
263267
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise

0 commit comments

Comments
 (0)