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 all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
933176f
update add remote skill UI
VanyLaw Mar 25, 2021
db46a28
polish
VanyLaw Mar 25, 2021
20d8313
add trigger after skill created
VanyLaw Mar 29, 2021
d4c9c99
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Mar 29, 2021
b16038f
add action to on intent trigger after add remote skill
VanyLaw Mar 30, 2021
e77a107
import orchestrator after add remote skill
VanyLaw Apr 1, 2021
1cf0356
add loading spinner
VanyLaw Apr 1, 2021
86e819a
fix bug
VanyLaw Apr 1, 2021
b17ab63
add skill and alowCalled into appsettings
VanyLaw Apr 2, 2021
c814826
fix skill identifier wrong in new action
VanyLaw Apr 2, 2021
6822d1a
merge main, fix conflict, remove orchestractor modal if recognizer is…
VanyLaw Apr 6, 2021
3584a2f
fix skill identifier
VanyLaw Apr 6, 2021
4cde587
remove allowedCaller when remove skill
VanyLaw Apr 7, 2021
0588d3a
merge main, fix conflict
VanyLaw Apr 7, 2021
7272857
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 7, 2021
0ee913b
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 7, 2021
518118f
fix skill not added after add remote skill
VanyLaw Apr 7, 2021
5a1a4d3
Merge branch 'wenyluo/skill' of https://github.com/microsoft/BotFrame…
VanyLaw Apr 7, 2021
ebbb86e
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 7, 2021
5fc8bf9
fix orchestractor modal not show
VanyLaw Apr 8, 2021
d85bb7d
remove trigger when remove skill, fix bugs
VanyLaw Apr 8, 2021
29577bd
polish UI
VanyLaw Apr 8, 2021
ead4f72
merge main, fix conflict
VanyLaw Apr 9, 2021
2aca4f2
Merge branch 'main' into wenyluo/skill
luhan2017 Apr 9, 2021
9429c20
add endpoint dropdown
VanyLaw Apr 9, 2021
44383c3
Merge branch 'wenyluo/skill' of https://github.com/microsoft/BotFrame…
VanyLaw Apr 9, 2021
f8eb9b0
en-us
VanyLaw Apr 12, 2021
062cb15
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 12, 2021
3e262af
filter duplicate msAppId in allowedCaller
VanyLaw Apr 12, 2021
be423f6
disable entity in lueditor
VanyLaw Apr 12, 2021
199af75
polish
VanyLaw Apr 12, 2021
e07473a
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 13, 2021
5cfda9c
fix some comments
VanyLaw Apr 13, 2021
c58452c
fix lint
VanyLaw Apr 13, 2021
a540426
merge main
VanyLaw Apr 14, 2021
1c9b20f
fix comments
VanyLaw Apr 14, 2021
918cb92
add prerelease
VanyLaw Apr 14, 2021
7b140cb
fix test, fix endpoints bug, append intent to multiLanguage lufile
VanyLaw Apr 14, 2021
ae5f185
polish
VanyLaw Apr 15, 2021
2a95309
merge main, fix conflict
VanyLaw Apr 15, 2021
6b79809
disable next if lueditor error
VanyLaw Apr 15, 2021
62fe89b
fix lint
VanyLaw Apr 15, 2021
7820674
fix multi language
VanyLaw Apr 15, 2021
ecf0835
show warning msg if remote lufile get fail
VanyLaw Apr 15, 2021
065949a
fix typecheck
VanyLaw Apr 15, 2021
9d8e7a7
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 16, 2021
9c08697
fix comments
VanyLaw Apr 16, 2021
aca30c5
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 16, 2021
abad6da
Merge branch 'main' into wenyluo/skill
luhan2017 Apr 16, 2021
93b5418
fix test
VanyLaw Apr 16, 2021
4f36cf9
fix comments
VanyLaw Apr 16, 2021
63653f6
Merge branch 'wenyluo/skill' of https://github.com/microsoft/BotFrame…
VanyLaw Apr 16, 2021
f0f2e3f
fix test
VanyLaw Apr 16, 2021
cab38b8
merge main
VanyLaw Apr 19, 2021
f6229b2
fix comments
VanyLaw Apr 19, 2021
2ef5330
Merge remote-tracking branch 'origin/main' into wenyluo/skill
VanyLaw Apr 19, 2021
4778d9f
change sidebar back
VanyLaw Apr 19, 2021
90b268a
enus
VanyLaw Apr 19, 2021
f5e7dc5
Merge branch 'main' into wenyluo/skill
cwhitten Apr 19, 2021
8ca6c94
Merge branch 'main' into wenyluo/skill
cwhitten Apr 19, 2021
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
195 changes: 21 additions & 174 deletions Composer/packages/client/__tests__/components/skill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { act, fireEvent } from '@botframework-composer/test-utils';

import httpClient from '../../src/utils/httpUtil';
import { renderWithRecoil } from '../testUtils';
import CreateSkillModal, { validateEndpoint, validateManifestUrl } from '../../src/components/CreateSkillModal';
import CreateSkillModal, {
validateManifestUrl,
getSkillManifest,
} from '../../src/components/AddRemoteSkillModal/CreateSkillModal';
import { currentProjectIdState, settingsState } from '../../src/recoilModel';

jest.mock('../../src//utils/httpUtil');
Expand Down Expand Up @@ -50,13 +53,19 @@ describe('<SkillForm />', () => {
(httpClient.get as jest.Mock).mockResolvedValue({ endpoints: [] });

const onDismiss = jest.fn();
const onSubmit = jest.fn();
const { getByLabelText, getByText } = renderWithRecoil(
<CreateSkillModal projectId={projectId} onDismiss={onDismiss} onSubmit={onSubmit} />,
const addRemoteSkill = jest.fn();
const addTriggerToRoot = jest.fn();
const { getByLabelText } = renderWithRecoil(
<CreateSkillModal
addRemoteSkill={addRemoteSkill}
addTriggerToRoot={addTriggerToRoot}
projectId={projectId}
onDismiss={onDismiss}
/>,
recoilInitState
);

const urlInput = getByLabelText('Manifest URL');
const urlInput = getByLabelText('Skill Manifest Url');
act(() => {
fireEvent.change(urlInput, {
target: { value: 'https://onenote-dev.azurewebsites.net/manifests/OneNoteSync-2-1-preview-1-manifest.json' },
Expand All @@ -66,30 +75,20 @@ describe('<SkillForm />', () => {
expect(urlInput.getAttribute('value')).toBe(
'https://onenote-dev.azurewebsites.net/manifests/OneNoteSync-2-1-preview-1-manifest.json'
);

const submitButton = getByText('Confirm');
act(() => {
fireEvent.click(submitButton);
});
expect(onSubmit).not.toBeCalled();
} finally {
jest.runOnlyPendingTimers();
jest.useRealTimers();
}
});

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

beforeEach(() => {
formDataErrors = {};
validationState = {};
setFormDataErrors = jest.fn();
setSkillManifest = jest.fn();
setValidationState = jest.fn();
});

describe('validateManifestUrl', () => {
Expand All @@ -99,18 +98,13 @@ describe('<SkillForm />', () => {
await validateManifestUrl({
formData,
formDataErrors,
projectId,
setFormDataErrors,
setValidationState,
setSkillManifest,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({ manifestUrl: 'URL should start with http:// or https://' })
);
expect(setSkillManifest).not.toBeCalled();
expect(setValidationState).not.toBeCalled();
});
});

Expand All @@ -121,190 +115,43 @@ describe('<SkillForm />', () => {
validateManifestUrl({
formData,
formDataErrors,
projectId,
setFormDataErrors,
setValidationState,
setSkillManifest,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(expect.objectContaining({ manifestUrl: 'Please input a manifest URL' }));
});

it('should try and retrieve manifest if manifest URL meets other criteria', async () => {
it('should try and retrieve manifest', async () => {
(httpClient.get as jest.Mock) = jest.fn().mockResolvedValue({ data: 'skill manifest' });

const formData = { manifestUrl: 'https://skill' };
const formDataErrors = { manifestUrl: 'error' };
const manifestUrl = 'https://skill';

await validateManifestUrl({
formData,
formDataErrors,
projectId,
setFormDataErrors,
setValidationState,
setSkillManifest,
validationState,
});
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
manifestUrl: 'Validating',
})
);
await getSkillManifest(projectId, manifestUrl, setSkillManifest, setFormDataErrors);
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieveSkillManifest`, {
params: {
url: formData.manifestUrl,
url: manifestUrl,
},
});
expect(setSkillManifest).toBeCalledWith('skill manifest');
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
manifestUrl: 'Validated',
})
);
expect(setFormDataErrors).toBeCalledWith(
expect.not.objectContaining({
manifestUrl: 'error',
})
);
});

it('should show error when it could not retrieve skill manifest', async () => {
(httpClient.get as jest.Mock) = jest.fn().mockRejectedValue({ message: 'skill manifest' });

const formData = { manifestUrl: 'https://skill' };
const manifestUrl = 'https://skill';

await validateManifestUrl({
formData,
formDataErrors,
projectId,
setFormDataErrors,
setValidationState,
setSkillManifest,
validationState,
});
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
manifestUrl: 'Validating',
})
);
await getSkillManifest(projectId, manifestUrl, setSkillManifest, setFormDataErrors);
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieveSkillManifest`, {
params: {
url: formData.manifestUrl,
url: manifestUrl,
},
});
expect(setSkillManifest).not.toBeCalled();
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
manifestUrl: 'NotValidated',
})
);
expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({
manifestUrl: 'Manifest URL can not be accessed',
})
);
});
});

describe('validateEndpoint', () => {
it('should set an error for missing msAppId', () => {
const formData = { endpointUrl: 'https://skill/api/messages' };

validateEndpoint({
formData,
formDataErrors,
setFormDataErrors,
setValidationState,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({
endpoint: 'Please select a valid endpoint',
})
);
expect(setValidationState).not.toBeCalled();
});

it('should set an error for missing endpointUrl', () => {
const formData = { msAppId: '00000000-0000-0000-0000-000000000000' };

validateEndpoint({
formData,
formDataErrors,
setFormDataErrors,
setValidationState,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({
endpoint: 'Please select a valid endpoint',
})
);
expect(setValidationState).not.toBeCalled();
});

it('should set an error for malformed msAppId', () => {
const formData = { endpointUrl: 'https://skill/api/messages', msAppId: 'malformed app id' };

validateEndpoint({
formData,
formDataErrors,
setFormDataErrors,
setValidationState,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({
endpoint: 'Skill manifest endpoint is configured improperly',
})
);
expect(setValidationState).not.toBeCalled();
});

it('should set an error for malformed endpointUrl', () => {
const formData = { endpointUrl: 'malformed endpoint', msAppId: '00000000-0000-0000-0000-000000000000' };

validateEndpoint({
formData,
formDataErrors,
setFormDataErrors,
setValidationState,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.objectContaining({
endpoint: 'Skill manifest endpoint is configured improperly',
})
);
expect(setValidationState).not.toBeCalled();
});

it('should not set an error', () => {
const formData = { endpointUrl: 'https://skill/api/messages', msAppId: '00000000-0000-0000-0000-000000000000' };

validateEndpoint({
formData,
formDataErrors,
setFormDataErrors,
setValidationState,
validationState,
});

expect(setFormDataErrors).toBeCalledWith(
expect.not.objectContaining({
endpoint: expect.any(String),
})
);
expect(setValidationState).toBeCalledWith(
expect.objectContaining({
endpoint: 'Validated',
})
);
});
});
});
Loading