Skip to content

Commit 4abfc22

Browse files
Merge branch 'dev'
2 parents dec5d79 + ec718b5 commit 4abfc22

16 files changed

+2971
-771
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/docs
21
/build
3-
/tests/tests.config.js
4-
/tests/index.html
52
/.idea
63
/node_modules
74
/.extjs-link.conf.json

README.md

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## @conjoon/extjs-dev-webmailsim ![MIT](https://img.shields.io/npm/l/@conjoon/extjs-dev-webmailsim) [![npm version](https://badge.fury.io/js/@conjoon%2Fextjs-dev-webmailsim.svg)](https://badge.fury.io/js/@conjoon%2Fextjs-dev-webmailsim)
22

3-
This Sencha ExtJS NPM package contains mock data for development of [conjoon/extjs-app-webmail](https://github.com/conjoon/extjs-app-webmail).
4-
When using this package, all backend requests of `extjs-app-webmail` will be replaced with mocks.
3+
This Sencha Ext JS NPM package contains mock data for development of [conjoon/extjs-app-webmail](https://github.com/conjoon/extjs-app-webmail).
4+
When using this package, configured urls will be intercepted and static data is returned in
5+
the responses.
56

67
## Installation
78
```bash
@@ -18,11 +19,9 @@ Testing environment will then be available via
1819
$ npm test
1920
```
2021

21-
For using the package as an external dependency in an application, use
22-
```bash
23-
$ npm install --save-prod @conjoon/extjs-dev-webmailsim
24-
```
25-
In your `app.json`, add this package as a requirement, and make sure your ExtJS `workspace.json`
22+
For using the package as an external dependency in an application:
23+
<br>
24+
In your `app.json`, add this package as a requirement, and make sure your Ext JS `workspace.json`
2625
is properly configured to look up local repositories in the `node_modules`-directory.
2726

2827
Example (`workspace.json`) :
@@ -34,66 +33,32 @@ Example (`workspace.json`) :
3433
}
3534
}
3635
```
37-
## Usage
38-
Simply update the app.json of the **conjoon**-application
39-
by specifying this package in the `uses`-property in either the `development` and/or `prodution` section:
36+
Update the `app.json` of the application by specifying this package in the `uses`-property in
37+
either the `development` and/or `prodution` section:
4038

4139
*Example:*
4240
```json
4341
{
4442
"development": {
4543
"uses": [
46-
"extjs-app-webmail",
44+
"extjs-dev-imapusersim",
4745
"extjs-app-imapuser",
48-
"extjs-dev-webmailsim",
49-
"extjs-dev-imapusersim"
46+
"extjs-app-webmail",
47+
"extjs-dev-webmailsim"
5048
]
5149
},
5250
"production": {
5351
"uses": [
54-
"extjs-app-webmail",
55-
"extjs-app-imapuser"
52+
"extjs-app-imapuser",
53+
"extjs-app-webmail"
5654
]
5755
}
5856
}
5957
```
60-
In order to properly intercept outgoing requests to the services as described in **conjoon/rest-api-description/rest-imap**,
61-
the package needs to be configured with a regular expression representing the urls to catch.
62-
The package is pre-configured so that it catches urls in the form of `https://php-ms-imapuser.ddev.site/rest-imap/api/v1/*`.
63-
A custom configuration can be placed in the resources-folder of the application using the package.
6458

65-
The following is a snapshot of the configuration and not guaranteed to work in future versions. It should be used as
66-
an example - consult the `package.json` for an up to date configuration.
67-
```json
68-
{
69-
"mailAccount": {
70-
"url": "https://php-ms-imapuser.ddev.site/rest-imap/api/v.*?/\/MailAccounts(\/\\d+)?",
71-
"enabled": true,
72-
"delay": 250
73-
},
74-
"mailFolder": {
75-
"url": "https://php-ms-imapuser.ddev.site/rest-imap/api/v.*?/\/MailAccounts\/(.+)\/MailFolders(\/.*)?",
76-
"enabled": true,
77-
"delay": 250
78-
},
79-
"attachment": {
80-
"url": "https://php-ms-imapuser.ddev.site/rest-imap/api/v.*?/\/MailAccounts\/(.+)\/MailFolders\/(.+)\/MessageItems\/(.+)\/Attachments(\/.*)?",
81-
"enabled": true,
82-
"delay": 250
83-
},
84-
"messageItem": {
85-
"url": "https://php-ms-imapuser.ddev.site/rest-imap/api/v.*?/\/MailAccounts\/(.+)\/MailFolders\/(.+)\/MessageItems(\/.*)?",
86-
"enabled": true,
87-
"delay": 250
88-
},
89-
"sendMessage": {
90-
"url": "https://php-ms-imapuser.ddev.site/rest-imap/api/v.*?/\/SendMessage(\/\\d+)?",
91-
"enabled": true,
92-
"delay": 250
93-
}
94-
}
95-
```
96-
If this package is used in your environment, intercepting urls can be enabled/disabled by changing the property `enabled`
97-
to either `true` or `false`.
98-
<br>Please refer to the documentation of [extjs-lib-core](https://github.com/coon-js/extjs-lib-core) on how to
99-
create package-specific configurations.
59+
60+
## Configuration and Usage
61+
For more information on how to configure and use the package, refer to the [documentation](./docs/README.md).
62+
63+
## Tests
64+
Tests are written with [Siesta](https://bryntum.com/siesta). Documentation can be found [here](./tests/README.md).

docs/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# @conjoon/extjs-dev-webmailsim Documentation
2+
3+
**extjs-dev-webmailsim** is a **coon.js** package and is tagged as such in the
4+
`package.json`:
5+
6+
```json
7+
{
8+
"coon-js": {
9+
"package": {
10+
"autoLoad": {
11+
"registerController": true
12+
},
13+
"config" : "${package.resourcePath}/extjs-dev-webmailsim.conf.json"
14+
}
15+
}
16+
}
17+
```
18+
19+
By default, this package's configuration can be found in this package's `resources` folder
20+
in a file named `extjs-dev-webmailsim.conf.json`.
21+
22+
## What goes into a `extjs-dev-webmailsim` configuration?
23+
24+
The package intercepts outgoing network requests to all urls matching a specific
25+
url-pattern. Additionally, you can configure whether the package's url intercepting should
26+
be enabled or disabled - this makes it easier to use this package in environments where
27+
you have to test for fully functional network behavior with real HTTP-requests and live- and mock-data should be used side-by-side.
28+
29+
The configuration file for this package has various entries representing entities and their endpoints:
30+
`mailAccount`, `mailFolder`, `messageItem` and `attachment`:
31+
32+
```json
33+
{
34+
"attachment": {
35+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems/(.+)/Attachments(/.*)?",
36+
"enabled": true,
37+
"delay": 250
38+
},
39+
"messageItem": {
40+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems(/.*)?",
41+
"enabled": true,
42+
"delay": 250
43+
},
44+
"mailFolder": {
45+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders(/.*)?",
46+
"enabled": true,
47+
"delay": 250
48+
},
49+
"mailAccount": {
50+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts(/d+)?",
51+
"enabled": true,
52+
"delay": 250
53+
}
54+
}
55+
```
56+
Each entry in the configuration can be configured with
57+
58+
- `url` - In order to properly intercept outgoing requests to the services as described in
59+
[rest-api-mail](https://github.com/conjoon/rest-api-description), the package needs
60+
to be configured with various regular expressions representing urls to catch.
61+
The package is pre-configured. For example, HTTP-requests to the following URLs are intercepted by this package:
62+
- `https://dev-ms-email.ddev.site/rest-api-email/api/v0/MailAccounts`
63+
- `https://dev-ms-email.ddev.site/rest-api-email/api/v1/MailAccounts/dev/MailFolders/INBOX.Sent/MessageItems/123`
64+
65+
- `enabled` - If this package is used with your development or production environment, intercepting urls can be enabled/disabled by changing the property `enabled`
66+
to either `true` or `false`.
67+
- `delay` - the delay in milliseconds to mimic network latency
68+
69+
### Order of matching URLs
70+
The Simmanager will consider url-matching in the order the urls are configured.
71+
Make sure more specific regular expressions are defined first, followed by more common ones.
72+
73+
For example, the url `https://dev-ms-email.ddev.site/rest-api-email/api/v1/MailAccounts/dev/MailFolders/INBOX.Sent/MessageItems/123`
74+
would be intercepted by the regular expression defined with `mailFolder` (because it is defined _at first_), although it should be intercepted by `messageItem`:
75+
76+
```json
77+
{
78+
"mailFolder": {
79+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders(/.*)?",
80+
"enabled": true,
81+
"delay": 250
82+
},
83+
"messageItem": {
84+
"url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems(/.*)?",
85+
"enabled": true,
86+
"delay": 250
87+
}
88+
}
89+
```
90+
91+
## Response Data
92+
If a request was intercepted, static data is returned to mimic responses of backends
93+
implementing the [REST API](https://github.com/conjoon/rest-api-description). The data returned
94+
can be edited in this package's `src/data/table/MessageTable.js` and `src/data/table/AttachmentTable.js`.

0 commit comments

Comments
 (0)