Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1f7d64c
Initial commit for tests
compulim Sep 9, 2019
8712825
Add proxy to Web Socket
compulim Sep 10, 2019
45b30ee
Use global agent
compulim Sep 10, 2019
4b28aa6
Fix reliability
compulim Sep 10, 2019
7c76df7
Add upload attachment test
compulim Sep 10, 2019
f8f5622
Add airplane mode test
compulim Sep 11, 2019
7e69ceb
Clean up
compulim Sep 11, 2019
3a874fa
Add fatal test
compulim Sep 11, 2019
6f61a48
Refactor
compulim Sep 11, 2019
c6b2ecf
Fix build script
compulim Sep 11, 2019
f427673
Update build script
compulim Sep 11, 2019
5d9bbb9
Fix tests
compulim Sep 11, 2019
0c25b29
Update bundle folder
compulim Sep 11, 2019
44ec9a4
Update clean scripts
compulim Sep 11, 2019
fc2b46d
Update bundle name
compulim Sep 11, 2019
f9a8fcc
Add entry
compulim Sep 11, 2019
f7e00bf
Skip all transforms for tests
compulim Sep 11, 2019
1625407
Removing unnecessary lines
compulim Sep 11, 2019
4fedcf8
Rename cres to res
compulim Sep 11, 2019
d14b3be
Rename equalityFn to predicate
compulim Sep 11, 2019
c616b33
Apply suggestions from code review
compulim Sep 11, 2019
9f9488e
Rename to createPromiseStack
compulim Sep 11, 2019
5f22593
Merge branch 'feat-tests' of https://github.com/compulim/BotFramework…
compulim Sep 11, 2019
04cd248
Use ConnectionStatus.Online
compulim Sep 11, 2019
4c37f71
Typo
compulim Sep 11, 2019
37c46a2
Rename `sendingActivity` to `activityFromUser`
compulim Sep 11, 2019
6e80f46
Clean up
compulim Sep 11, 2019
2b88728
Use dl_* user ID
compulim Sep 11, 2019
1e349f2
Rename back to .babelrc.js because babel-jest
compulim Sep 11, 2019
f94c5c0
Use dl_*
compulim Sep 12, 2019
12ee071
Clean up
compulim Sep 12, 2019
974c63a
Reuse waitForActivity
compulim Sep 12, 2019
dbe74c8
Rename
compulim Sep 12, 2019
15a01cd
Skip test using secret if DIRECT_LINE_SECRET is not set
compulim Sep 12, 2019
4abe413
Apply PR review changes
compulim Sep 12, 2019
a37dafa
Fix tests
compulim Sep 12, 2019
7d9f5d0
Fix tests
compulim Sep 12, 2019
6507ae6
Apply PR changes
compulim Sep 12, 2019
9485875
Stack -> queue and using a single queue
compulim Sep 12, 2019
e10ba2d
Remove promise-race-map
compulim Sep 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .babelrc

This file was deleted.

34 changes: 34 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
env: {
test: {
plugins: [
'babel-plugin-istanbul'
]
}
},
overrides: [{
include: ['./__tests__'],
presets: [
['@babel/preset-env', {
targets: {
node: 12
}
}],
'@babel/preset-typescript'
]
}],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-runtime',
'babel-plugin-transform-inline-environment-variables'
],
presets: [
['@babel/preset-env', {
forceAllTransforms: true,
modules: 'commonjs'
}],
'@babel/preset-typescript'
],
sourceMaps: 'inline'
};
5 changes: 0 additions & 5 deletions .editorconfig

This file was deleted.

9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/.idea
/built
/.env
/dist
/lib
/node_modules

/directLine.js
/directLine-instrumented.js
/stats.html
10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,52 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Breaking Changes

- Build folders updated
- `/dist/` contains JavaScript bundle
- `/dist/directline.js` is now in lowercase
- `/lib/` contains ES modules and type definitions
- Build scripts updated
- `npm run build`: Development build, with instrumentation code, one-off
- `npm run start`: Development build, with instrumentation code, with watch
- `npm run prepublishOnly`: Production build, minified, one-off

### Changed
- Bumped dependencies, by [@compulim](https://github.com/compulim), in PR [#195](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/195)
- [`@babel/runtime@7.6.0`](https://npmjs.com/package/@babel/runtime)
- [`rxjs@5.0.3`](https://npmjs.com/package/rxjs)
- Bumped dev dependencies, by [@compulim](https://github.com/compulim), in PR [#195](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/195)
- [`@babel/cli@7.6.0`](https://npmjs.com/package/@babel/cli)
- [`@babel/core@7.6.0`](https://npmjs.com/package/@babel/core)
- [`@babel/plugin-proposal-class-properties@7.5.5`](https://npmjs.com/package/@babel/plugin-proposal-class-properties)
- [`@babel/plugin-proposal-object-rest-spread@7.5.5`](https://npmjs.com/package/@babel/plugin-proposal-object-rest-spread)
- [`@babel/plugin-transform-runtime@7.6.0`](https://npmjs.com/package/@babel/plugin-transform-runtime)
- [`@babel/preset-env@7.6.0`](https://npmjs.com/package/@babel/preset-env)
- [`@babel/preset-typescript@7.6.0`](https://npmjs.com/package/@babel/preset-typescript)
- [`@types/jest@24.0.18`](https://npmjs.com/package/@types/jest)
- [`@types/node@12.7.4`](https://npmjs.com/package/@types/node)
- [`@types/p-defer@2.0.0`](https://npmjs.com/package/@types/p-defer)
- [`babel-jest@24.9.0`](https://npmjs.com/package/babel-jest)
- [`babel-plugin-istanbul@5.2.0`](https://npmjs.com/package/babel-plugin-istanbul)
- [`babel-plugin-transform-inline-environment-variables@0.4.3`](https://npmjs.com/package/babel-plugin-transform-inline-environment-variables)
- [`concurrently@4.1.2`](https://npmjs.com/package/concurrently)
- [`dotenv@8.1.0`](https://npmjs.com/package/dotenv)
- [`get-port@5.0.0`](https://npmjs.com/package/get-port)
- [`global-agent@2.0.2`](https://npmjs.com/package/global-agent)
- [`http-proxy@1.17.0`](https://npmjs.com/package/http-proxy)
- [`jest@24.9.0`](https://npmjs.com/package/jest)
- [`jest-environment-jsdom-fourteen@0.1.0`](https://npmjs.com/package/jest-environment-jsdom-fourteen)
- [`jsdom@14.1.0`](https://npmjs.com/package/jsdom)
- [`node-fetch@2.6.0`](https://npmjs.com/package/node-fetch)
- [`on-error-resume-next@1.1.0`](https://npmjs.com/package/on-error-resume-next)
- [`restify@8.4.0`](https://npmjs.com/package/restify)
- [`rimraf@3.0.0`](https://npmjs.com/package/rimraf)
- [`simple-update-in@2.1.1`](https://npmjs.com/package/simple-update-in)
- [`typescript@3.6.2`](https://npmjs.com/package/typescript)
- [`webpack@4.39.3`](https://npmjs.com/package/webpack)
- [`webpack-cli@3.3.8`](https://npmjs.com/package/webpack-cli)

## [0.11.4] - 2019-03-04
### Changed
- Change reconnect delay to be a random amount between 3s and 15s, by [@mingweiw](https://github.com/mingweiw) in PR [#164](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/164)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ That said, the public API is still subject to change.

There are several ways:

1. Build from scratch and include either `/directLine.js` (webpacked with rxjs) or `built/directline.js` in your app
1. Build from scratch and include either `/directLine.js` (webpacked with rxjs) or `lib/directline.js` in your app
2. `npm install botframework-directlinejs`

## Using from within a Node environment
Expand Down
9 changes: 9 additions & 0 deletions __tests__/constants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"userId": "dl_12345",
"timeouts": {
"default": 5000,
"rest": 10000,
"streamingExtensions": 10000,
"webSocket": 10000
}
}
62 changes: 62 additions & 0 deletions __tests__/happy.postActivity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'dotenv/config';

import onErrorResumeNext from 'on-error-resume-next';

import { timeouts } from './constants.json';
import * as createDirectLine from './setup/createDirectLine';
import postActivity from './setup/postActivity';
import waitForBotToEcho from './setup/waitForBotToEcho';
import waitForConnected from './setup/waitForConnected';

describe('Happy path', () => {
let unsubscribes;

beforeEach(() => unsubscribes = []);
afterEach(() => unsubscribes.forEach(fn => onErrorResumeNext(fn)));

describe('should connect, send message, and receive echo from bot', () => {
let directLine;

describe('using REST', () => {
beforeEach(() => jest.setTimeout(timeouts.rest));

test('with secret', async () => {
directLine = await createDirectLine.forREST({ token: false });
});

test('with token', async () => {
directLine = await createDirectLine.forREST({ token: true });
});
});

// test('using Streaming Extensions', async () => {
// jest.setTimeout(timeouts.webSocket);
// directLine = await createDirectLine.forStreamingExtensions();
// });

describe('using Web Socket', () => {
beforeEach(() => jest.setTimeout(timeouts.webSocket));

test('with secret', async () => {
directLine = await createDirectLine.forWebSocket({ token: false });
});

test('with token', async () => {
directLine = await createDirectLine.forWebSocket({ token: false });
});
});

afterEach(async () => {
// If directLine object is undefined, that means the test is failing.
if (!directLine) { return; }

unsubscribes.push(directLine.end.bind(directLine));
unsubscribes.push(await waitForConnected(directLine));

await Promise.all([
postActivity(directLine, { text: 'Hello, World!', type: 'message' }),
waitForBotToEcho(directLine, ({ text }) => text === 'Hello, World!')
]);
});
});
});
106 changes: 106 additions & 0 deletions __tests__/happy.uploadAttachments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'dotenv/config';

import onErrorResumeNext from 'on-error-resume-next';

import { timeouts } from './constants.json';
import * as createDirectLine from './setup/createDirectLine';
import fetchAsBase64 from './setup/fetchAsBase64';
import postActivity from './setup/postActivity';
import waitForBotToEcho from './setup/waitForBotToEcho';
import waitForConnected from './setup/waitForConnected';

describe('Happy path', () => {
let unsubscribes;

beforeEach(() => unsubscribes = []);
afterEach(() => unsubscribes.forEach(fn => onErrorResumeNext(fn)));

describe('upload 2 attachments with text messages', () => {
let directLine;

describe('using REST', () => {
beforeEach(() => jest.setTimeout(timeouts.rest));

test('with secret', async () => {
directLine = await createDirectLine.forREST({ token: false });
});

test('with token', async () => {
directLine = await createDirectLine.forREST({ token: true });
});
});

// test('using Streaming Extensions', async () => {
// jest.setTimeout(timeouts.webSocket);
// directLine = await createDirectLine.forStreamingExtensions();
// });

describe('using Web Socket', () => {
beforeEach(() => jest.setTimeout(timeouts.webSocket));

test('with secret', async () => {
directLine = await createDirectLine.forWebSocket({ token: false });
});

test('with token', async () => {
directLine = await createDirectLine.forWebSocket({ token: false });
});
});

afterEach(async () => {
// If directLine object is undefined, that means the test is failing.
if (!directLine) { return; }

unsubscribes.push(directLine.end.bind(directLine));
unsubscribes.push(await waitForConnected(directLine));

const activityFromUser = {
// DirectLine.postActivityWithAttachments support "contentUrl" only but not "content"
attachments: [{
contentType: 'image/png',
contentUrl: 'https://webchat-waterbottle.azurewebsites.net/public/surfacelogo.png'
}, {
contentType: 'image/png',
contentUrl: 'https://webchat-waterbottle.azurewebsites.net/public/xboxlogo.png'
}],
text: 'Hello, World!',
type: 'message'
};

await Promise.all([
postActivity(directLine, activityFromUser),
waitForBotToEcho(directLine, async ({ attachments, text }) => {
if (text === 'Hello, World!') {
// Bug #194 is causing trouble on the order of attachments sent.
// https://github.com/microsoft/BotFramework-DirectLineJS/issues/194

// Until the bug is fixed, we will not check the order.

const [expecteds, actuals] = await Promise.all([
Promise.all([
fetchAsBase64(activityFromUser.attachments[0].contentUrl),
fetchAsBase64(activityFromUser.attachments[1].contentUrl)
]),
Promise.all([
fetchAsBase64(attachments[0].contentUrl),
fetchAsBase64(attachments[1].contentUrl)
])
]);

expect(attachments[0]).not.toBe(attachments[1]);
expect(~actuals.indexOf(expecteds[0])).toBeTruthy();
expect(~actuals.indexOf(expecteds[1])).toBeTruthy();

// Use the commented code below after bug #194 is fixed.
// https://github.com/microsoft/BotFramework-DirectLineJS/issues/194

// await expect(fetchAsBase64(attachments[0].contentUrl)).resolves.toBe(await fetchAsBase64(activityFromUser.attachments[0].contentUrl));
// await expect(fetchAsBase64(attachments[1].contentUrl)).resolves.toBe(await fetchAsBase64(activityFromUser.attachments[1].contentUrl));

return true;
}
})
]);
});
});
});
Loading