feat: add community publishing and news syndication
Validate and deploy production / validate (push) Successful in 23s
Validate and deploy staging / validate (push) Successful in 50s
Validate and deploy production / deploy (push) Failing after 40s
Validate and deploy staging / deploy (push) Failing after 7s

This commit is contained in:
jb
2026-08-01 21:42:09 -04:00
parent b47e2588e9
commit dd84dff055
288 changed files with 83254 additions and 38351 deletions
+112
View File
@@ -0,0 +1,112 @@
import { describe, expect, it } from 'vitest';
import { EMPTY_ARTICLE_DOCUMENT, parseArticleDocument } from './document';
describe('article documents', () => {
it('accepts formatted prose, multiple Builds, and article images', () => {
const parsed = parseArticleDocument({
version: 1,
document: {
type: 'doc',
content: [
{
type: 'heading',
attrs: { level: 2 },
content: [
{ type: 'text', text: 'Opening', marks: [{ type: 'bold' }] },
],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Use this rotation.',
marks: [
{ type: 'link', attrs: { href: 'https://shd.build/guides' } },
],
},
],
},
{
type: 'buildEmbed',
attrs: {
buildId: '11111111-1111-4111-8111-111111111111',
embedKey: 'build-11111111-1111-4111-8111-111111111111',
},
},
{
type: 'buildEmbed',
attrs: {
buildId: '22222222-2222-4222-8222-222222222222',
embedKey: 'build-22222222-2222-4222-8222-222222222222',
},
},
{
type: 'articleImage',
attrs: {
imageId: '33333333-3333-4333-8333-333333333333',
alt: 'A loadout screen',
caption: 'Final configuration',
},
},
],
},
});
expect(parsed?.buildEmbeds).toHaveLength(2);
expect(parsed?.imageIds).toEqual(['33333333-3333-4333-8333-333333333333']);
expect(parsed?.plainText).toContain('Opening Use this rotation.');
});
it('rejects unsafe links and unknown nodes', () => {
expect(
parseArticleDocument({
version: 1,
document: {
type: 'doc',
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'unsafe',
marks: [
{ type: 'link', attrs: { href: 'javascript:alert(1)' } },
],
},
],
},
],
},
}),
).toBeNull();
expect(
parseArticleDocument({
version: 1,
document: {
type: 'doc',
content: [{ type: 'iframe', attrs: { src: 'https://example.com' } }],
},
}),
).toBeNull();
});
it('rejects duplicate embed keys and unknown envelope fields', () => {
const embed = {
type: 'buildEmbed',
attrs: {
buildId: '11111111-1111-4111-8111-111111111111',
embedKey: 'build-11111111-1111-4111-8111-111111111111',
},
};
expect(
parseArticleDocument({
version: 1,
document: { type: 'doc', content: [embed, embed] },
}),
).toBeNull();
expect(
parseArticleDocument({ ...EMPTY_ARTICLE_DOCUMENT, legacy: true }),
).toBeNull();
});
});