Skip to content

Commit

Permalink
🐛 fix: fix function apiName length
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Dec 15, 2023
1 parent 799e03a commit ddf664a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/store/tool/slices/plugin/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,27 @@ describe('pluginSelectors', () => {
describe('enabledSchema', () => {
it('enabledSchema should return correct ChatCompletionFunctions array', () => {
const result = pluginSelectors.enabledSchema(['plugin-1'])(mockState);
expect(result).toEqual([{ name: 'plugin-1____api-1____default' }]);
expect(result).toEqual([{ name: 'plugin-1____api-1' }]);
});
it('enabledSchema should return with standalone plugin', () => {
const result = pluginSelectors.enabledSchema(['plugin-3'])({
...mockState,
installedPlugins: [
...mockState.installedPlugins,
{
identifier: 'plugin-3',
manifest: {
identifier: 'plugin-3',
api: [{ name: 'api-3' }],
type: 'standalone',
},
type: 'plugin',
},
],
} as ToolStoreState);
expect(result).toEqual([{ name: 'plugin-3____api-3____standalone' }]);
});

it('enabledSchema should return empty', () => {
const result = pluginSelectors.enabledSchema([])(mockState);
expect(result).toEqual([]);
Expand Down
3 changes: 2 additions & 1 deletion src/store/tool/slices/plugin/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const enabledSchema =
)
.flatMap((manifest) =>
manifest.api.map((m) => {
const pluginType = manifest.type ? `${PLUGIN_SCHEMA_SEPARATOR + manifest.type}` : '';
const pluginType =
manifest.type !== 'default' ? `${PLUGIN_SCHEMA_SEPARATOR + manifest.type}` : '';

// 将插件的 identifier 作为前缀,避免重复
let apiName = manifest.identifier + PLUGIN_SCHEMA_SEPARATOR + m.name + pluginType;
Expand Down

0 comments on commit ddf664a

Please sign in to comment.