feat: expose permanent trash deletion in sdk
This commit is contained in:
@@ -35,6 +35,7 @@ describe('VerstakPluginAPI contract', () => {
|
||||
expect(typeof api.files.trash).toBe('function');
|
||||
expect(typeof api.files.listTrash).toBe('function');
|
||||
expect(typeof api.files.restoreTrash).toBe('function');
|
||||
expect(typeof api.files.deleteTrash).toBe('function');
|
||||
expect(typeof api.files.openExternal).toBe('function');
|
||||
expect(typeof api.files.showInFolder).toBe('function');
|
||||
expect(typeof api.workbench.openResource).toBe('function');
|
||||
@@ -359,6 +360,11 @@ describe('VerstakPluginAPI contract', () => {
|
||||
expect.objectContaining({ relativePath: 'PlatformTest/image.bin', type: 'file' }),
|
||||
]));
|
||||
await expect(api.files.listTrash()).resolves.toEqual([]);
|
||||
|
||||
const permanentlyDeleted = await api.files.trash('PlatformTest/two.txt');
|
||||
await expect(api.files.deleteTrash(permanentlyDeleted.trashId)).resolves.toBeUndefined();
|
||||
await expect(api.files.listTrash()).resolves.toEqual([]);
|
||||
await expect(api.files.readText('PlatformTest/two.txt')).rejects.toThrow('not-found: PlatformTest/two.txt');
|
||||
});
|
||||
|
||||
test('files mock rejects non-canonical and reserved paths', async () => {
|
||||
|
||||
@@ -157,6 +157,7 @@ export interface VerstakPluginAPI {
|
||||
trash(relativePath: string): Promise<TrashResult>;
|
||||
listTrash(): Promise<TrashEntry[]>;
|
||||
restoreTrash(trashId: string, options?: RestoreTrashOptions): Promise<string>;
|
||||
deleteTrash(trashId: string): Promise<void>;
|
||||
openExternal(relativePath: string): Promise<void>;
|
||||
showInFolder(relativePath: string): Promise<void>;
|
||||
};
|
||||
|
||||
@@ -348,6 +348,12 @@ export function createMockPluginAPI(pluginId = 'test.plugin', options: MockPlugi
|
||||
if (index >= 0) trashEntries.splice(index, 1);
|
||||
return target;
|
||||
}),
|
||||
deleteTrash: vi.fn(async (trashId: string) => {
|
||||
const index = trashEntries.findIndex((item) => item.trashId === trashId);
|
||||
if (index < 0) throw new Error(`not-found: trash entry ${trashId}`);
|
||||
trashEntries.splice(index, 1);
|
||||
trashPayloads.delete(trashId);
|
||||
}),
|
||||
openExternal: vi.fn(async (relativePath: string) => {
|
||||
const path = normalizePath(relativePath);
|
||||
if (!files.has(path)) throw new Error(`not-found: ${path}`);
|
||||
|
||||
Reference in New Issue
Block a user