1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Chore: Sync fuzzer: Add action for deleting notes (#13083)

This commit is contained in:
Henry Heino
2025-08-29 14:28:00 -07:00
committed by GitHub
parent 78fb07d4c7
commit 650594ecea
4 changed files with 28 additions and 0 deletions

View File

@@ -351,6 +351,19 @@ class ActionTracker {
this.checkRep_();
return Promise.resolve();
},
deleteNote: (id: ItemId) => {
this.checkRep_();
const item = this.idToItem_.get(id);
if (!item) throw new Error(`Not found ${id}`);
assert.ok(!isFolder(item), 'should be a note');
assertWriteable(item);
removeItemRecursive(id);
this.checkRep_();
return Promise.resolve();
},
shareFolder: (id: ItemId, shareWith: ClientInfo, options: ShareOptions) => {
const itemToShare = this.idToItem_.get(id);
assertIsFolder(itemToShare);

View File

@@ -504,6 +504,13 @@ class Client implements ActionableClient {
await this.assertNoteMatchesState_(note);
}
public async deleteNote(id: ItemId) {
logger.info('Delete note', id, 'in', this.label);
await this.tracker_.deleteNote(id);
await this.execCliCommand_('rmnote', '--permanent', '--force', id);
}
public async deleteFolder(id: string) {
logger.info('Delete folder', id, 'in', this.label);
await this.tracker_.deleteFolder(id);

View File

@@ -144,6 +144,13 @@ const doRandomAction = async (context: FuzzContext, client: Client, clientPool:
return true;
},
deleteNote: async () => {
const target = await client.randomNote({ includeReadOnly: false });
if (!target) return false;
await client.deleteNote(target.id);
return true;
},
shareFolder: async () => {
const other = clientPool.randomClient(c => !c.hasSameAccount(client));
if (!other) return false;

View File

@@ -69,6 +69,7 @@ export interface ActionableClient {
removeFromShare(id: string, shareWith: Client): Promise<void>;
deleteAssociatedShare(id: string): Promise<void>;
deleteFolder(id: ItemId): Promise<void>;
deleteNote(id: ItemId): Promise<void>;
createNote(data: NoteData): Promise<void>;
updateNote(data: NoteData): Promise<void>;
moveItem(itemId: ItemId, newParentId: ItemId): Promise<void>;