Skip to content

Commit

Permalink
use {botName}-manifest as name
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlong9278 committed Jul 20, 2021
1 parent 3c9322d commit fced4e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,9 @@

import { getManifestId } from '../content';

const skillManifest = {
id: 'test',
content: {
$schema: 'https://schemas.botframework.com/schemas/skills/skill-manifest-2.1.1.json',
version: '2.1.1',
},
};

describe('geManifestId', () => {
it('should generate valid id without manifest schema version', () => {
const result = getManifestId('test', [], {});
const result = getManifestId('test');
expect(result).toEqual('test-manifest');
});

it('should generate valid, non-conflicting id without manifest schema version', () => {
const skillManifests: any = [{ id: 'test-manifest' }, { id: 'test-manifest-0' }];
const result = getManifestId('test', skillManifests, {});
expect(result).toEqual('test-manifest-1');
});

it('should generate valid id with manifest schema version', () => {
const result = getManifestId('test', [], skillManifest);
expect(result).toEqual('test-2-1-1-manifest');
});

it('should generate valid, non-conflicting id with manifest schema version', () => {
const skillManifests: any = [{ id: 'test-2-1-1-manifest' }, { id: 'test-2-1-1-manifest-0' }];
const result = getManifestId('test', skillManifests, skillManifest);
expect(result).toEqual('test-2-1-1-manifest-1');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,8 @@ const onRenderInvalidProfileWarning = (hasValidProfile, handleShowPublishProfile
);
};

export const getManifestId = (
botName: string,
skillManifests: SkillManifestFile[],
{ content: { version } = '' }: Partial<SkillManifestFile>
): string => {
let fileId = version ? `${botName}-${version.replace(/\./g, '-')}-manifest` : `${botName}-manifest`;
let i = -1;

while (skillManifests.some(({ id }) => id === fileId) && i < skillManifests.length) {
if (i < 0) {
fileId = fileId.concat(`-${++i}`);
} else {
fileId = fileId.substr(0, fileId.lastIndexOf('-')).concat(`-${++i}`);
}
}

return fileId;
export const getManifestId = (botName: string): string => {
return `${botName}-manifest`;
};

const onRenderTitle = (options: IDropdownOption[] | undefined): JSX.Element | null => {
Expand Down Expand Up @@ -217,7 +202,7 @@ export const SelectProfile: React.FC<ContentProps> = ({
}, [settings]);

useEffect(() => {
const fileId = getManifestId(botName, skillManifests, manifest);
const fileId = getManifestId(botName);
setSkillManifest({ ...manifest, id: fileId });
}, [id]);

Expand Down

0 comments on commit fced4e5

Please sign in to comment.