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: Using Recoil JS for state management #3587

Merged
merged 133 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 115 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
729bdb3
replace useReducer with recoil
lei9444 Jun 19, 2020
4931134
update the import order
lei9444 Jun 19, 2020
b5f3b34
Lock updated
Jun 19, 2020
b439b42
add dialog, lg, lu to recoil
lei9444 Jun 22, 2020
3bc3f88
Wrapped up more app states
Jun 23, 2020
7fb8205
Wrapped up all app states
Jun 23, 2020
1ea44c3
Merge conflict resolved
Jun 24, 2020
0289a5b
wrapped up all bot state
lei9444 Jun 28, 2020
fe44fe6
Dispatcher fetch updated to enable typescript
Jun 24, 2020
450cfb4
Stable state updates
Jun 26, 2020
8e3643c
repalce all actions with dispatcher
lei9444 Jun 29, 2020
bbe7923
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
lei9444 Jun 29, 2020
c75ea8a
Unit test update
Jun 30, 2020
66c100d
Define Conversations state
Jun 30, 2020
dc61137
fix all build error
lei9444 Jun 30, 2020
b9e9232
Merge branch 'master' of https://github.com/microsoft/BotFramework-Co…
lei9444 Jun 30, 2020
11b45e7
fix merge confilct
lei9444 Jun 30, 2020
0f8c880
Merge branch 'master' into leilzh-srravich/recoil-spike
Jun 30, 2020
4bf5012
State updates
Jun 30, 2020
c761c67
Toolbar and other test updates
Jun 30, 2020
a8218ca
Project tree and navItem tests
Jun 30, 2020
811d476
Publish modal test updated
Jul 1, 2020
0b67346
refactor the file persistence
lei9444 Jul 1, 2020
b913eb7
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
lei9444 Jul 1, 2020
1d5852e
chore: Merge master into recoil spike (#3543)
srinaath Jul 1, 2020
afa8e62
Lint errors
Jul 1, 2020
99fcfa1
Merge branch 'master' into leilzh-srravich/recoil-spike
Jul 2, 2020
94cebaa
Yar lock updated and file persistence commented out
Jul 2, 2020
73b886e
Added ejection handling and export to zip
Jul 3, 2020
afc6b7a
fix some failed major workflow
lei9444 Jul 3, 2020
cc22f21
revert some code to wait for master to fix
lei9444 Jul 3, 2020
3b5878f
remove some snapshot in useRecoilCallback
lei9444 Jul 3, 2020
9b530cf
reset current path to initial path
Jul 5, 2020
f1fea20
useNotfiicationTest updated
Jul 6, 2020
0c67e4a
lgApi test passed
Jul 6, 2020
815009f
fix save as and luis deploy workflow
lei9444 Jul 6, 2020
f1e6ac0
remove old state management
lei9444 Jul 6, 2020
f845380
fix all client test
lei9444 Jul 6, 2020
bcb4e0e
add test for file persistence
lei9444 Jul 6, 2020
1ba2f96
Added project failure support (#3573)
srinaath Jul 6, 2020
581210d
Merge branch 'master' into leilzh-srravich/recoil-spike
Jul 6, 2020
aacda23
add unit test to shared.ts and some utilities
beyackle Jul 6, 2020
a3b2775
remove redundant type annotations
beyackle Jul 6, 2020
06d4720
remove extra projectId things
beyackle Jul 6, 2020
a08dbc5
fix more test failures
beyackle Jul 7, 2020
84602b1
Lg, lu recoil refactor
Jul 7, 2020
71e3578
Dispatcher test
Jul 7, 2020
eaf87c9
Renamed test
Jul 7, 2020
f432b66
fix file persistence switch error
lei9444 Jul 7, 2020
850bce4
fix test util lint
lei9444 Jul 7, 2020
5c3213a
update the recoil test
lei9444 Jul 7, 2020
6b00418
Merge branch 'master' of https://github.com/microsoft/BotFramework-Co…
lei9444 Jul 7, 2020
af238be
fix master conflict
lei9444 Jul 7, 2020
f31e73b
update the onboarding default value
lei9444 Jul 7, 2020
0aedaaf
fix publish to profile bug
lei9444 Jul 7, 2020
9336dd9
add tests for dialog
lei9444 Jul 7, 2020
003b09b
fix type failures and add legibility
beyackle Jul 7, 2020
08c4011
fix broken tests
beyackle Jul 7, 2020
8b690e9
Accessing current
Jul 7, 2020
8d4fe4f
Update dialog.test.tsx
beyackle Jul 7, 2020
64efe12
Update dialog.test.tsx
beyackle Jul 7, 2020
111037f
Update dialog.test.tsx
beyackle Jul 7, 2020
f7766bc
add initial tests to navigation
beyackle Jul 7, 2020
1c3ba7b
test updated
Jul 7, 2020
9a3667c
Header memoized
Jul 8, 2020
7777d51
split the app component for render perf
lei9444 Jul 8, 2020
e8283ee
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
lei9444 Jul 8, 2020
ae79afe
remove console
lei9444 Jul 8, 2020
2db68f4
update lg dispatcher test and fix some tests error
lei9444 Jul 8, 2020
639b04f
fix move failed bug
lei9444 Jul 8, 2020
f0a8cf7
fix broken tests
beyackle Jul 8, 2020
bbb1d31
Revert "fix broken tests"
beyackle Jul 8, 2020
155ac5f
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
beyackle Jul 8, 2020
1b186f2
fix failing tests
beyackle Jul 8, 2020
e29bfc6
Merge branch 'master' into leilzh-srravich/recoil-spike
Jul 8, 2020
24146f3
Lock file updated
Jul 8, 2020
b972110
update navigation tests
beyackle Jul 8, 2020
1144157
add more tests and fix typo
beyackle Jul 8, 2020
fc889e1
add more nav tests
beyackle Jul 8, 2020
b396b67
added templateid
Jul 9, 2020
b6761e8
Merge branch 'master' into leilzh-srravich/recoil-spike
Jul 9, 2020
98e246f
Updated skill test
Jul 9, 2020
e597c7d
remove lg template crud from worker
lei9444 Jul 9, 2020
fa7be31
update the lg content and add lgresolver
lei9444 Jul 9, 2020
8552eef
update lgapi.test and creationflow test
lei9444 Jul 9, 2020
a369cee
Create skill.test.ts
beyackle Jul 9, 2020
562904c
add tests and fix bug in skills.ts
beyackle Jul 9, 2020
8b90fa3
test everything but useSkill
beyackle Jul 9, 2020
7c76458
Update skill.test.ts
beyackle Jul 9, 2020
16809bd
Making toggles work for minmap, linenumber, onboarding and project tests
Jul 10, 2020
fa57b16
Reoved eject handler
Jul 10, 2020
e961663
update the skill atom function
lei9444 Jul 10, 2020
365f4e4
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
lei9444 Jul 10, 2020
e022d37
fix e2e test
lei9444 Jul 10, 2020
dabc1c7
Merge branch 'master' of https://github.com/microsoft/BotFramework-Co…
lei9444 Jul 10, 2020
2fcb0cc
fix router bug
lei9444 Jul 10, 2020
70a0134
fix lint
lei9444 Jul 10, 2020
015a93f
add lu.test
lei9444 Jul 10, 2020
c9152fc
update skill.test
lei9444 Jul 10, 2020
294ea2e
update lu.test
lei9444 Jul 10, 2020
38dcd02
add setting.test
lei9444 Jul 10, 2020
453eb77
Test update for http mock
Jul 10, 2020
6dcb9ce
add some user tests
beyackle Jul 10, 2020
9b0454d
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
beyackle Jul 10, 2020
62c25c8
Axios test pattern
Jul 10, 2020
418bbd5
update user unit tests and fix bug
beyackle Jul 10, 2020
f5c8885
Update dialog.test.tsx
beyackle Jul 10, 2020
19866e3
Export test complete
Jul 11, 2020
3d994ef
Merge branch 'master' into leilzh-srravich/recoil-spike
Jul 11, 2020
0bb231b
Renaming useResolver
Jul 12, 2020
28ad178
clean lg parser code and add tests for parser
lei9444 Jul 13, 2020
288ee8b
update publish luis test
lei9444 Jul 13, 2020
f815291
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Jul 13, 2020
e6353c8
update project test
lei9444 Jul 13, 2020
91139df
Update table-view.tsx
beyackle Jul 13, 2020
38f64eb
update lgutils
lei9444 Jul 15, 2020
455ac36
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Jul 16, 2020
ee3b7c9
Reduced mock project response data
Jul 16, 2020
f492348
More reduction in project payload size
Jul 16, 2020
38fe333
null check settings.luis
Jul 16, 2020
075c1c8
Added recoil to dev deps
Jul 16, 2020
19917d2
Merge branch 'main' into leilzh-srravich/recoil-spike
Jul 16, 2020
9259318
Removed awaits
Jul 17, 2020
2c6079e
fix lint
lei9444 Jul 17, 2020
ca94091
wrap dispatcher to get latest state
lei9444 Jul 20, 2020
0d4b8e5
Merge branch 'main' into leilzh-srravich/recoil-spike
lei9444 Jul 20, 2020
6a8935e
update the app update
lei9444 Jul 20, 2020
d42f652
Merge branch 'leilzh-srravich/recoil-spike' of https://github.com/mic…
lei9444 Jul 20, 2020
a19e338
clean the wrap
lei9444 Jul 20, 2020
56d2dd8
import fix from PR#3666
beyackle Jul 20, 2020
e1bce93
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Jul 21, 2020
cd243f5
Merge branch 'main' into leilzh-srravich/recoil-spike
boydc2014 Jul 21, 2020
ad873f9
Merge branch 'main' into leilzh-srravich/recoil-spike
srinaath Jul 21, 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
18 changes: 17 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"name": "Server: Attach",
"port": 9228,
"sourceMaps": true
}
},
{
"type": "node",
"request": "launch",
Expand All @@ -94,6 +94,22 @@
"NODE_ENV": "development",
},
"outputCapture": "std"
},
{
"name": "Debug current jest test",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/Composer/node_modules/jest/bin/jest",
"--runInBand"
],
"args": [
"${fileBasename}",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
4 changes: 3 additions & 1 deletion Composer/cypress/integration/Onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ context('Onboarding', () => {

//enable onboarding setting
cy.visitPage('Settings');
cy.findByText('Application Settings').click();
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('Application Settings').click();
});
cy.findByLabelText('Onboarding').click();
cy.visitPage('Design');
});
Expand Down
2 changes: 1 addition & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
"dependencies": {
"cross-env": "^6.0.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';

import { renderWithStore } from '../../../testUtils';
import { renderWithRecoil } from '../../../testUtils';
import { CreateOptions } from '../../../../src/components/CreationFlow/CreateOptions';

describe('<CreateOptions/>', () => {
const handleDismissMock = jest.fn();
const handleCreateNextMock = jest.fn();
const saveTemplateMock = jest.fn();
const templates = [
{
description: 'empty bot',
Expand All @@ -31,27 +30,13 @@ describe('<CreateOptions/>', () => {
tags: ['Basic'],
},
];
let storeContext;

const renderComponent = () => {
return renderWithStore(
<CreateOptions path="create" templates={templates} onDismiss={handleDismissMock} onNext={handleCreateNextMock} />,
storeContext.state,
storeContext.action
return renderWithRecoil(
<CreateOptions path="create" templates={templates} onDismiss={handleDismissMock} onNext={handleCreateNextMock} />
);
};

beforeEach(() => {
storeContext = {
actions: {
saveTemplateId: saveTemplateMock,
},
state: {
templateId: '',
},
};
});

it('should save empty bot template id', async () => {
const component = renderComponent();
const nextButton = await component.findByText('Next');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Licensed under the MIT License.

import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';
import { fireEvent, act, waitFor } from '@bfc/test-utils';

import { renderWithStore } from '../../../testUtils';
import { StorageFolder } from '../../../../src/store/types';
import { renderWithRecoil } from '../../../testUtils';
import { StorageFolder } from '../../../../src/recoilModel/types';
import { focusedStorageFolderState, storagesState } from '../../../../src/recoilModel';
import DefineConversation from '../../../../src/components/CreationFlow/DefineConversation';

describe('<DefineConversation/>', () => {
const onCurrentPathUpdateMock = jest.fn();
const saveTemplateMock = jest.fn();
const onSubmitMock = jest.fn();
const onDismissMock = jest.fn();
const createFolder = jest.fn();
const updateFolder = jest.fn();
let storeContext, locationMock;
let locationMock;
const focusedStorageFolder: StorageFolder = {
name: 'Desktop',
parent: '/test-folder',
Expand All @@ -33,35 +33,24 @@ describe('<DefineConversation/>', () => {
],
};
function renderComponent() {
return renderWithStore(
return renderWithRecoil(
<DefineConversation
createFolder={createFolder}
focusedStorageFolder={focusedStorageFolder}
location={locationMock}
templateId={'EchoBot'}
updateFolder={updateFolder}
onCurrentPathUpdate={onCurrentPathUpdateMock}
onDismiss={onDismissMock}
onSubmit={onSubmitMock}
/>,
storeContext.state,
storeContext.action
({ set }) => {
set(focusedStorageFolderState, '');
set(storagesState, [{ id: 'default' }]);
}
);
}

beforeEach(() => {
locationMock = {};
storeContext = {
actions: {
saveTemplateId: saveTemplateMock,
},
state: {
templateId: 'EchoBot',
focusedStorageFolder: '',
storages: [{ id: 'default' }],
},
};
});

it('should render the component', () => {
const component = renderComponent();
expect(component.container).toBeDefined();
Expand Down Expand Up @@ -98,8 +87,11 @@ describe('<DefineConversation/>', () => {
it('does not allow submission when the name is invalid', async () => {
const component = renderComponent();
const nameField = await component.getByTestId('NewDialogName');
fireEvent.change(nameField, { target: { value: 'invalidName;' } });
const node = await component.getByTestId('SubmitNewBotBtn');
act(() => {
fireEvent.change(nameField, { target: { value: 'invalidName;' } });
});

const node = await waitFor(() => component.getByTestId('SubmitNewBotBtn'));
expect(node).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

import * as React from 'react';
import { render, fireEvent } from '@bfc/test-utils';
import { render, fireEvent, act } from '@bfc/test-utils';

import { StorageFolder } from '../../../../src/store/types';
import { StorageFolder } from '../../../../src/recoilModel/types';
import { FileSelector } from '../../../../src/components/CreationFlow/FileSelector';

describe('<FileSelector/>', () => {
Expand Down Expand Up @@ -55,7 +55,10 @@ describe('<FileSelector/>', () => {
it('should open file', async () => {
const component = renderComponent();
const bot = await component.findByText('EchoBot-0');
fireEvent.click(bot);
act(() => {
fireEvent.click(bot);
});

expect(onFileChosen).toBeCalledWith({
name: 'EchoBot-0',
type: 'bot',
Expand All @@ -70,7 +73,9 @@ describe('<FileSelector/>', () => {
const comboBox = await component.findByTestId('FileSelectorComboBox');
const dropdown = comboBox.querySelector('.ms-ComboBox-CaretDown-button');
if (dropdown) {
fireEvent.click(dropdown);
act(() => {
fireEvent.click(dropdown);
});
}
expect(await component.findByText('C:\\test-folder')).toBeInTheDocument();
expect(await component.findByText('C:\\')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@

import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';
import { MutableSnapshot } from 'recoil';

import { StorageFolder } from '../../../../src/store/types';
import { StorageFolder } from '../../../../src/recoilModel/types';
import { renderWithRecoil } from '../../../testUtils';
import { LocationSelectContent } from '../../../../src/components/CreationFlow/LocationSelectContent';
import { renderWithStore } from '../../../testUtils';
import { CreationFlowStatus } from '../../../../src/constants';
import { storageFileLoadingStatusState, creationFlowStatusState, storagesState } from '../../../../src/recoilModel';

describe('<LocationSelectContent/>', () => {
const onCurrentPathUpdateMock = jest.fn();
const onOpenMock = jest.fn();
const operationMode = { write: true, read: true };
let storeContext;

const focusedStorageFolder: StorageFolder = {
name: 'Desktop',
parent: 'C:/test-folder',
Expand All @@ -37,61 +39,66 @@ describe('<LocationSelectContent/>', () => {
},
],
};
function renderComponent() {
return renderWithStore(

const storages = [
{
defaultPath: 'C:\\',
id: 'default',
name: 'This PC',
path: 'C:/test-folder/Desktop',
platform: 'win32',
type: 'LocalDisk',
},
];

function renderComponent(recoilInitState: (obj: MutableSnapshot) => void) {
return renderWithRecoil(
<LocationSelectContent
focusedStorageFolder={focusedStorageFolder}
operationMode={operationMode}
onCurrentPathUpdate={onCurrentPathUpdateMock}
onOpen={onOpenMock}
/>,
storeContext.state
recoilInitState
);
}

beforeEach(() => {
storeContext = {
state: {
storages: [
{
defaultPath: 'C:\\',
id: 'default',
name: 'This PC',
path: 'C:/test-folder/Desktop',
platform: 'win32',
type: 'LocalDisk',
},
],
storageFileLoadingStatus: 'success',
creationFlowStatus: CreationFlowStatus.OPEN,
},
};
});

it('should render spinner', async () => {
storeContext.state.storageFileLoadingStatus = 'pending';
const component = renderComponent();
const component = renderComponent(({ set }) => {
set(storageFileLoadingStatusState, 'pending');
set(creationFlowStatusState, CreationFlowStatus.OPEN);
set(storagesState, storages);
});
const spinner = await component.findByTestId('locationSelectContentSpinner');
expect(spinner).toBeDefined();
});

it('fail to render FileSelector', async () => {
storeContext.state.storageFileLoadingStatus = 'failure';
const component = renderComponent();
const component = renderComponent(({ set }) => {
set(storageFileLoadingStatusState, 'failure');
set(creationFlowStatusState, CreationFlowStatus.OPEN);
set(storagesState, storages);
});
expect(await component.findByText('Can not connect the storage.')).toBeInTheDocument();
});

it('should open folder', async () => {
storeContext.state.storageFileLoadingStatus = 'success';
const component = renderComponent();
const component = renderComponent(({ set }) => {
set(storageFileLoadingStatusState, 'success');
set(creationFlowStatusState, CreationFlowStatus.OPEN);
set(storagesState, storages);
});
const parent = await component.findByText('..');
fireEvent.click(parent);
expect(onCurrentPathUpdateMock).toBeCalledWith('C:/test-folder', 'default');
});

it('should open bot', async () => {
storeContext.state.storageFileLoadingStatus = 'success';
const component = renderComponent();
const component = renderComponent(({ set }) => {
set(storageFileLoadingStatusState, 'success');
set(storagesState, storages);
set(creationFlowStatusState, CreationFlowStatus.OPEN);
});
const bot = await component.findByText('EchoBot-0');
fireEvent.click(bot);
expect(onOpenMock).toBeCalledWith('C:/test-folder/Desktop/EchoBot-0', 'default');
Expand Down
Loading