fix(extensions): avoid premature skill import folder defaults

This commit is contained in:
777genius 2026-04-16 23:09:15 +03:00
parent 86bc4ce4e8
commit 2142518461
2 changed files with 31 additions and 1 deletions

View file

@ -97,7 +97,7 @@ export const SkillImportDialog = ({
if (!open || folderNameEdited) {
return;
}
setFolderName(getSuggestedSkillFolderNameFromPath(sourceDir));
setFolderName(sourceDir.trim() ? getSuggestedSkillFolderNameFromPath(sourceDir) : '');
}, [folderNameEdited, open, sourceDir]);
useEffect(() => {

View file

@ -120,6 +120,36 @@ describe('SkillImportDialog', () => {
vi.unstubAllGlobals();
});
it('keeps destination folder empty until a source folder is chosen', async () => {
const host = document.createElement('div');
document.body.appendChild(host);
const root = createRoot(host);
await act(async () => {
root.render(
React.createElement(SkillImportDialog, {
open: true,
projectPath: null,
projectLabel: null,
onClose: vi.fn(),
onImported: vi.fn(),
})
);
await Promise.resolve();
});
const sourceInput = host.querySelector('#skill-import-source') as HTMLInputElement;
const folderInput = host.querySelector('#skill-import-folder') as HTMLInputElement;
expect(sourceInput.value).toBe('');
expect(folderInput.value).toBe('');
await act(async () => {
root.unmount();
await Promise.resolve();
});
});
it('keeps destination folder name synced with the chosen source until edited manually', async () => {
const host = document.createElement('div');
document.body.appendChild(host);