Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 1 addition & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"scripts": {
"start": "node scripts/start.js",
"build": "node --max-old-space-size=2048 scripts/build.js",
"build": "node scripts/build.js",
"test": "jest",
"lint": "eslint --quiet --ext .js,.jsx,.ts,.tsx ./src",
"lint:fix": "yarn lint --fix"
Expand Down
22 changes: 18 additions & 4 deletions Composer/packages/lib/shared/__tests__/dialogFactory.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import { seedDefaults } from '../src/dialogFactory';
import { seedDefaults, seedNewDialog } from '../src/dialogFactory';

describe('DialogFactory', () => {
describe('#seedDefaults', () => {
it('can assign defaults to non-object types', async () => {
it('can assign defaults to non-object types', () => {
const seed: any = seedDefaults('Microsoft.TextInput');
expect(seed.maxTurnCount).toBe(3);
expect(seed.alwaysPrompt).toBe(false);
});
it('can assign defaults to object types', async () => {

it('can assign defaults to object types', () => {
const seed: any = seedDefaults('Microsoft.ChoiceInput');
expect(seed.choiceOptions.includeNumbers).toBe(true);
});
it("does not assign defaults when it shouldn't", async () => {

it("does not assign defaults when it shouldn't", () => {
const seed: any = seedDefaults('Microsoft.SendActivity');
expect(seed.activity).toBeFalsy();
});
});

describe('#seedNewDialog', () => {
it('does not override user-provided values', () => {
const seed: any = seedNewDialog('Microsoft.TextInput', { name: 'My Name' }, { allowInterruptions: 'foo' });
expect(seed.allowInterruptions).toEqual('foo');
});

it('does not override initial values', () => {
const seed: any = seedNewDialog('Microsoft.TextInput', { name: 'My Name' });
expect(seed.allowInterruptions).toEqual('false');
});
});
});
15 changes: 12 additions & 3 deletions Composer/packages/lib/shared/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
const path = require('path');

module.exports = {
preset: 'ts-jest/presets/js-with-babel',
testPathIgnorePatterns: ['/node_modules/'],
transform: {
'^.+\\.(j|t)sx?$': 'babel-jest',
},
watchPathIgnorePatterns: ['<rootDir>/__tests__/mocks'],
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/controllers/*.{js,jsx,ts,tsx}'],
moduleNameMapper: {
// Any imports of .scss / .css files will instead import styleMock.js which is an empty object
'\\.(jpg|jpeg|png|svg)$': '<rootDir>/__tests__/jestMocks/styleMock.js',
'\\.(s)?css$': '<rootDir>/__tests__/jestMocks/styleMock.js',
},

globals: {
'ts-jest': {
tsConfig: path.resolve(__dirname, './tsconfig.json'),
diagnostics: {
warnOnly: true,
},
},
},
};
20 changes: 19 additions & 1 deletion Composer/packages/lib/shared/src/dialogFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ const initialDialogShape = {
$type: 'Microsoft.OnConversationUpdateActivity',
condition: "toLower(turn.Activity.membersAdded[0].name) != 'bot'",
},
'Microsoft.AttachmentInput': {
allowInterruptions: 'false',
},
'Microsoft.ChoiceInput': {
allowInterruptions: 'false',
},
'Microsoft.ConfirmInput': {
allowInterruptions: 'false',
},
'Microsoft.DateTimeInput': {
allowInterruptions: 'false',
},
'Microsoft.NumberInput': {
allowInterruptions: 'false',
},
'Microsoft.TextInput': {
allowInterruptions: 'false',
},
};

export function getNewDesigner(name: string, description: string) {
Expand Down Expand Up @@ -95,8 +113,8 @@ export const seedNewDialog = (
id: nanoid('1234567890', 6),
...designerAttributes,
},
...seedDefaults($type),
...(initialDialogShape[$type] || {}),
...optionalAttributes,
...seedDefaults($type),
};
};
20 changes: 12 additions & 8 deletions Composer/packages/lib/shared/src/viewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const dialogGroups: DialogGroupsMap = {
SDKTypes.EndTurn,
SDKTypes.RepeatDialog,
SDKTypes.ReplaceDialog,
SDKTypes.EditActions,
],
},
[DialogGroup.CODE]: {
Expand Down Expand Up @@ -135,7 +134,7 @@ export const dialogGroups: DialogGroupsMap = {
};

export const createStepMenu = (
stepLabels,
stepLabels: DialogGroup[],
subMenu = true,
handleType: (e: any, item: IContextualMenuItem) => void,
filter?: (x: SDKTypes) => boolean
Expand All @@ -144,11 +143,15 @@ export const createStepMenu = (
const stepMenuItems = stepLabels.map(x => {
const item = dialogGroups[x];
const subMenu: IContextualMenuProps = {
items: item.types.filter(filter || (x => true)).map($type => ({
key: $type,
name: ConceptLabels[$type] && ConceptLabels[$type].title ? ConceptLabels[$type].title : $type,
$type: $type,
})),
items: item.types.filter(filter || (() => true)).map($type => {
const conceptLabel = ConceptLabels[$type];

return {
key: $type,
name: conceptLabel && conceptLabel.title ? conceptLabel.title : $type,
$type: $type,
};
}),
onItemClick: (e, item: IContextualMenuItem | undefined) => {
if (item) {
item = {
Expand Down Expand Up @@ -187,7 +190,8 @@ export const createStepMenu = (
return stepMenuItems;
} else {
const stepMenuItems = dialogGroups[stepLabels[0]].types.map(item => {
const name = ConceptLabels[item] && ConceptLabels[item].title ? ConceptLabels[item].title : item;
const conceptLabel = ConceptLabels[item];
const name = conceptLabel && conceptLabel.title ? conceptLabel.title : item;
const menuItem: IContextualMenuItem = {
key: item,
text: name,
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
displayName: 'yarn install'
- script: cd Composer && yarn build:prod
displayName: 'yarn build:prod'
env:
NODE_OPTIONS: --max-old-space-size=2048
- script: cd Composer && yarn lint
displayName: 'yarn lint'
- script: cd Composer && yarn test:coverage
Expand Down Expand Up @@ -70,6 +72,8 @@ jobs:
displayName: 'yarn install'
- script: cd Composer && yarn build:prod
displayName: 'yarn build:prod'
env:
NODE_OPTIONS: --max-old-space-size=2048
- script: cd Composer && yarn test:integration
displayName: yarn test:integration
env:
Expand Down