1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Chore: Sync fuzzer: Add actions for publishing and unpublishing notes (#13062)

This commit is contained in:
Henry Heino
2025-09-08 04:02:53 -07:00
committed by GitHub
parent 1f0a98999f
commit 88f687ba6a
4 changed files with 82 additions and 1 deletions

View File

@@ -580,6 +580,31 @@ class Client implements ActionableClient {
await this.execCliCommand_('share', 'delete', '-f', id);
}
public async publishNote(id: ItemId) {
await this.tracker_.publishNote(id);
logger.info('Publish note', id, 'in', this.label);
const publishOutput = await this.execCliCommand_('publish', '-f', id);
const publishUrl = publishOutput.stdout.match(/http[s]?:\/\/\S+/);
assert.notEqual(publishUrl, null, 'should log the publication URL');
logger.info('Testing publication URL: ', publishUrl[0]);
const fetchResult = await fetch(publishUrl[0]);
if (!fetchResult.ok) {
logger.warn('Fetch failed', fetchResult.statusText);
}
assert.equal(fetchResult.status, 200, `should be able to fetch the published note (status: ${fetchResult.statusText}).`);
}
public async unpublishNote(id: ItemId) {
await this.tracker_.publishNote(id);
logger.info('Unpublish note', id, 'in', this.label);
await this.execCliCommand_('unpublish', id);
}
public async moveItem(itemId: ItemId, newParentId: ItemId) {
logger.info('Move', itemId, 'to', newParentId);
await this.tracker_.moveItem(itemId, newParentId);
@@ -589,7 +614,7 @@ class Client implements ActionableClient {
public async listNotes() {
const params = {
fields: 'id,parent_id,body,title,is_conflict,conflict_original_id,share_id',
fields: 'id,parent_id,body,title,is_conflict,conflict_original_id,share_id,is_shared',
include_deleted: '1',
include_conflicts: '1',
};
@@ -605,6 +630,7 @@ class Client implements ActionableClient {
title: getStringProperty(item, 'title'),
body: getStringProperty(item, 'body'),
isShared: getStringProperty(item, 'share_id') !== '',
published: getNumberProperty(item, 'is_shared') === 1,
}),
);
}