2025-10-07 14:29:36 +00:00
|
|
|
import { expect, tap } from '@push.rocks/tapbundle';
|
|
|
|
import * as qenv from '@push.rocks/qenv';
|
|
|
|
const testQenv = new qenv.Qenv('./', './.nogit/');
|
|
|
|
|
|
|
|
import * as ghost from '../ts/index.js';
|
|
|
|
|
|
|
|
let testGhostInstance: ghost.Ghost;
|
|
|
|
let createdWebhook: any;
|
|
|
|
|
|
|
|
tap.test('initialize Ghost instance', async () => {
|
|
|
|
testGhostInstance = new ghost.Ghost({
|
|
|
|
baseUrl: 'http://localhost:2368',
|
|
|
|
adminApiKey: await testQenv.getEnvVarOnDemand('ADMIN_APIKEY'),
|
|
|
|
contentApiKey: await testQenv.getEnvVarOnDemand('CONTENT_APIKEY'),
|
|
|
|
});
|
|
|
|
expect(testGhostInstance).toBeInstanceOf(ghost.Ghost);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should create webhook', async () => {
|
2025-10-08 09:14:45 +00:00
|
|
|
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();
|
2025-10-07 14:29:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should update webhook', async () => {
|
2025-10-08 09:14:45 +00:00
|
|
|
const updatedWebhook = await testGhostInstance.updateWebhook(createdWebhook.id, {
|
|
|
|
target_url: 'https://example.com/webhook/updated'
|
|
|
|
});
|
|
|
|
expect(updatedWebhook).toBeTruthy();
|
2025-10-07 14:29:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should delete webhook', async () => {
|
2025-10-08 09:14:45 +00:00
|
|
|
await testGhostInstance.deleteWebhook(createdWebhook.id);
|
2025-10-07 14:29:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export default tap.start();
|