Skip to content

Commit

Permalink
Fixed merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Nov 16, 2018
2 parents ad9d2f4 + 6a238d4 commit faf4a45
Show file tree
Hide file tree
Showing 15 changed files with 1,261 additions and 3,727 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Checkout the [Wiki](https://github.com/Microsoft/BotFramework-Emulator/wiki) for

## Nightly builds

Nightly builds are generated using the latest code. Therefore, they may not be stable, and most likely lack up to date documentation. These builds are better suited for more experienced users, although everyone is welcome to use them and provide feedback. Niightly builds of the V4 Emulator are available [here](https://github.com/Microsoft/botframework-emulator-nightlies/releases).
Nightly builds are generated using the latest code. Therefore, they may not be stable, and most likely lack up to date documentation. These builds are better suited for more experienced users, although everyone is welcome to use them and provide feedback. Nightly builds of the V4 Emulator are available [here](https://github.com/Microsoft/botframework-emulator-nightlies/releases).

## Contributing

Expand Down
3,963 changes: 438 additions & 3,525 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/app/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { SharedConstants } from '@bfemulator/app-shared';

export const CONTENT_TYPE_APP_SETTINGS = 'application/vnd.microsoft.bfemulator.document.appsettings';
export const CONTENT_TYPE_WELCOME_PAGE = 'application/vnd.microsoft.bfemulator.document.welcome';
export const CONTENT_TYPE_TRANSCRIPT = 'application/vnd.microsoft.bfemulator.document.transcript';
export const CONTENT_TYPE_LIVE_CHAT = 'application/vnd.microsoft.bfemulator.document.livechat';
export const CONTENT_TYPE_LIVE_CHAT = SharedConstants.ContentTypes.CONTENT_TYPE_LIVE_CHAT;

export const NAVBAR_BOT_EXPLORER = 'navbar.botExplorer';
export const NAVBAR_SETTINGS = 'navbar.settings';
Expand Down
172 changes: 172 additions & 0 deletions packages/app/client/src/data/sagas/botSagas.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Bot Framework: http://botframework.com
//
// Bot Framework Emulator Github:
// https://github.com/Microsoft/BotFramwork-Emulator
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { BotActions, botHashGenerated, SetActiveBotAction } from '../action/botActions';
import { BotConfigWithPath } from '@bfemulator/sdk-shared';
import {
botSagas,
browseForBot,
generateHashForActiveBot,
refreshConversationMenu
} from './botSagas';
import {
call,
put,
takeEvery
} from 'redux-saga/effects';
import { generateBotHash } from '../botHelpers';
import { SharedConstants } from '@bfemulator/app-shared';

jest.mock('../../ui/dialogs', () => ({}));

jest.mock('../store', () => ({
get store() {
return {};
}
}));

const mockSharedConstants = SharedConstants;
let mockRemoteCommandsCalled = [];
let mockLocalCommandsCalled = [];

jest.mock('../../platform/commands/commandServiceImpl', () => ({
CommandServiceImpl: {
call: async (commandName: string, ...args: any[]) => {
mockLocalCommandsCalled.push({ commandName, args: args });

switch (commandName) {
case mockSharedConstants.Commands.Bot.OpenBrowse:
return Promise.resolve(true);
default:
return Promise.resolve(true);
}
},
remoteCall: async (commandName: string, ... args: any[]) => {
mockRemoteCommandsCalled.push({ commandName, args: args});

return Promise.resolve(true);
}
}
}));

describe('The botSagas', () => {

beforeEach(() => {
mockRemoteCommandsCalled = [];
mockLocalCommandsCalled = [];
});

it('should initialize the root saga', () => {
let gen = botSagas();

const browseForBotYield = gen.next().value;

expect(browseForBotYield).toEqual(
takeEvery(
BotActions.browse,
browseForBot
)
);

const generateBotHashYield = gen.next().value;

expect(generateBotHashYield).toEqual(
takeEvery(
BotActions.setActive,
generateHashForActiveBot
)
);

const refreshConversationMenuYield = gen.next().value;

expect(refreshConversationMenuYield).toEqual(
takeEvery(
[
BotActions.setActive,
BotActions.load,
BotActions.close
],
refreshConversationMenu
)
);

expect(gen.next().done).toBe(true);

});

it('should refresh the conversation menu', () => {
const gen = refreshConversationMenu();
gen.next();

expect(mockRemoteCommandsCalled).toHaveLength(1);
const { UpdateConversationMenu } = SharedConstants.Commands.Electron;
expect(mockRemoteCommandsCalled[0].commandName).toEqual(UpdateConversationMenu);
expect(gen.next().done).toBe(true);
});

it('should generate a hash for an active bot', () => {
const botConfigPath: BotConfigWithPath = {
name: 'botName',
description: 'a bot description here',
padlock: null,
services: [],
path: '/some/Path/something',
version: '0.1'
};

const setActiveBotAction: SetActiveBotAction = {
type: BotActions.setActive,
payload: {
bot: botConfigPath
}
};
const gen = generateHashForActiveBot(setActiveBotAction);
const generatedHash = gen.next().value;

expect(generatedHash).toEqual(call(generateBotHash, botConfigPath));

const putGeneratedHash = gen.next(generatedHash).value;
expect(putGeneratedHash).toEqual(put(botHashGenerated(generatedHash)));
expect(gen.next().done).toBe(true);
});

it('should open native open file dialog to browse for .bot file', () => {
const gen = browseForBot();
gen.next();
expect(mockLocalCommandsCalled).toHaveLength(1);
const { OpenBrowse } = SharedConstants.Commands.Bot;

expect(mockLocalCommandsCalled[0].commandName).toEqual(OpenBrowse);
expect(gen.next().done).toBe(true);
});
});
16 changes: 14 additions & 2 deletions packages/app/client/src/data/sagas/botSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';
import { call, ForkEffect, put, takeEvery } from 'redux-saga/effects';
import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { SharedConstants } from '@bfemulator/app-shared';
import { BotActions, botHashGenerated, SetActiveBotAction } from '../action/botActions';
Expand All @@ -46,11 +46,23 @@ export function* browseForBot(): IterableIterator<any> {

export function* generateHashForActiveBot(action: SetActiveBotAction): IterableIterator<any> {
const { bot } = action.payload;
const generatedHash = yield generateBotHash(bot);
const generatedHash = yield call(generateBotHash, bot);
yield put(botHashGenerated(generatedHash));
}

export function* refreshConversationMenu(): IterableIterator<any> {
yield CommandServiceImpl.remoteCall(SharedConstants.Commands.Electron.UpdateConversationMenu);
}

export function* botSagas(): IterableIterator<ForkEffect> {
yield takeEvery(BotActions.browse, browseForBot);
yield takeEvery(BotActions.setActive, generateHashForActiveBot);
yield takeEvery(
[
BotActions.setActive,
BotActions.load,
BotActions.close
],
refreshConversationMenu
);
}

0 comments on commit faf4a45

Please sign in to comment.