Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: State management support for loading mutiple projects #4117

Merged
merged 32 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ describe('<CreationFlow/>', () => {
'',
expect.stringMatching(/(\/|\\)test-folder(\/|\\)Desktop/),
'',
'en-US'
'en-US',
undefined
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';

import { PublishDialog } from '../../../src/components/TestController/publishDialog';
import { projectIdState, botNameState, settingsState, dispatcherState } from '../../../src/recoilModel';
import { botNameState, settingsState, dispatcherState, currentProjectIdState } from '../../../src/recoilModel';
import { renderWithRecoil } from '../../testUtils';
jest.useFakeTimers();

const projectId = '12abvc.as324';
const luisConfig = {
name: '',
authoringKey: '12345',
Expand All @@ -29,15 +30,22 @@ describe('<PublishDialog />', () => {
set(dispatcherState, {
setSettings: setSettingsMock,
});
set(projectIdState, '12345');
set(botNameState, 'sampleBot0');
set(settingsState, {
set(currentProjectIdState, projectId);
set(botNameState(projectId), 'sampleBot0');
set(settingsState(projectId), {
luis: luisConfig,
qna: qnaConfig,
});
};
const { getByText } = renderWithRecoil(
<PublishDialog isOpen botName={'sampleBot0'} config={config} onDismiss={onDismiss} onPublish={onPublish} />,
<PublishDialog
isOpen
botName={'sampleBot0'}
config={config}
projectId={projectId}
onDismiss={onDismiss}
onPublish={onPublish}
/>,
recoilInitState
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { showCreateDialogModalState } from '../../src/recoilModel';
describe('<CreateDialogModal/>', () => {
const onSubmitMock = jest.fn();
const onDismissMock = jest.fn();
const projectId = 'test-create-dialog';

function renderComponent() {
return renderWithRecoil(
<CreateDialogModal isOpen onDismiss={onDismissMock} onSubmit={onSubmitMock} />,
<CreateDialogModal isOpen projectId={projectId} onDismiss={onDismissMock} onSubmit={onSubmitMock} />,
({ set }) => {
set(showCreateDialogModalState, true);
set(showCreateDialogModalState(projectId), true);
}
);
}
Expand Down
11 changes: 9 additions & 2 deletions Composer/packages/client/__tests__/components/design.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jest.mock('@bfc/code-editor', () => {
LuEditor: () => <div></div>,
};
});
const projectId = '1234a-324234';

describe('<ProjectTree/>', () => {
it('should render the ProjectTree', async () => {
Expand Down Expand Up @@ -46,7 +47,7 @@ describe('<ProjectTree/>', () => {
});
const handleSubmit = jest.fn(() => {});
const { getByText } = renderWithRecoil(
<CreateDialogModal isOpen={isOpen} onDismiss={handleDismiss} onSubmit={handleSubmit} />
<CreateDialogModal isOpen={isOpen} projectId={projectId} onDismiss={handleDismiss} onSubmit={handleSubmit} />
);
const cancelButton = getByText('Cancel');
fireEvent.click(cancelButton);
Expand All @@ -60,7 +61,13 @@ describe('<ProjectTree/>', () => {
});
const handleSubmit = jest.fn(() => {});
const { getByText } = renderWithRecoil(
<TriggerCreationModal dialogId={'todobot'} isOpen={isOpen} onDismiss={handleDismiss} onSubmit={handleSubmit} />
<TriggerCreationModal
dialogId={'todobot'}
isOpen={isOpen}
projectId={projectId}
onDismiss={handleDismiss}
onSubmit={handleSubmit}
/>
);
const cancelButton = getByText('Cancel');
fireEvent.click(cancelButton);
Expand Down
20 changes: 9 additions & 11 deletions Composer/packages/client/__tests__/components/skill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CreateSkillModal, {
validateManifestUrl,
validateName,
} from '../../src/components/CreateSkillModal';
import { settingsState, projectIdState, skillsState } from '../../src/recoilModel';
import { currentProjectIdState, settingsState, skillsState } from '../../src/recoilModel';
import Skills from '../../src/pages/skills';

jest.mock('../../src//utils/httpUtil');
Expand Down Expand Up @@ -44,13 +44,14 @@ const skills: Skill[] = [
];

let recoilInitState;
const projectId = '123a.234';

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

describe('<SkillList />', () => {
it('should render the SkillList', () => {
const { container } = renderWithRecoil(<SkillList projectId={'123'} />, recoilInitState);
const { container } = renderWithRecoil(<SkillList projectId={projectId} />, recoilInitState);
expect(container).toHaveTextContent('Email-Skill');
expect(container).toHaveTextContent('Point Of Interest Skill');
});
Expand All @@ -105,7 +106,7 @@ describe('<SkillForm />', () => {
const onDismiss = jest.fn();
const onSubmit = jest.fn();
const { getByLabelText, getByText } = renderWithRecoil(
<CreateSkillModal projectId={'123'} onDismiss={onDismiss} onSubmit={onSubmit} />,
<CreateSkillModal projectId={projectId} onDismiss={onDismiss} onSubmit={onSubmit} />,
recoilInitState
);

Expand All @@ -120,20 +121,17 @@ describe('<SkillForm />', () => {
act(() => {
fireEvent.click(submitButton);
});

expect(onSubmit).not.toBeCalled();
});

let formDataErrors;
let projectId;
let validationState;
let setFormDataErrors;
let setSkillManifest;
let setValidationState;

beforeEach(() => {
formDataErrors = {};
projectId = '123';
validationState = {};
setFormDataErrors = jest.fn();
setSkillManifest = jest.fn();
Expand Down Expand Up @@ -225,7 +223,7 @@ describe('<SkillForm />', () => {
manifestUrl: 'Validating',
})
);
expect(httpClient.post).toBeCalledWith('/projects/123/skill/check', { url: formData.manifestUrl });
expect(httpClient.post).toBeCalledWith(`/projects/${projectId}/skill/check`, { url: formData.manifestUrl });
expect(setSkillManifest).toBeCalledWith('skill manifest');
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -259,7 +257,7 @@ describe('<SkillForm />', () => {
manifestUrl: 'Validating',
})
);
expect(httpClient.post).toBeCalledWith('/projects/123/skill/check', { url: formData.manifestUrl });
expect(httpClient.post).toBeCalledWith(`/projects/${projectId}/skill/check`, { url: formData.manifestUrl });
expect(setSkillManifest).not.toBeCalled();
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import { fireEvent, waitFor } from '@bfc/test-utils';
import { TriggerCreationModal } from '../../src/components/ProjectTree/TriggerCreationModal';
import { renderWithRecoil } from '../testUtils';

const projectId = '123a-bv3c4';

describe('<TriggerCreationModal/>', () => {
const onSubmitMock = jest.fn();
const onDismissMock = jest.fn();

function renderComponent() {
return renderWithRecoil(
<TriggerCreationModal isOpen dialogId={'todobot'} onDismiss={onDismissMock} onSubmit={onSubmitMock} />
<TriggerCreationModal
isOpen
dialogId={'todobot'}
projectId={projectId}
onDismiss={onDismissMock}
onSubmit={onSubmitMock}
/>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import TableView from '../../../src/pages/knowledge-base/table-view';
import CodeEditor from '../../../src/pages/knowledge-base/code-editor';
import { renderWithRecoil } from '../../testUtils';
import {
projectIdState,
localeState,
dialogsState,
qnaFilesState,
settingsState,
schemasState,
dispatcherState,
currentProjectIdState,
} from '../../../src/recoilModel';
import mockProjectResponse from '../../../src/recoilModel/dispatchers/__tests__/mocks/mockProjectResponse.json';

Expand Down Expand Up @@ -50,26 +50,29 @@ const state = {
const updateQnAFileMock = jest.fn();

const initRecoilState = ({ set }) => {
set(projectIdState, state.projectId);
set(localeState, state.locale);
set(dialogsState, state.dialogs);
set(qnaFilesState, state.qnaFiles);
set(settingsState, state.settings);
set(schemasState, mockProjectResponse.schemas);
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), state.locale);
set(dialogsState(state.projectId), state.dialogs);
set(qnaFilesState(state.projectId), state.qnaFiles);
set(settingsState(state.projectId), state.settings);
set(schemasState(state.projectId), mockProjectResponse.schemas);
set(dispatcherState, {
updateQnAFile: updateQnAFileMock,
});
};

describe('QnA page all up view', () => {
it('should render QnA page table view', () => {
const { getByText, getByTestId } = renderWithRecoil(<TableView dialogId={'a'} />, initRecoilState);
const { getByText, getByTestId } = renderWithRecoil(
<TableView dialogId={'a'} projectId={state.projectId} />,
initRecoilState
);
getByTestId('table-view');
getByText('question (1)');
getByText('answer');
});

it('should render QnA page code editor', () => {
renderWithRecoil(<CodeEditor dialogId={'a'} />, initRecoilState);
renderWithRecoil(<CodeEditor dialogId={'a'} projectId={state.projectId} />, initRecoilState);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { renderWithRecoil } from '../../testUtils';
import TableView from '../../../src/pages/language-generation/table-view';
import CodeEditor from '../../../src/pages/language-generation/code-editor';
import {
projectIdState,
localeState,
luFilesState,
lgFilesState,
settingsState,
schemasState,
dialogsState,
currentProjectIdState,
} from '../../../src/recoilModel';
import mockProjectResponse from '../../../src/recoilModel/dispatchers/__tests__/mocks/mockProjectResponse.json';

Expand Down Expand Up @@ -48,23 +48,26 @@ const state = {
};

const initRecoilState = ({ set }) => {
set(projectIdState, state.projectId);
set(localeState, state.locale);
set(dialogsState, state.dialogs);
set(luFilesState, state.luFiles);
set(lgFilesState, state.lgFiles);
set(settingsState, state.settings);
set(schemasState, mockProjectResponse.schemas);
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), state.locale);
set(dialogsState(state.projectId), state.dialogs);
set(luFilesState(state.projectId), state.luFiles);
set(lgFilesState(state.projectId), state.lgFiles);
set(settingsState(state.projectId), state.settings);
set(schemasState(state.projectId), mockProjectResponse.schemas);
};

describe('LG page all up view', () => {
it('should render lg page table view', () => {
const { getByText, getByTestId } = renderWithRecoil(<TableView dialogId={'a'} />, initRecoilState);
const { getByText, getByTestId } = renderWithRecoil(
<TableView dialogId={'a'} projectId={state.projectId} />,
initRecoilState
);
getByTestId('table-view');
getByText('Name');
});

it('should render lg page code editor', () => {
renderWithRecoil(<CodeEditor dialogId={'a'} />, initRecoilState);
renderWithRecoil(<CodeEditor dialogId={'a'} projectId={state.projectId} />, initRecoilState);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import TableView from '../../../src/pages/language-understanding/table-view';
import CodeEditor from '../../../src/pages/language-understanding/code-editor';
import { renderWithRecoil } from '../../testUtils';
import {
projectIdState,
localeState,
dialogsState,
luFilesState,
lgFilesState,
settingsState,
schemasState,
currentProjectIdState,
} from '../../../src/recoilModel';
import mockProjectResponse from '../../../src/recoilModel/dispatchers/__tests__/mocks/mockProjectResponse.json';

Expand Down Expand Up @@ -41,23 +41,26 @@ const state = {
};

const initRecoilState = ({ set }) => {
set(projectIdState, state.projectId);
set(localeState, state.locale);
set(dialogsState, state.dialogs);
set(luFilesState, state.luFiles);
set(lgFilesState, state.lgFiles);
set(settingsState, state.settings);
set(schemasState, mockProjectResponse.schemas);
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), state.locale);
set(dialogsState(state.projectId), state.dialogs);
set(luFilesState(state.projectId), state.luFiles);
set(lgFilesState(state.projectId), state.lgFiles);
set(settingsState(state.projectId), state.settings);
set(schemasState(state.projectId), mockProjectResponse.schemas);
};

describe('LU page all up view', () => {
it('should render lu page table view', () => {
const { getByText, getByTestId } = renderWithRecoil(<TableView dialogId={'a'} />, initRecoilState);
const { getByText, getByTestId } = renderWithRecoil(
<TableView dialogId={'a'} projectId={state.projectId} />,
initRecoilState
);
getByTestId('table-view');
getByText('Intent');
});

it('should render lu page code editor', () => {
renderWithRecoil(<CodeEditor dialogId={'a'} />, initRecoilState);
renderWithRecoil(<CodeEditor dialogId={'a'} projectId={state.projectId} />, initRecoilState);
});
});
Loading