Record published pages in conversation packages
This commit is contained in:
@@ -219,6 +219,74 @@ test('prepareHtmlPublishContent rewrites imgproxy local image urls to public sta
|
||||
assert.doesNotMatch(prepared, /plain\/local:\/\//);
|
||||
});
|
||||
|
||||
test('registerPublicationArtifactForConversation records public html artifact', async () => {
|
||||
const calls = [];
|
||||
const registry = {
|
||||
async ensurePackage(input) {
|
||||
calls.push(['ensurePackage', input]);
|
||||
return { id: 'cp_session-1' };
|
||||
},
|
||||
async recordArtifact(input) {
|
||||
calls.push(['recordArtifact', input]);
|
||||
return input;
|
||||
},
|
||||
async writeManifestForSession(input) {
|
||||
calls.push(['writeManifestForSession', input]);
|
||||
return { storageKey: 'users/user-1/conversations/session-1/manifest.json' };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await publicationInternals.registerPublicationArtifactForConversation({
|
||||
registry,
|
||||
userId: 'user-1',
|
||||
page: {
|
||||
page_id: 'page-1',
|
||||
title: '发布页',
|
||||
source_session_id: 'session-1',
|
||||
source_message_id: 'message-1',
|
||||
},
|
||||
publication: {
|
||||
id: 'pub-1',
|
||||
publicUrl: 'https://m.tkmind.cn/u/john/pages/published',
|
||||
publishedAt: 3000,
|
||||
},
|
||||
bundleAssetId: 'asset-pub',
|
||||
storageKey: 'users/user-1/publications/pub-1/index.html',
|
||||
htmlBytes: 256,
|
||||
now: 3000,
|
||||
});
|
||||
|
||||
assert.equal(result.id, 'ca_pub-1');
|
||||
assert.deepEqual(calls[0], [
|
||||
'ensurePackage',
|
||||
{
|
||||
userId: 'user-1',
|
||||
sessionId: 'session-1',
|
||||
title: '发布页',
|
||||
now: 3000,
|
||||
},
|
||||
]);
|
||||
assert.equal(calls[1][1].artifactKind, 'public_html');
|
||||
assert.equal(calls[1][1].publicationId, 'pub-1');
|
||||
assert.equal(calls[1][1].canonicalUrl, 'https://m.tkmind.cn/u/john/pages/published');
|
||||
assert.deepEqual(calls[2], [
|
||||
'writeManifestForSession',
|
||||
{ userId: 'user-1', sessionId: 'session-1' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('registerPublicationArtifactForConversation skips pages without source session', async () => {
|
||||
assert.equal(
|
||||
await publicationInternals.registerPublicationArtifactForConversation({
|
||||
registry: { ensurePackage: async () => assert.fail('should not be called') },
|
||||
userId: 'user-1',
|
||||
page: { page_id: 'page-1', title: '发布页' },
|
||||
publication: { id: 'pub-1' },
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('prepareHtmlPublishContent rewrites imgproxy urls in srcset and css url contexts', async () => {
|
||||
const prepared = await publicationInternals.prepareHtmlPublishContent({
|
||||
pool: {
|
||||
|
||||
Reference in New Issue
Block a user