@actionlogementservices/wdio-test-context 1.0.0
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/.editorconfig +20 -0
- package/.jsdoc.json +35 -0
- package/.prettierrc +11 -0
- package/README.md +116 -0
- package/doc/images/badges/modifier-abstract.png +0 -0
- package/doc/images/badges/modifier-abstract.svg +10 -0
- package/doc/images/badges/modifier-default.png +0 -0
- package/doc/images/badges/modifier-default.svg +10 -0
- package/doc/images/badges/modifier-private.png +0 -0
- package/doc/images/badges/modifier-private.svg +10 -0
- package/doc/images/badges/modifier-protected.png +0 -0
- package/doc/images/badges/modifier-protected.svg +10 -0
- package/doc/images/badges/modifier-public.png +0 -0
- package/doc/images/badges/modifier-public.svg +10 -0
- package/doc/images/badges/modifier-readonly.png +0 -0
- package/doc/images/badges/modifier-readonly.svg +10 -0
- package/doc/images/badges/modifier-static.png +0 -0
- package/doc/images/badges/modifier-static.svg +10 -0
- package/doc/src-page-objects_guerrillamail.page.md +69 -0
- package/doc/src-page-objects_maildrop.page.md +57 -0
- package/doc/src-page-objects_page.md +484 -0
- package/doc/src-page-objects_yopmail.page.md +57 -0
- package/doc/src-wdio_ado-reporter.md +93 -0
- package/doc/src-wdio_test-context-worker-service.md +48 -0
- package/doc/src_ado-client.md +55 -0
- package/doc/src_logger.md +183 -0
- package/doc/src_mail-service.md +54 -0
- package/doc/src_pdf-generator.md +35 -0
- package/doc/src_test-context.md +173 -0
- package/doc/toc.md +22 -0
- package/eslint.config.js +100 -0
- package/jsconfig.json +14 -0
- package/package.json +58 -0
- package/src/ado-client.js +96 -0
- package/src/index.js +8 -0
- package/src/logger.js +125 -0
- package/src/mail-service.js +81 -0
- package/src/page-objects/guerrillamail.page.js +144 -0
- package/src/page-objects/index.js +3 -0
- package/src/page-objects/maildrop.page.js +97 -0
- package/src/page-objects/page.js +463 -0
- package/src/page-objects/yopmail.page.js +102 -0
- package/src/pdf-generator.js +61 -0
- package/src/test-context.js +248 -0
- package/src/types.d.ts +60 -0
- package/src/wdio/ado-reporter.js +111 -0
- package/src/wdio/test-context-worker-service.js +88 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
[*]
|
|
8
|
+
|
|
9
|
+
# Change these settings to your own preference
|
|
10
|
+
indent_style = space
|
|
11
|
+
indent_size = 2
|
|
12
|
+
|
|
13
|
+
# We recommend you to keep these unchanged
|
|
14
|
+
end_of_line = lf
|
|
15
|
+
charset = utf-8
|
|
16
|
+
trim_trailing_whitespace = true
|
|
17
|
+
insert_final_newline = false
|
|
18
|
+
|
|
19
|
+
[*.md]
|
|
20
|
+
trim_trailing_whitespace = false
|
package/.jsdoc.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tags": {
|
|
3
|
+
"allowUnknownTags": true
|
|
4
|
+
},
|
|
5
|
+
"source": {
|
|
6
|
+
"include": ["./src"],
|
|
7
|
+
"exclude": ["node_modules"]
|
|
8
|
+
},
|
|
9
|
+
"opts": {
|
|
10
|
+
"template": "node_modules/kis-jsdoc-plugin/templates/markdown",
|
|
11
|
+
"encoding": "utf8",
|
|
12
|
+
"destination": "./doc/",
|
|
13
|
+
"recurse": true,
|
|
14
|
+
"includes": "public,private"
|
|
15
|
+
},
|
|
16
|
+
"plugins": ["node_modules/jsdoc-escape-at", "node_modules/kis-jsdoc-plugin"],
|
|
17
|
+
"templates": {
|
|
18
|
+
"markdown": {
|
|
19
|
+
"imageext": "png",
|
|
20
|
+
"tocfilename": "toc.md",
|
|
21
|
+
"tocOrder": {
|
|
22
|
+
"public": 1,
|
|
23
|
+
"internal": 2
|
|
24
|
+
},
|
|
25
|
+
"badgecolors": {
|
|
26
|
+
"public": "FF5000",
|
|
27
|
+
"internal": "009663",
|
|
28
|
+
"other": "9f9f9f"
|
|
29
|
+
},
|
|
30
|
+
"externallinks": {
|
|
31
|
+
"Promise": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# wdio-test-context
|
|
2
|
+
A framework to add test context to webdriverio end to end tests.
|
|
3
|
+
- It uses JSON files (named dataset) and optional javascript function to add dynamic content to your dataset.
|
|
4
|
+
- It consumes a disposable mail service (YOPmail, maildrop or Guerilla Mail) in order to check for new message.
|
|
5
|
+
- It provides pdf generation to enable document uploads.
|
|
6
|
+
- It provides an Azure DevOps webdriverio reporter.
|
|
7
|
+
- It generates a screenshot when the test fails.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
- In your webdriverio test project:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @actionlogementservices/wdio-test-context
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- Create a `data` folder
|
|
18
|
+
|
|
19
|
+
- Create JSON files in the `data` folder: this will be your datasets.
|
|
20
|
+
|
|
21
|
+
- Create a `data/test-context.d.ts`: this will add intellisense when you use your test context data within the spec files.
|
|
22
|
+
|
|
23
|
+
- Create a `data/test-context.js` file with the following code:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// import your own function to generate dynamic data
|
|
27
|
+
import { generateRandomData } from './generate-random-data.js';
|
|
28
|
+
import { TestContext } from '@actionlogementservices/wdio-test-context';
|
|
29
|
+
|
|
30
|
+
// to enable intellisense with your own data
|
|
31
|
+
/** @typedef {import('./test-context.d.ts').TestContextModel} TestContextModel */
|
|
32
|
+
|
|
33
|
+
/** @type {TestContextModel & TestContext} */
|
|
34
|
+
export const testContext = /** @type {TestContextModel & TestContext} */ (
|
|
35
|
+
new TestContext()
|
|
36
|
+
.setDataGenerator(generateRandomData) // optional : add your own dynamic data
|
|
37
|
+
.setDefaultDataset('test') // default dataset name when DATASET env var is not specified
|
|
38
|
+
.setEnvironment('local', {
|
|
39
|
+
frontUrl: 'https://test.lvh.me',
|
|
40
|
+
backOfficeUrl: 'https://test-backoffice.lvh.me:4432',
|
|
41
|
+
sso: true,
|
|
42
|
+
})
|
|
43
|
+
.setEnvironment('staging', {
|
|
44
|
+
frontUrl: 'https://staging.domain.com',
|
|
45
|
+
backOfficeUrl: 'https://staging-backoffice.domain.com',
|
|
46
|
+
})
|
|
47
|
+
.initialize()
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Create optionnally `data/generate-random-data.js` to add dynamic data, file with the following code:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { faker } from '@faker-js/faker/locale/fr';
|
|
55
|
+
import moment from 'moment';
|
|
56
|
+
|
|
57
|
+
/** @typedef {import('@actionlogementservices/wdio-test-context/types').DataGenerator} DataGenerator */
|
|
58
|
+
|
|
59
|
+
/** @type {DataGenerator} */
|
|
60
|
+
function generateRandomData(_context) {
|
|
61
|
+
// dates random
|
|
62
|
+
const customDate = faker.date.between({ from: '1995-01-01', to: '2001-01-01' });
|
|
63
|
+
return {
|
|
64
|
+
customDate,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { generateRandomData };
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- Configure webdriverio: in your wdio.conf.js:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import { AdoReporter, TestContextWorkerService } from '@actionlogementservices/wdio-test-context';
|
|
75
|
+
import { testContext } from './data/test-context.js';
|
|
76
|
+
|
|
77
|
+
export const config = {
|
|
78
|
+
...
|
|
79
|
+
reporters: [[AdoReporter, {}]],
|
|
80
|
+
services: [[TestContextWorkerService, { testContext, logLevel: 'debug' }]],
|
|
81
|
+
...
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Use the test context in the spec file
|
|
85
|
+
|
|
86
|
+
- Somewhere in your spec files:
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { testContext } from '../../environments.js';
|
|
90
|
+
|
|
91
|
+
describe(`[Inbox] - ${testContext.user.email} - I`, () => {
|
|
92
|
+
let confirmationLink;
|
|
93
|
+
it('receive a mail with confirmation code within 10s', async () => {
|
|
94
|
+
await browser.open(testContext.getParameter('frontUrl')); // to retrieve parameters
|
|
95
|
+
const from = 'no-reply@domain.com';
|
|
96
|
+
const subject = `Confirmation code`;
|
|
97
|
+
// to wait for email and to access test context data
|
|
98
|
+
const content = await testContext.mailService.waitForMessage(testContext.user.email, from, subject);
|
|
99
|
+
confirmationCode = getConfirmationCode(content);
|
|
100
|
+
expect(confirmationCode).toContain('123456');
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Run your test
|
|
105
|
+
|
|
106
|
+
- Specify the dataset with the `DATASET` env var and the environment with the `TARGET_ENV` env var
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
TARGET_ENV=staging DATASET=full-scenario npx wdio
|
|
110
|
+
or
|
|
111
|
+
TARGET_ENV=staging DATASET=full-scenario npm test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Code documentation
|
|
115
|
+
|
|
116
|
+
- Code is [documented here](./doc/toc.md).
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="55" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#477ca1" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#477ca1" d="M0 0h55v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="275" y="140" transform="scale(.1)" textLength="450">abstract</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="49" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#b90000" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#b90000" d="M0 0h49v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="245" y="140" transform="scale(.1)" textLength="390">default</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="49" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#e07a18" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#e07a18" d="M0 0h49v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="245" y="140" transform="scale(.1)" textLength="390">private</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="63" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#009664" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#009664" d="M0 0h63v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="315" y="140" transform="scale(.1)" textLength="530">protected</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="43" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#2c732c" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#2c732c" d="M0 0h43v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="215" y="140" transform="scale(.1)" textLength="330">public</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="57" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#5b5b5b" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#5b5b5b" d="M0 0h57v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="285" y="140" transform="scale(.1)" textLength="470">readonly</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="39" height="20">
|
|
3
|
+
<g shape-rendering="crispEdges">
|
|
4
|
+
<path fill="#36796f" d="M0 0h0v20H0z"/>
|
|
5
|
+
<path fill="#36796f" d="M0 0h39v20H0z"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
8
|
+
<text x="195" y="140" transform="scale(.1)" textLength="290">static</text>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Module `page-objects/guerrillamail.page`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Page-object on top of Guerilla Mail.
|
|
6
|
+
|
|
7
|
+
[Source file](../src/page-objects/guerrillamail.page.js)
|
|
8
|
+
|
|
9
|
+
# Class `GuerillamailPage`
|
|
10
|
+
|
|
11
|
+
Implements a page-object on top of Guerilla Mail.
|
|
12
|
+
|
|
13
|
+
## Methods
|
|
14
|
+
|
|
15
|
+
### `openInbox(email)`
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
WDIO logic to open the mailbox.
|
|
20
|
+
|
|
21
|
+
Parameters | Type | Description
|
|
22
|
+
--- | --- | ---
|
|
23
|
+
__email__ | `string` | *disposable email*
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### `retrieveDomains() ► Promise.<Array.<string>>`
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
WDIO logic to retrieve domains exposed by the provider.
|
|
32
|
+
|
|
33
|
+
Parameters | Type | Description
|
|
34
|
+
--- | --- | ---
|
|
35
|
+
__*return*__ | `Promise.<Array.<string>>` | **
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### `getMessages() ► `
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
WDIO logic to get emails.
|
|
44
|
+
|
|
45
|
+
Parameters | Type | Description
|
|
46
|
+
--- | --- | ---
|
|
47
|
+
__*return*__ | `undefined` | **
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### `getMessageContent(index) ► Promise.<string>`
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
WDIO logic to get the specified message content.
|
|
56
|
+
|
|
57
|
+
Parameters | Type | Description
|
|
58
|
+
--- | --- | ---
|
|
59
|
+
__index__ | `number` | **
|
|
60
|
+
__*return*__ | `Promise.<string>` | **
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Members
|
|
65
|
+
|
|
66
|
+
Name | Type | Description
|
|
67
|
+
--- | --- | ---
|
|
68
|
+
__name__ | `undefined` | *name of the provider*
|
|
69
|
+
__domains__ | `undefined` | *domains exposed of the provider*
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Module `page-objects/maildrop.page`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Page-object on top of maildrop.
|
|
6
|
+
|
|
7
|
+
[Source file](../src/page-objects/maildrop.page.js)
|
|
8
|
+
|
|
9
|
+
# Class `MaildropPage`
|
|
10
|
+
|
|
11
|
+
Implements a page-object on top of maildrop.
|
|
12
|
+
|
|
13
|
+
## Methods
|
|
14
|
+
|
|
15
|
+
### `openInbox(email)`
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
WDIO logic to open the mailbox.
|
|
20
|
+
|
|
21
|
+
Parameters | Type | Description
|
|
22
|
+
--- | --- | ---
|
|
23
|
+
__email__ | `string` | *disposable email*
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### `getMessages() ► `
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
WDIO logic to get emails.
|
|
32
|
+
|
|
33
|
+
Parameters | Type | Description
|
|
34
|
+
--- | --- | ---
|
|
35
|
+
__*return*__ | `undefined` | **
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### `getMessageContent(index) ► Promise.<string>`
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
WDIO logic to get the specified message content.
|
|
44
|
+
|
|
45
|
+
Parameters | Type | Description
|
|
46
|
+
--- | --- | ---
|
|
47
|
+
__index__ | `number` | **
|
|
48
|
+
__*return*__ | `Promise.<string>` | **
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Members
|
|
53
|
+
|
|
54
|
+
Name | Type | Description
|
|
55
|
+
--- | --- | ---
|
|
56
|
+
__name__ | `undefined` | *name of the provider*
|
|
57
|
+
__domains__ | `undefined` | *domains exposed of the provider*
|