BREAKING CHANGE(classes.ghost): Remove Settings and Webhooks browse/read APIs, remove noisy console.error logs, and update tests/docs
This commit is contained in:
@@ -16,91 +16,26 @@ tap.test('initialize Ghost instance', async () => {
|
||||
expect(testGhostInstance).toBeInstanceOf(ghost.Ghost);
|
||||
});
|
||||
|
||||
tap.test('should get all webhooks', async () => {
|
||||
try {
|
||||
const webhooks = await testGhostInstance.getWebhooks();
|
||||
expect(webhooks).toBeArray();
|
||||
console.log(`Found ${webhooks.length} webhooks`);
|
||||
if (webhooks.length > 0) {
|
||||
console.log(`First webhook: ${webhooks[0].name || 'unnamed'}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.message?.includes('not a function') || error.statusCode === 403) {
|
||||
console.log('Webhooks API not available in this Ghost version - skipping test');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should create webhook', async () => {
|
||||
try {
|
||||
const timestamp = Date.now();
|
||||
createdWebhook = await testGhostInstance.createWebhook({
|
||||
event: 'post.published',
|
||||
target_url: `https://example.com/webhook/${timestamp}`,
|
||||
name: `Test Webhook ${timestamp}`
|
||||
});
|
||||
expect(createdWebhook).toBeTruthy();
|
||||
expect(createdWebhook.id).toBeTruthy();
|
||||
console.log(`Created webhook: ${createdWebhook.id}`);
|
||||
} catch (error: any) {
|
||||
if (error.message?.includes('not a function') || error.statusCode === 403) {
|
||||
console.log('Webhooks API not available - skipping test');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should get webhook by ID', async () => {
|
||||
if (createdWebhook) {
|
||||
try {
|
||||
const webhook = await testGhostInstance.getWebhookById(createdWebhook.id);
|
||||
expect(webhook).toBeTruthy();
|
||||
expect(webhook.id).toEqual(createdWebhook.id);
|
||||
console.log(`Got webhook by ID: ${webhook.id}`);
|
||||
} catch (error: any) {
|
||||
if (error.message?.includes('not a function') || error.statusCode === 403) {
|
||||
console.log('Webhooks API not available - skipping test');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
const timestamp = Date.now();
|
||||
createdWebhook = await testGhostInstance.createWebhook({
|
||||
event: 'post.published',
|
||||
target_url: `https://example.com/webhook/${timestamp}`,
|
||||
name: `Test Webhook ${timestamp}`
|
||||
});
|
||||
expect(createdWebhook).toBeTruthy();
|
||||
expect(createdWebhook.id).toBeTruthy();
|
||||
});
|
||||
|
||||
tap.test('should update webhook', async () => {
|
||||
if (createdWebhook) {
|
||||
try {
|
||||
const updatedWebhook = await testGhostInstance.updateWebhook(createdWebhook.id, {
|
||||
target_url: 'https://example.com/webhook/updated'
|
||||
});
|
||||
expect(updatedWebhook).toBeTruthy();
|
||||
console.log(`Updated webhook: ${updatedWebhook.id}`);
|
||||
} catch (error: any) {
|
||||
if (error.message?.includes('not a function') || error.statusCode === 403) {
|
||||
console.log('Webhooks API not available - skipping test');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
const updatedWebhook = await testGhostInstance.updateWebhook(createdWebhook.id, {
|
||||
target_url: 'https://example.com/webhook/updated'
|
||||
});
|
||||
expect(updatedWebhook).toBeTruthy();
|
||||
});
|
||||
|
||||
tap.test('should delete webhook', async () => {
|
||||
if (createdWebhook) {
|
||||
try {
|
||||
await testGhostInstance.deleteWebhook(createdWebhook.id);
|
||||
console.log(`Deleted webhook: ${createdWebhook.id}`);
|
||||
} catch (error: any) {
|
||||
if (error.message?.includes('not a function') || error.statusCode === 403) {
|
||||
console.log('Webhooks API not available - skipping test');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
await testGhostInstance.deleteWebhook(createdWebhook.id);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
|
Reference in New Issue
Block a user