Files
memind/mindspace-workspace-page-deliver.test.mjs
T

45 lines
1.4 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createWorkspacePageDeliverService } from './mindspace-workspace-page-deliver.mjs';
test('ensureWorkspaceHtmlPublications publishes auto-synced workspace html pages', async () => {
const published = [];
const service = createWorkspacePageDeliverService({
pool: {
async query() {
return [[{
page_id: 'page-1',
title: '隔离验证页',
current_version_id: 'ver-1',
workspace_relative_path: 'public/demo.html',
source_snapshot_json: JSON.stringify({
auto_synced: true,
relative_path: 'public/demo.html',
content_mode: 'static_html',
}),
}]];
},
},
pageService: {
async getPage() {
return { id: 'page-1', title: '隔离验证页', currentVersionId: 'ver-1' };
},
},
publicationService: {
async getCurrent() {
return null;
},
async publish(userId, pageId, input) {
published.push({ userId, pageId, input });
return { id: 'pub-1', publicUrl: 'http://127.0.0.1:9181/u/john/pages/page-demo' };
},
},
});
const result = await service.ensureWorkspaceHtmlPublications('user-1');
assert.equal(result.published, 1);
assert.equal(published.length, 1);
assert.equal(published[0].input.accessMode, 'public');
assert.equal(published[0].input.autoAcknowledgeFindings, true);
});