fix(extensions): avoid premature skill import folder defaults
This commit is contained in:
parent
86bc4ce4e8
commit
2142518461
2 changed files with 31 additions and 1 deletions
|
|
@ -97,7 +97,7 @@ export const SkillImportDialog = ({
|
||||||
if (!open || folderNameEdited) {
|
if (!open || folderNameEdited) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setFolderName(getSuggestedSkillFolderNameFromPath(sourceDir));
|
setFolderName(sourceDir.trim() ? getSuggestedSkillFolderNameFromPath(sourceDir) : '');
|
||||||
}, [folderNameEdited, open, sourceDir]);
|
}, [folderNameEdited, open, sourceDir]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,36 @@ describe('SkillImportDialog', () => {
|
||||||
vi.unstubAllGlobals();
|
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 () => {
|
it('keeps destination folder name synced with the chosen source until edited manually', async () => {
|
||||||
const host = document.createElement('div');
|
const host = document.createElement('div');
|
||||||
document.body.appendChild(host);
|
document.body.appendChild(host);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue