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 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4005df5
BotProjects update
Sep 14, 2020
8882c4b
All tests except Undo/Redo working
Sep 14, 2020
6451a7f
Removed logs
Sep 14, 2020
ff9724b
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
Sep 14, 2020
e58a70d
add en-US
beyackle Sep 14, 2020
21f4f31
Value match
Sep 14, 2020
9daad67
Merge branch 'srravich/bot-projects-recoil' of https://github.com/mic…
Sep 14, 2020
72b76b6
Qna maker fetch from URL fixed
Sep 15, 2020
86851ae
Merge branch 'main' into srravich/bot-projects-recoil
srinaath Sep 15, 2020
c3f7de1
Handled current project Id
Sep 15, 2020
3621787
Merge branch 'srravich/bot-projects-recoil' of https://github.com/mic…
Sep 15, 2020
96f854f
Remove unused var
Sep 15, 2020
72cb7ed
Resolve bug with notifications
Sep 15, 2020
e0c92ce
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
Sep 15, 2020
052b4c5
Integration test passes for trigger creation
Sep 15, 2020
43ebeae
Revert en-us.json
Sep 15, 2020
29de0d7
PR cleanup
Sep 15, 2020
1f53275
Merge branch 'main' into srravich/bot-projects-recoil
srinaath Sep 15, 2020
b88b049
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
Sep 15, 2020
bcddcac
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
Sep 16, 2020
70f3157
Delete bot resolved
Sep 16, 2020
5941ffa
Remove unused selectors
Sep 16, 2020
c92167a
Remove unused refs
Sep 16, 2020
0a881f0
remove fit
Sep 17, 2020
93b6a91
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
Sep 17, 2020
1983e5d
PR feedback
Sep 17, 2020
43953a5
Delete files untracked
Sep 17, 2020
d2ac51d
Removed unused files
Sep 17, 2020
b287f85
Added back the locale
Sep 17, 2020
fae82ec
Skills tests fixed
Sep 17, 2020
6aa4f6f
Update test name
Sep 17, 2020
2dc1926
Load dialog settings url by default on clicking settings
Sep 17, 2020
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
80 changes: 19 additions & 61 deletions Composer/packages/client/__tests__/components/skill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
import * as React from 'react';
import { act, fireEvent, getByLabelText, getByTestId, getByText } from '@bfc/test-utils';
import { Skill } from '@bfc/shared';
import { act } from '@bfc/test-utils/lib/hooks';

import httpClient from '../../src//utils/httpUtil';
import SkillList from '../../src/pages/skills/skill-list';
import { renderWithRecoil } from '../testUtils';
import CreateSkillModal from '../../src/components/CreateSkillModal';
import { settingsState, currentProjectIdState, botEndpointsState } from '../../src/recoilModel';
import CreateSkillModal, {
validateEndpoint,
validateManifestUrl,
validateName,
} from '../../src/components/CreateSkillModal';
import { currentProjectIdState, settingsState, skillsState } from '../../src/recoilModel';
import Skills from '../../src/pages/skills';

jest.mock('../../src//utils/httpUtil');

jest.mock('../../src/components/Modal/dialogStyle', () => ({}));

const projectId = '12321.234234';

const items: Skill[] = [
const skills: Skill[] = [
{
manifestUrl: 'https://yuesuemailskill0207-gjvga67.azurewebsites.net/manifest/manifest-1.0.json',
name: 'Email-Skill',
Expand All @@ -41,36 +43,15 @@ const items: Skill[] = [
},
];

const recoilInitState = ({ set }) => {
set(currentProjectIdState, projectId);
set(botEndpointsState, {
projectId: 'http://localhost:3000/api/messages',
});
set(settingsState(projectId), {
luis: {
name: '',
authoringKey: '12345',
authoringEndpoint: 'testAuthoringEndpoint',
endpointKey: '12345',
endpoint: 'testEndpoint',
authoringRegion: 'westus',
defaultLanguage: 'en-us',
environment: 'composer',
},
qna: {
subscriptionKey: '12345',
qnaRegion: 'westus',
endpointKey: '',
},
});
};
let recoilInitState;
const projectId = '123a.234';

describe('Skill page', () => {
beforeEach(() => {
recoilInitState = ({ set }) => {
set(projectIdState, '243245');
set(skillsState, skills),
set(settingsState, {
set(currentProjectIdState, '243245');
set(skillsState(projectId), skills),
set(settingsState(projectId), {
luis: {
name: '',
authoringKey: '12345',
Expand All @@ -90,10 +71,8 @@ describe('Skill page', () => {
};
});

const button = getByText('Connect to a new skill');
act(() => {
fireEvent.click(button);
});
it('can add a new skill', async () => {
const { baseElement } = renderWithRecoil(<Skills />, recoilInitState);

const button = getByText(baseElement, 'Connect to a new skill');
act(() => {
Expand All @@ -112,25 +91,10 @@ describe('Skill page', () => {

describe('<SkillList />', () => {
it('should render the SkillList', () => {
const { container } = renderWithRecoil(
<SkillList projectId={projectId} skills={items} onDelete={jest.fn()} onEdit={jest.fn()} />
);
expect(container).toHaveTextContent('Email Skill');
const { container } = renderWithRecoil(<SkillList projectId={'123'} />, recoilInitState);
expect(container).toHaveTextContent('Email-Skill');
expect(container).toHaveTextContent('Point Of Interest Skill');
});

it('can edit the skill', () => {
const onEdit = jest.fn();
const { getAllByTestId } = renderWithRecoil(
<SkillList projectId={projectId} skills={items} onDelete={jest.fn()} onEdit={onEdit} />
);

const editBtns = getAllByTestId('EditSkill');
editBtns.forEach((btn, i) => {
fireEvent.click(btn);
expect(onEdit).toHaveBeenCalledWith(i);
});
});
});

describe('<SkillForm />', () => {
Expand All @@ -142,14 +106,8 @@ describe('<SkillForm />', () => {
const onDismiss = jest.fn();
const onSubmit = jest.fn();
const { getByLabelText, getByText } = renderWithRecoil(
<CreateSkillModal
isOpen
editIndex={0}
projectId={projectId}
skills={items}
onDismiss={onDismiss}
onSubmit={onSubmit}
/>
<CreateSkillModal projectId={'123'} onDismiss={onDismiss} onSubmit={onSubmit} />,
recoilInitState
);

const urlInput = getByLabelText('Manifest url');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const validateName = ({
};

export const CreateSkillModal: React.FC<CreateSkillModalProps> = ({ projectId, onSubmit, onDismiss }) => {
const skills = useRecoilValue(skillsState);
const skills = useRecoilValue(skillsState(projectId));

const [formData, setFormData] = useState<Partial<Skill>>({});
const [formDataErrors, setFormDataErrors] = useState<SkillFormDataErrors>({});
Expand Down
6 changes: 2 additions & 4 deletions Composer/packages/client/src/pages/design/DesignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
const focusPath = useRecoilValue(focusPathState(projectId));
const showCreateDialogModal = useRecoilValue(showCreateDialogModalState(projectId));
const showAddSkillDialogModal = useRecoilValue(showAddSkillDialogModalState(projectId));
const skills = useRecoilValue(skillsState(projectId));
const actionsSeed = useRecoilValue(actionsSeedState(projectId));
const locale = useRecoilValue(localeState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
Expand All @@ -129,7 +128,6 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
const { undo, redo, canRedo, canUndo, commitChanges, clearUndo } = undoFunction;
const visualEditorSelection = useRecoilValue(visualEditorSelectionState);
const {
addSkill,
removeDialog,
updateDialog,
createDialogCancel,
Expand All @@ -145,6 +143,7 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
exportToZip,
onboardingAddCoachMarkRef,
importQnAFromUrls,
addSkill,
} = useRecoilValue(dispatcherState);

const params = new URLSearchParams(location?.search);
Expand Down Expand Up @@ -675,9 +674,8 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
{showAddSkillDialogModal && (
<CreateSkillModal
projectId={projectId}
skills={skills}
onDismiss={() => addSkillDialogCancel(projectId)}
onSubmit={handleAddSkillDialogSubmit}
onSubmit={(skill) => addSkill(projectId, skill)}
/>
)}
{exportSkillModalVisible && (
Expand Down
10 changes: 5 additions & 5 deletions Composer/packages/client/src/pages/skills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import formatMessage from 'format-message';
import { useRecoilValue } from 'recoil';
import { Skill } from '@bfc/shared';

import { dispatcherState, settingsState, botNameState, skillsState } from '../../recoilModel';
import { dispatcherState, settingsState, botNameState } from '../../recoilModel';
import { Toolbar, IToolbarItem } from '../../components/Toolbar';
import { TestController } from '../../components/TestController/TestController';
import { CreateSkillModal } from '../../components/CreateSkillModal';
Expand All @@ -20,11 +20,11 @@ import SkillList from './skill-list';

const Skills: React.FC<RouteComponentProps<{ projectId: string }>> = (props) => {
const { projectId = '' } = props;
const [editIndex, setEditIndex] = useState<number | undefined>();
const skills = useRecoilValue(skillsState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const [showAddSkillDialogModal, setShowAddSkillDialogModal] = useState(false);

const botName = useRecoilValue(botNameState(projectId));
const { setSettings, updateSkill } = useRecoilValue(dispatcherState);
const settings = useRecoilValue(settingsState(projectId));
const { addSkill, setSettings } = useRecoilValue(dispatcherState);

const toolbarItems: IToolbarItem[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/pages/skills/skill-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ interface SkillListProps {

const SkillList: React.FC<SkillListProps> = ({ projectId }) => {
const { removeSkill, updateSkill } = useRecoilValue(dispatcherState);
const skills = useRecoilValue(skillsState);
const skills = useRecoilValue(skillsState(projectId));

const [selectedSkillUrl, setSelectedSkillUrl] = useState<string | null>(null);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('dialog dispatcher', () => {
dispatcher = renderedComponent.current.currentDispatcher;
});

fit('removes a dialog file', async () => {
it('removes a dialog file', async () => {
await act(async () => {
await dispatcher.createDialog({ id: '1', content: 'abcde', projectId });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Multilang dispatcher', () => {
dispatcher = renderedComponent.current.currentDispatcher;
});

fit('add language', async () => {
it('add language', async () => {
await act(async () => {
await dispatcher.addLanguages({
languages: ['zh-cn'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('navigation dispatcher', () => {
});

describe('selectAndFocus', () => {
fit('sets selection and focus with a valud search', async () => {
it('sets selection and focus with a valud search', async () => {
mockGetUrlSearch.mockReturnValue('?foo=bar&baz=quux');
await act(async () => {
await dispatcher.selectAndFocus(projectId, 'dialogId', 'select', 'focus');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
settingsState,
showAddSkillDialogModalState,
displaySkillManifestState,
projectIdState,
} from '../../atoms/botState';
import { dispatcherState } from '../../DispatcherWrapper';
import { currentProjectIdState } from '../../atoms';
Expand Down Expand Up @@ -52,9 +51,10 @@ describe('skill dispatcher', () => {
mockDialogComplete.mockClear();

const useRecoilTestHook = () => {
const projectId = useRecoilValue(currentProjectIdState);
const skillManifests = useRecoilValue(skillManifestsState(projectId));
const onAddSkillDialogComplete = useRecoilValue(onAddSkillDialogCompleteState(projectId));
const skills = useRecoilValue(skillsState(projectId));
const skills: Skill[] = useRecoilValue(skillsState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const showAddSkillDialogModal = useRecoilValue(showAddSkillDialogModalState(projectId));
const displaySkillManifest = useRecoilValue(displaySkillManifestState(projectId));
Expand Down Expand Up @@ -132,43 +132,30 @@ describe('skill dispatcher', () => {
]);
});

describe('updateSkill', () => {
it('adds a skill', async () => {
await act(async () => {
dispatcher.updateSkill({
projectId,
targetId: -1,
skillData: makeTestSkill(3),
});
});
expect(renderedComponent.current.showAddSkillDialogModal).toBe(false);
expect(renderedComponent.current.onAddSkillDialogComplete.func).toBeUndefined();
expect(renderedComponent.current.skills).toContainEqual(makeTestSkill(3));
it('addsSkill', async () => {
await act(async () => {
dispatcher.addSkill('123', makeTestSkill(3));
});
it('modifies a skill', async () => {
await act(async () => {
dispatcher.updateSkill({
projectId,
targetId: 0,
skillData: makeTestSkill(100),
});
expect(renderedComponent.current.showAddSkillDialogModal).toBe(false);
expect(renderedComponent.current.onAddSkillDialogComplete.func).toBeUndefined();
expect(renderedComponent.current.skills).toContainEqual(makeTestSkill(3));
});

it('updateSkill', async () => {
await act(async () => {
dispatcher.updateSkill('123', {
targetId: 0,
skillData: makeTestSkill(100),
});
expect(renderedComponent.current.showAddSkillDialogModal).toBe(false);
expect(renderedComponent.current.onAddSkillDialogComplete.func).toBeUndefined();
expect(renderedComponent.current.skills).not.toContain(makeTestSkill(1));
expect(renderedComponent.current.skills).toContainEqual(makeTestSkill(100));
});
it('deletes a skill', async () => {
await act(async () => {
dispatcher.updateSkill({
projectId,
targetId: 0,
skillData: {},
});
});
expect(renderedComponent.current.showAddSkillDialogModal).toBe(false);
expect(renderedComponent.current.onAddSkillDialogComplete.func).toBeUndefined();
expect(renderedComponent.current.skills).not.toContain(makeTestSkill(1));

expect(renderedComponent.current.skills).not.toContain(makeTestSkill(1));
expect(renderedComponent.current.skills).toContainEqual(makeTestSkill(100));
});

it('removeSkill', async () => {
await act(async () => {
dispatcher.removeSkill('123', makeTestSkill(1).manifestUrl);
});
expect(renderedComponent.current.skills).not.toContain(makeTestSkill(1));
});
Expand Down

This file was deleted.

Loading