Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/confluence-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,8 +1260,7 @@ class ConfluenceClient {
if (format === 'markdown') {
storageContent = this.markdownToStorage(content);
} else if (format === 'html') {
// Convert HTML directly to storage format (no macro wrapper)
storageContent = content;
storageContent = this.htmlToConfluenceStorage(content);
}

pageData.body = {
Expand Down Expand Up @@ -1299,8 +1298,7 @@ class ConfluenceClient {
if (format === 'markdown') {
storageContent = this.markdownToStorage(content);
} else if (format === 'html') {
// Convert HTML directly to storage format (no macro wrapper)
storageContent = content;
storageContent = this.htmlToConfluenceStorage(content);
}

pageData.body = {
Expand Down
28 changes: 28 additions & 0 deletions tests/confluence-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,34 @@ describe('ConfluenceClient', () => {
expect(requestData.body).toBeUndefined();
mock.restore();
});

test('createPage with format="html" routes through htmlToConfluenceStorage', async () => {
const mock = new MockAdapter(client.client);
mock.onPost('/content').reply(200, { id: '444' });
const spy = jest.spyOn(client, 'htmlToConfluenceStorage');

await client.createPage('T', 'TEST', '<p>x</p>', 'html');

expect(spy).toHaveBeenCalledWith('<p>x</p>');
const body = JSON.parse(mock.history.post[0].data).body.storage;
expect(body.representation).toBe('storage');
expect(body.value).toBe('<p>x</p>');

spy.mockRestore();
mock.restore();
});

test('createChildPage with format="html" routes through htmlToConfluenceStorage', async () => {
const mock = new MockAdapter(client.client);
mock.onPost('/content').reply(200, { id: '555' });
const spy = jest.spyOn(client, 'htmlToConfluenceStorage');

await client.createChildPage('T', 'TEST', '100', '<p>x</p>', 'html');

expect(spy).toHaveBeenCalledWith('<p>x</p>');
spy.mockRestore();
mock.restore();
});
});

describe('deletePage', () => {
Expand Down