clone of repo on github
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

4178 lines
164 KiB

> alexandria@0.0.2 test
> vitest
DEV v3.2.4 /home/madmin/Projects/GitCitadel/gc-alexandria
✓ tests/unit/ZettelEditor.test.ts (24 tests) 20ms
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Addressable Event Deduplication > should keep only the most recent version of addressable events by coordinate
[eventDeduplication] Found 1 duplicate events out of 3 total events
[eventDeduplication] Reduced to 2 unique coordinates
[eventDeduplication] Duplicate details: [
{
coordinate: '30041:pubkey1:chapter-1',
count: 2,
events: [ 'event1 (created_at: 1000)', 'event2 (created_at: 2000)' ]
}
]
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Addressable Event Deduplication > should handle events with missing d-tags gracefully
[eventDeduplication] No duplicates found in 1 events
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Addressable Event Deduplication > should handle events with missing timestamps
[eventDeduplication] Found 1 duplicate events out of 2 total events
[eventDeduplication] Reduced to 1 unique coordinates
[eventDeduplication] Duplicate details: [
{
coordinate: '30041:pubkey1:chapter-3',
count: 2,
events: [ 'event7 (created_at: 0)', 'event8 (created_at: 1500)' ]
}
]
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Mixed Event Type Deduplication > should only deduplicate addressable events (kinds 30000-39999)
[eventDeduplication] deduplicateAndCombineEvents: Found 1 duplicate coordinates out of 4 replaceable events
[eventDeduplication] deduplicateAndCombineEvents: Reduced from 5 to 4 events (1 removed)
[eventDeduplication] deduplicateAndCombineEvents: Duplicate details: [
{
coordinate: '30041:pubkey1:chapter-1',
count: 2,
events: [ 'event1 (created_at: 1000)', 'event2 (created_at: 2000)' ]
}
]
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Edge Cases > should handle events with null/undefined values
[eventDeduplication] No duplicates found in 1 events
stdout | tests/unit/relayDeduplication.test.ts > Relay Deduplication Behavior Tests > Edge Cases > should handle events from different authors with same d-tag
[eventDeduplication] No duplicates found in 2 events
stdout | tests/unit/relayDeduplication.test.ts > Relay Behavior Simulation > should simulate what happens when relays return duplicate events
[eventDeduplication] Found 2 duplicate events out of 3 total events
[eventDeduplication] Reduced to 1 unique coordinates
[eventDeduplication] Duplicate details: [
{
coordinate: '30041:pubkey1:chapter-1',
count: 3,
events: [
'event1 (created_at: 1000)',
'event2 (created_at: 2000)',
'event3 (created_at: 1500)'
]
}
]
stdout | tests/unit/relayDeduplication.test.ts > Relay Behavior Simulation > should simulate multiple relays returning different versions
[eventDeduplication] Found 1 duplicate events out of 2 total events
[eventDeduplication] Reduced to 1 unique coordinates
[eventDeduplication] Duplicate details: [
{
coordinate: '30041:pubkey1:chapter-1',
count: 2,
events: [ 'event1 (created_at: 1000)', 'event2 (created_at: 2000)' ]
}
]
stdout | tests/unit/relayDeduplication.test.ts > Real Relay Deduplication Tests > should detect if relays are returning duplicate replaceable events
Note: This test would require actual relay queries to verify deduplication behavior
To run this test properly, we would need to:
1. Query real relays for replaceable events
2. Check if relays return duplicates
3. Verify our deduplication logic works on real data
stdout | tests/unit/relayDeduplication.test.ts > Real Relay Deduplication Tests > should verify that our deduplication logic works on real relay data
Note: This test would require actual relay queries
To implement this test, we would need to:
1. Set up NDK with real relays
2. Fetch events for a known author with multiple versions
3. Apply deduplication and verify results
stdout | tests/unit/relayDeduplication.test.ts > Practical Relay Behavior Analysis > should document what we know about relay deduplication behavior
=== RELAY DEDUPLICATION BEHAVIOR ANALYSIS ===
Based on the code analysis and the comment from onedev:
1. THEORETICAL BEHAVIOR:
- Relays SHOULD handle deduplication for replaceable events
- Only the most recent version of each coordinate should be stored
- Client-side deduplication should only be needed for cached/local events
2. REALITY CHECK:
- Not all relays implement deduplication correctly
- Some relays may return multiple versions of the same event
- Network conditions and relay availability can cause inconsistencies
3. ALEXANDRIA'S APPROACH:
- Implements client-side deduplication as a safety net
- Uses coordinate system (kind:pubkey:d-tag) for addressable events
- Keeps the most recent version based on created_at timestamp
- Only applies to replaceable events (kinds 30000-39999)
4. WHY KEEP THE DEDUPLICATION:
- Defensive programming against imperfect relay implementations
- Handles multiple relay sources with different data
- Works with cached events that might be outdated
- Ensures consistent user experience regardless of relay behavior
5. TESTING STRATEGY:
- Unit tests verify our deduplication logic works correctly
- Integration tests would verify relay behavior (when network allows)
- Monitoring can help determine if relays improve over time
stdout | tests/unit/relayDeduplication.test.ts > Practical Relay Behavior Analysis > should provide recommendations for when to remove deduplication
=== RECOMMENDATIONS FOR REMOVING DEDUPLICATION ===
The deduplication logic should be kept until:
1. RELAY STANDARDS:
- NIP-33 (replaceable events) is widely implemented by relays
- Relays consistently return only the most recent version
- No major relay implementations return duplicates
2. TESTING EVIDENCE:
- Real-world testing shows relays don't return duplicates
- Multiple relay operators confirm deduplication behavior
- No user reports of duplicate content issues
3. MONITORING:
- Add logging to track when deduplication is actually used
- Monitor relay behavior over time
- Collect metrics on duplicate events found
4. GRADUAL REMOVAL:
- Make deduplication configurable (on/off)
- Test with deduplication disabled in controlled environments
- Monitor for issues before removing completely
5. FALLBACK STRATEGY:
- Keep deduplication as a fallback option
- Allow users to enable it if they experience issues
- Maintain the code for potential future use
✓ tests/unit/relayDeduplication.test.ts (22 tests) 22ms
✓ tests/unit/nostr_identifiers.test.ts (12 tests) 9ms
✓ tests/unit/tagExpansion.test.ts (12 tests) 23ms
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure with Preamble > should build 30040 event set with preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document with Preamble',
authors: [ 'John Doe', 'Section Author' ],
version: '1.0',
publicationDate: '2024-01-15, Alexandria Test',
summary: 'This is a test document with preamble',
tags: [ 'test', 'preamble', 'asciidoc' ]
},
content: '= Test Document with Preamble\n' +
'John Doe <john@example.com>\n' +
'1.0, 2024-01-15, Alexandria Test\n' +
':summary: This is a test document with preamble\n' +
':keywords: test, preamble, asciidoc\n' +
'\n' +
'This is the preamble content that should be included.\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document with Preamble',
indexDTag: 'test-document-with-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-with-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-with-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document with Preamble' ],
[ 'author', 'John Doe' ],
[ 'author', 'Section Author' ],
[ 'version', '1.0' ],
[ 'published_on', '2024-01-15, Alexandria Test' ],
[ 'summary', 'This is a test document with preamble' ],
[ 't', 'test' ],
[ 't', 'preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-with-preamble' ],
[ 'title', 'Test Document with Preamble' ],
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure without Preamble > should build 30040 event set without preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document without Preamble',
authors: [ 'Section Author' ],
version: 'Version',
summary: 'This is a test document without preamble',
tags: [ 'test', 'no-preamble', 'asciidoc' ]
},
content: '= Test Document without Preamble\n' +
':summary: This is a test document without preamble\n' +
':keywords: test, no-preamble, asciidoc\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document without Preamble',
indexDTag: 'test-document-without-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-without-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-without-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document without Preamble' ],
[ 'author', 'Section Author' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a test document without preamble' ],
[ 't', 'test' ],
[ 't', 'no-preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-without-preamble' ],
[ 'title', 'Test Document without Preamble' ],
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
❯ tests/unit/metadataExtraction.test.ts (16 tests | 2 failed) 231ms
× AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly 124ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract section metadata correctly 8ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract standalone author names and remove them from content 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should handle multiple standalone author names 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should not extract non-author lines as authors 4ms
✓ AsciiDoc Metadata Extraction > parseAsciiDocWithMetadata should parse complete document 23ms
✓ AsciiDoc Metadata Extraction > metadataToTags should convert metadata to Nostr tags 2ms
✓ AsciiDoc Metadata Extraction > should handle index card format correctly 4ms
✓ AsciiDoc Metadata Extraction > should handle empty content gracefully 4ms
✓ AsciiDoc Metadata Extraction > should handle keywords as tags 4ms
✓ AsciiDoc Metadata Extraction > should handle both tags and keywords 5ms
✓ AsciiDoc Metadata Extraction > should handle tags only 8ms
✓ AsciiDoc Metadata Extraction > should handle both summary and description 15ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle section-only content correctly 8ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle minimal document header (just title) correctly 1ms
× AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly 7ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure with Preamble > should build 30040 event set with skeleton structure and preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document with Preamble',
version: 'Version',
summary: 'This is a skeleton document with preamble',
tags: [ 'skeleton', 'preamble', 'empty' ]
},
content: '= Skeleton Document with Preamble\n' +
':summary: This is a skeleton document with preamble\n' +
':keywords: skeleton, preamble, empty\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document with Preamble',
indexDTag: 'skeleton-document-with-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-with-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-with-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-with-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document with Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document with preamble' ],
[ 't', 'skeleton' ],
[ 't', 'preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-with-preamble' ],
[ 'title', 'Skeleton Document with Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure without Preamble > should build 30040 event set with skeleton structure without preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document without Preamble',
version: 'Version',
summary: 'This is a skeleton document without preamble',
tags: [ 'skeleton', 'no-preamble', 'empty' ]
},
content: '= Skeleton Document without Preamble\n' +
':summary: This is a skeleton document without preamble\n' +
':keywords: skeleton, no-preamble, empty\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document without Preamble',
indexDTag: 'skeleton-document-without-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-without-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-without-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-without-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document without Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document without preamble' ],
[ 't', 'skeleton' ],
[ 't', 'no-preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-without-preamble' ],
[ 'title', 'Skeleton Document without Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card format
Parsed AsciiDoc: {
metadata: { title: 'Test Index Card', version: 'Version' },
content: '= Test Index Card\nindex card',
sections: []
}
Creating index card format (no sections)
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card with metadata
Parsed AsciiDoc: {
metadata: {
title: 'Test Index Card with Metadata',
version: 'Version',
summary: 'This is an index card with metadata',
tags: [ 'index', 'card', 'metadata' ]
},
content: '= Test Index Card with Metadata\n' +
':summary: This is an index card with metadata\n' +
':keywords: index, card, metadata\n' +
'index card',
sections: []
}
Index event: {
documentTitle: 'Test Index Card with Metadata',
indexDTag: 'test-index-card-with-metadata'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'index-card' ],
[ 'title', 'Test Index Card with Metadata' ],
[ 'version', 'Version' ],
[ 'summary', 'This is an index card with metadata' ],
[ 't', 'index' ],
[ 't', 'card' ],
[ 't', 'metadata' ],
[ 'd', 'test-index-card-with-metadata' ],
[ 'title', 'Test Index Card with Metadata' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Complex Metadata Structures > should handle complex metadata with all attribute types
Parsed AsciiDoc: {
metadata: {
title: 'Complex Metadata Document',
authors: [
'Jane Smith',
'Override Author',
'Third Author',
'Section Author',
'Section Co-Author'
],
version: '2.0',
publicationDate: '2024-03-01',
summary: 'This is a complex document with all metadata types Alternative description field',
publishedBy: 'Alexandria Complex',
type: 'book',
coverImage: 'https://example.com/cover.jpg',
isbn: '978-0-123456-78-9',
source: 'https://github.com/alexandria/complex',
autoUpdate: 'yes',
tags: [
'additional',
'tags',
'here',
'complex',
'metadata',
'all-types'
]
},
content: '= Complex Metadata Document\n' +
'Jane Smith <jane@example.com>\n' +
'2.0, 2024-02-20, Alexandria Complex\n' +
':summary: This is a complex document with all metadata types\n' +
':description: Alternative description field\n' +
':keywords: complex, metadata, all-types\n' +
':tags: additional, tags, here\n' +
':author: Override Author\n' +
':author: Third Author\n' +
':version: 3.0\n' +
':published_on: 2024-03-01\n' +
':published_by: Alexandria Complex\n' +
':type: book\n' +
':image: https://example.com/cover.jpg\n' +
':isbn: 978-0-123456-78-9\n' +
':source: https://github.com/alexandria/complex\n' +
':auto-update: yes\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Section with Complex Metadata\n' +
':author: Section Author\n' +
':author: Section Co-Author\n' +
':summary: This section has complex metadata\n' +
':description: Alternative description for section\n' +
':keywords: section, complex, metadata\n' +
':tags: section, tags\n' +
':type: chapter\n' +
':image: https://example.com/section-image.jpg\n' +
'\n' +
'This is the section content.',
sections: [
{
metadata: [Object],
content: 'This is the section content.',
title: 'Section with Complex Metadata'
}
]
}
Index event: {
documentTitle: 'Complex Metadata Document',
indexDTag: 'complex-metadata-document'
}
Creating section 0: {
title: 'Section with Complex Metadata',
dTag: 'complex-metadata-document-section-with-complex-metadata',
content: 'This is the section content.',
metadata: {
title: 'Section with Complex Metadata',
authors: [ 'Section Author', 'Section Co-Author' ],
summary: 'This section has complex metadata Alternative description for section',
type: 'chapter',
coverImage: 'https://example.com/section-image.jpg',
tags: [ 'section', 'tags', 'complex', 'metadata' ]
}
}
A tags: [
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'complex' ],
[ 'title', 'Complex Metadata Document' ],
[ 'author', 'Jane Smith' ],
[ 'author', 'Override Author' ],
[ 'author', 'Third Author' ],
[ 'author', 'Section Author' ],
[ 'author', 'Section Co-Author' ],
[ 'version', '2.0' ],
[ 'published_on', '2024-03-01' ],
[ 'published_by', 'Alexandria Complex' ],
[
'summary',
'This is a complex document with all metadata types Alternative description field'
],
[ 'image', 'https://example.com/cover.jpg' ],
[ 'i', '978-0-123456-78-9' ],
[ 'source', 'https://github.com/alexandria/complex' ],
[ 'type', 'book' ],
[ 'auto-update', 'yes' ],
[ 't', 'additional' ],
[ 't', 'tags' ],
[ 't', 'here' ],
[ 't', 'complex' ],
[ 't', 'metadata' ],
[ 't', 'all-types' ],
[ 'd', 'complex-metadata-document' ],
[ 'title', 'Complex Metadata Document' ],
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with only title and no sections
Parsed AsciiDoc: {
metadata: {
title: 'Document with No Sections',
version: 'Version',
summary: 'This document has no sections'
},
content: '= Document with No Sections\n' +
':summary: This document has no sections\n' +
'\n' +
'This is just preamble content.',
sections: []
}
Index event: {
documentTitle: 'Document with No Sections',
indexDTag: 'document-with-no-sections'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with No Sections' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has no sections' ],
[ 'd', 'document-with-no-sections' ],
[ 'title', 'Document with No Sections' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with special characters in title
Parsed AsciiDoc: {
metadata: {
title: 'Document with Special Characters: Test & More!',
version: 'Version',
summary: 'This document has special characters in the title'
},
content: '= Document with Special Characters: Test & More!\n' +
':summary: This document has special characters in the title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'Document with Special Characters: Test & More!',
indexDTag: 'document-with-special-characters-test-more'
}
Creating section 0: {
title: 'Section 1',
dTag: 'document-with-special-characters-test-more-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with Special Characters: Test & More!' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has special characters in the title' ],
[ 'd', 'document-with-special-characters-test-more' ],
[ 'title', 'Document with Special Characters: Test & More!' ],
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with very long title
Parsed AsciiDoc: {
metadata: {
title: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
version: 'Version',
summary: 'This document has a very long title'
},
content: '= This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality\n' +
':summary: This document has a very long title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
indexDTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
}
Creating section 0: {
title: 'Section 1',
dTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[ 'version', 'Version' ],
[ 'summary', 'This document has a very long title' ],
[
'd',
'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
],
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
✓ tests/unit/eventInput30040.test.ts (14 tests) 389ms
(node:1443840) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
✓ tests/unit/mathProcessing.test.ts (18 tests) 16ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:44:30
42|
43| expect(metadata.title).toBe("Test Document with Metadata");
44| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
45| expect(metadata.version).toBe("1.0");
46| expect(metadata.publicationDate).toBe("2024-01-15");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:318:32
316| // Should extract document-level metadata
317| expect(metadata.title).toBe("Test Document");
318| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
319| expect(metadata.version).toBe("1.0");
320| expect(metadata.publishedBy).toBe("Alexandria Test");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 1 failed | 6 passed (7)
Tests 2 failed | 116 passed (118)
Start at 13:16:23
Duration 2.53s (transform 1.97s, setup 0ms, collect 3.66s, tests 710ms, environment 2ms, prepare 1.10s)
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit
c RERUN src/lib/utils/asciidoc_metadata.ts
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure with Preamble > should build 30040 event set with preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document with Preamble',
authors: [ 'John Doe', 'Section Author' ],
version: '1.0',
publicationDate: '2024-01-15, Alexandria Test',
summary: 'This is a test document with preamble',
tags: [ 'test', 'preamble', 'asciidoc' ]
},
content: '= Test Document with Preamble\n' +
'John Doe <john@example.com>\n' +
'1.0, 2024-01-15, Alexandria Test\n' +
':summary: This is a test document with preamble\n' +
':keywords: test, preamble, asciidoc\n' +
'\n' +
'This is the preamble content that should be included.\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document with Preamble',
indexDTag: 'test-document-with-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-with-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-with-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document with Preamble' ],
[ 'author', 'John Doe' ],
[ 'author', 'Section Author' ],
[ 'version', '1.0' ],
[ 'published_on', '2024-01-15, Alexandria Test' ],
[ 'summary', 'This is a test document with preamble' ],
[ 't', 'test' ],
[ 't', 'preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-with-preamble' ],
[ 'title', 'Test Document with Preamble' ],
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure without Preamble > should build 30040 event set without preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document without Preamble',
authors: [ 'Section Author' ],
version: 'Version',
summary: 'This is a test document without preamble',
tags: [ 'test', 'no-preamble', 'asciidoc' ]
},
content: '= Test Document without Preamble\n' +
':summary: This is a test document without preamble\n' +
':keywords: test, no-preamble, asciidoc\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document without Preamble',
indexDTag: 'test-document-without-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-without-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-without-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document without Preamble' ],
[ 'author', 'Section Author' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a test document without preamble' ],
[ 't', 'test' ],
[ 't', 'no-preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-without-preamble' ],
[ 'title', 'Test Document without Preamble' ],
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure with Preamble > should build 30040 event set with skeleton structure and preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document with Preamble',
version: 'Version',
summary: 'This is a skeleton document with preamble',
tags: [ 'skeleton', 'preamble', 'empty' ]
},
content: '= Skeleton Document with Preamble\n' +
':summary: This is a skeleton document with preamble\n' +
':keywords: skeleton, preamble, empty\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document with Preamble',
indexDTag: 'skeleton-document-with-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-with-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-with-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-with-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document with Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document with preamble' ],
[ 't', 'skeleton' ],
[ 't', 'preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-with-preamble' ],
[ 'title', 'Skeleton Document with Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
❯ tests/unit/metadataExtraction.test.ts (16 tests | 2 failed) 202ms
× AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly 116ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract section metadata correctly 7ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract standalone author names and remove them from content 4ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should handle multiple standalone author names 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should not extract non-author lines as authors 4ms
✓ AsciiDoc Metadata Extraction > parseAsciiDocWithMetadata should parse complete document 20ms
✓ AsciiDoc Metadata Extraction > metadataToTags should convert metadata to Nostr tags 2ms
✓ AsciiDoc Metadata Extraction > should handle index card format correctly 4ms
✓ AsciiDoc Metadata Extraction > should handle empty content gracefully 4ms
✓ AsciiDoc Metadata Extraction > should handle keywords as tags 4ms
✓ AsciiDoc Metadata Extraction > should handle both tags and keywords 4ms
✓ AsciiDoc Metadata Extraction > should handle tags only 3ms
✓ AsciiDoc Metadata Extraction > should handle both summary and description 7ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle section-only content correctly 8ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle minimal document header (just title) correctly 1ms
× AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly 7ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure without Preamble > should build 30040 event set with skeleton structure without preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document without Preamble',
version: 'Version',
summary: 'This is a skeleton document without preamble',
tags: [ 'skeleton', 'no-preamble', 'empty' ]
},
content: '= Skeleton Document without Preamble\n' +
':summary: This is a skeleton document without preamble\n' +
':keywords: skeleton, no-preamble, empty\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document without Preamble',
indexDTag: 'skeleton-document-without-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-without-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-without-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-without-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document without Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document without preamble' ],
[ 't', 'skeleton' ],
[ 't', 'no-preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-without-preamble' ],
[ 'title', 'Skeleton Document without Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card format
Parsed AsciiDoc: {
metadata: { title: 'Test Index Card', version: 'Version' },
content: '= Test Index Card\nindex card',
sections: []
}
Creating index card format (no sections)
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card with metadata
Parsed AsciiDoc: {
metadata: {
title: 'Test Index Card with Metadata',
version: 'Version',
summary: 'This is an index card with metadata',
tags: [ 'index', 'card', 'metadata' ]
},
content: '= Test Index Card with Metadata\n' +
':summary: This is an index card with metadata\n' +
':keywords: index, card, metadata\n' +
'index card',
sections: []
}
Index event: {
documentTitle: 'Test Index Card with Metadata',
indexDTag: 'test-index-card-with-metadata'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'index-card' ],
[ 'title', 'Test Index Card with Metadata' ],
[ 'version', 'Version' ],
[ 'summary', 'This is an index card with metadata' ],
[ 't', 'index' ],
[ 't', 'card' ],
[ 't', 'metadata' ],
[ 'd', 'test-index-card-with-metadata' ],
[ 'title', 'Test Index Card with Metadata' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Complex Metadata Structures > should handle complex metadata with all attribute types
Parsed AsciiDoc: {
metadata: {
title: 'Complex Metadata Document',
authors: [
'Jane Smith',
'Override Author',
'Third Author',
'Section Author',
'Section Co-Author'
],
version: '2.0',
publicationDate: '2024-03-01',
summary: 'This is a complex document with all metadata types Alternative description field',
publishedBy: 'Alexandria Complex',
type: 'book',
coverImage: 'https://example.com/cover.jpg',
isbn: '978-0-123456-78-9',
source: 'https://github.com/alexandria/complex',
autoUpdate: 'yes',
tags: [
'additional',
'tags',
'here',
'complex',
'metadata',
'all-types'
]
},
content: '= Complex Metadata Document\n' +
'Jane Smith <jane@example.com>\n' +
'2.0, 2024-02-20, Alexandria Complex\n' +
':summary: This is a complex document with all metadata types\n' +
':description: Alternative description field\n' +
':keywords: complex, metadata, all-types\n' +
':tags: additional, tags, here\n' +
':author: Override Author\n' +
':author: Third Author\n' +
':version: 3.0\n' +
':published_on: 2024-03-01\n' +
':published_by: Alexandria Complex\n' +
':type: book\n' +
':image: https://example.com/cover.jpg\n' +
':isbn: 978-0-123456-78-9\n' +
':source: https://github.com/alexandria/complex\n' +
':auto-update: yes\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Section with Complex Metadata\n' +
':author: Section Author\n' +
':author: Section Co-Author\n' +
':summary: This section has complex metadata\n' +
':description: Alternative description for section\n' +
':keywords: section, complex, metadata\n' +
':tags: section, tags\n' +
':type: chapter\n' +
':image: https://example.com/section-image.jpg\n' +
'\n' +
'This is the section content.',
sections: [
{
metadata: [Object],
content: 'This is the section content.',
title: 'Section with Complex Metadata'
}
]
}
Index event: {
documentTitle: 'Complex Metadata Document',
indexDTag: 'complex-metadata-document'
}
Creating section 0: {
title: 'Section with Complex Metadata',
dTag: 'complex-metadata-document-section-with-complex-metadata',
content: 'This is the section content.',
metadata: {
title: 'Section with Complex Metadata',
authors: [ 'Section Author', 'Section Co-Author' ],
summary: 'This section has complex metadata Alternative description for section',
type: 'chapter',
coverImage: 'https://example.com/section-image.jpg',
tags: [ 'section', 'tags', 'complex', 'metadata' ]
}
}
A tags: [
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'complex' ],
[ 'title', 'Complex Metadata Document' ],
[ 'author', 'Jane Smith' ],
[ 'author', 'Override Author' ],
[ 'author', 'Third Author' ],
[ 'author', 'Section Author' ],
[ 'author', 'Section Co-Author' ],
[ 'version', '2.0' ],
[ 'published_on', '2024-03-01' ],
[ 'published_by', 'Alexandria Complex' ],
[
'summary',
'This is a complex document with all metadata types Alternative description field'
],
[ 'image', 'https://example.com/cover.jpg' ],
[ 'i', '978-0-123456-78-9' ],
[ 'source', 'https://github.com/alexandria/complex' ],
[ 'type', 'book' ],
[ 'auto-update', 'yes' ],
[ 't', 'additional' ],
[ 't', 'tags' ],
[ 't', 'here' ],
[ 't', 'complex' ],
[ 't', 'metadata' ],
[ 't', 'all-types' ],
[ 'd', 'complex-metadata-document' ],
[ 'title', 'Complex Metadata Document' ],
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with only title and no sections
Parsed AsciiDoc: {
metadata: {
title: 'Document with No Sections',
version: 'Version',
summary: 'This document has no sections'
},
content: '= Document with No Sections\n' +
':summary: This document has no sections\n' +
'\n' +
'This is just preamble content.',
sections: []
}
Index event: {
documentTitle: 'Document with No Sections',
indexDTag: 'document-with-no-sections'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with No Sections' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has no sections' ],
[ 'd', 'document-with-no-sections' ],
[ 'title', 'Document with No Sections' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with special characters in title
Parsed AsciiDoc: {
metadata: {
title: 'Document with Special Characters: Test & More!',
version: 'Version',
summary: 'This document has special characters in the title'
},
content: '= Document with Special Characters: Test & More!\n' +
':summary: This document has special characters in the title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'Document with Special Characters: Test & More!',
indexDTag: 'document-with-special-characters-test-more'
}
Creating section 0: {
title: 'Section 1',
dTag: 'document-with-special-characters-test-more-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with Special Characters: Test & More!' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has special characters in the title' ],
[ 'd', 'document-with-special-characters-test-more' ],
[ 'title', 'Document with Special Characters: Test & More!' ],
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with very long title
Parsed AsciiDoc: {
metadata: {
title: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
version: 'Version',
summary: 'This document has a very long title'
},
content: '= This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality\n' +
':summary: This document has a very long title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
indexDTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
}
Creating section 0: {
title: 'Section 1',
dTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[ 'version', 'Version' ],
[ 'summary', 'This document has a very long title' ],
[
'd',
'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
],
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
✓ tests/unit/eventInput30040.test.ts (14 tests) 333ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:44:30
42|
43| expect(metadata.title).toBe("Test Document with Metadata");
44| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
45| expect(metadata.version).toBe("1.0");
46| expect(metadata.publicationDate).toBe("2024-01-15");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:318:32
316| // Should extract document-level metadata
317| expect(metadata.title).toBe("Test Document");
318| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
319| expect(metadata.version).toBe("1.0");
320| expect(metadata.publishedBy).toBe("Alexandria Test");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 1 failed | 1 passed (2)
Tests 2 failed | 28 passed (30)
Start at 13:18:57
Duration 1.00s
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit
c RERUN src/lib/utils/asciidoc_metadata.ts
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure with Preamble > should build 30040 event set with preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document with Preamble',
authors: [ 'John Doe', 'Section Author' ],
version: '1.0',
publicationDate: '2024-01-15, Alexandria Test',
summary: 'This is a test document with preamble',
tags: [ 'test', 'preamble', 'asciidoc' ]
},
content: '= Test Document with Preamble\n' +
'John Doe <john@example.com>\n' +
'1.0, 2024-01-15, Alexandria Test\n' +
':summary: This is a test document with preamble\n' +
':keywords: test, preamble, asciidoc\n' +
'\n' +
'This is the preamble content that should be included.\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document with Preamble',
indexDTag: 'test-document-with-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-with-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-with-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document with Preamble' ],
[ 'author', 'John Doe' ],
[ 'author', 'Section Author' ],
[ 'version', '1.0' ],
[ 'published_on', '2024-01-15, Alexandria Test' ],
[ 'summary', 'This is a test document with preamble' ],
[ 't', 'test' ],
[ 't', 'preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-with-preamble' ],
[ 'title', 'Test Document with Preamble' ],
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure without Preamble > should build 30040 event set without preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document without Preamble',
authors: [ 'Section Author' ],
version: 'Version',
summary: 'This is a test document without preamble',
tags: [ 'test', 'no-preamble', 'asciidoc' ]
},
content: '= Test Document without Preamble\n' +
':summary: This is a test document without preamble\n' +
':keywords: test, no-preamble, asciidoc\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document without Preamble',
indexDTag: 'test-document-without-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-without-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-without-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document without Preamble' ],
[ 'author', 'Section Author' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a test document without preamble' ],
[ 't', 'test' ],
[ 't', 'no-preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-without-preamble' ],
[ 'title', 'Test Document without Preamble' ],
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
❯ tests/unit/metadataExtraction.test.ts (16 tests | 2 failed) 228ms
× AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly 129ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract section metadata correctly 8ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract standalone author names and remove them from content 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should handle multiple standalone author names 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should not extract non-author lines as authors 4ms
✓ AsciiDoc Metadata Extraction > parseAsciiDocWithMetadata should parse complete document 21ms
✓ AsciiDoc Metadata Extraction > metadataToTags should convert metadata to Nostr tags 2ms
✓ AsciiDoc Metadata Extraction > should handle index card format correctly 5ms
✓ AsciiDoc Metadata Extraction > should handle empty content gracefully 4ms
✓ AsciiDoc Metadata Extraction > should handle keywords as tags 4ms
✓ AsciiDoc Metadata Extraction > should handle both tags and keywords 5ms
✓ AsciiDoc Metadata Extraction > should handle tags only 4ms
✓ AsciiDoc Metadata Extraction > should handle both summary and description 8ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle section-only content correctly 10ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle minimal document header (just title) correctly 1ms
× AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly 9ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure with Preamble > should build 30040 event set with skeleton structure and preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document with Preamble',
version: 'Version',
summary: 'This is a skeleton document with preamble',
tags: [ 'skeleton', 'preamble', 'empty' ]
},
content: '= Skeleton Document with Preamble\n' +
':summary: This is a skeleton document with preamble\n' +
':keywords: skeleton, preamble, empty\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document with Preamble',
indexDTag: 'skeleton-document-with-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-with-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-with-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-with-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document with Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document with preamble' ],
[ 't', 'skeleton' ],
[ 't', 'preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-with-preamble' ],
[ 'title', 'Skeleton Document with Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure without Preamble > should build 30040 event set with skeleton structure without preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document without Preamble',
version: 'Version',
summary: 'This is a skeleton document without preamble',
tags: [ 'skeleton', 'no-preamble', 'empty' ]
},
content: '= Skeleton Document without Preamble\n' +
':summary: This is a skeleton document without preamble\n' +
':keywords: skeleton, no-preamble, empty\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document without Preamble',
indexDTag: 'skeleton-document-without-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-without-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-without-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-without-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document without Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document without preamble' ],
[ 't', 'skeleton' ],
[ 't', 'no-preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-without-preamble' ],
[ 'title', 'Skeleton Document without Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card format
Parsed AsciiDoc: {
metadata: { title: 'Test Index Card', version: 'Version' },
content: '= Test Index Card\nindex card',
sections: []
}
Creating index card format (no sections)
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card with metadata
Parsed AsciiDoc: {
metadata: {
title: 'Test Index Card with Metadata',
version: 'Version',
summary: 'This is an index card with metadata',
tags: [ 'index', 'card', 'metadata' ]
},
content: '= Test Index Card with Metadata\n' +
':summary: This is an index card with metadata\n' +
':keywords: index, card, metadata\n' +
'index card',
sections: []
}
Index event: {
documentTitle: 'Test Index Card with Metadata',
indexDTag: 'test-index-card-with-metadata'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'index-card' ],
[ 'title', 'Test Index Card with Metadata' ],
[ 'version', 'Version' ],
[ 'summary', 'This is an index card with metadata' ],
[ 't', 'index' ],
[ 't', 'card' ],
[ 't', 'metadata' ],
[ 'd', 'test-index-card-with-metadata' ],
[ 'title', 'Test Index Card with Metadata' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Complex Metadata Structures > should handle complex metadata with all attribute types
Parsed AsciiDoc: {
metadata: {
title: 'Complex Metadata Document',
authors: [
'Jane Smith',
'Override Author',
'Third Author',
'Section Author',
'Section Co-Author'
],
version: '2.0',
publicationDate: '2024-03-01',
summary: 'This is a complex document with all metadata types Alternative description field',
publishedBy: 'Alexandria Complex',
type: 'book',
coverImage: 'https://example.com/cover.jpg',
isbn: '978-0-123456-78-9',
source: 'https://github.com/alexandria/complex',
autoUpdate: 'yes',
tags: [
'additional',
'tags',
'here',
'complex',
'metadata',
'all-types'
]
},
content: '= Complex Metadata Document\n' +
'Jane Smith <jane@example.com>\n' +
'2.0, 2024-02-20, Alexandria Complex\n' +
':summary: This is a complex document with all metadata types\n' +
':description: Alternative description field\n' +
':keywords: complex, metadata, all-types\n' +
':tags: additional, tags, here\n' +
':author: Override Author\n' +
':author: Third Author\n' +
':version: 3.0\n' +
':published_on: 2024-03-01\n' +
':published_by: Alexandria Complex\n' +
':type: book\n' +
':image: https://example.com/cover.jpg\n' +
':isbn: 978-0-123456-78-9\n' +
':source: https://github.com/alexandria/complex\n' +
':auto-update: yes\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Section with Complex Metadata\n' +
':author: Section Author\n' +
':author: Section Co-Author\n' +
':summary: This section has complex metadata\n' +
':description: Alternative description for section\n' +
':keywords: section, complex, metadata\n' +
':tags: section, tags\n' +
':type: chapter\n' +
':image: https://example.com/section-image.jpg\n' +
'\n' +
'This is the section content.',
sections: [
{
metadata: [Object],
content: 'This is the section content.',
title: 'Section with Complex Metadata'
}
]
}
Index event: {
documentTitle: 'Complex Metadata Document',
indexDTag: 'complex-metadata-document'
}
Creating section 0: {
title: 'Section with Complex Metadata',
dTag: 'complex-metadata-document-section-with-complex-metadata',
content: 'This is the section content.',
metadata: {
title: 'Section with Complex Metadata',
authors: [ 'Section Author', 'Section Co-Author' ],
summary: 'This section has complex metadata Alternative description for section',
type: 'chapter',
coverImage: 'https://example.com/section-image.jpg',
tags: [ 'section', 'tags', 'complex', 'metadata' ]
}
}
A tags: [
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'complex' ],
[ 'title', 'Complex Metadata Document' ],
[ 'author', 'Jane Smith' ],
[ 'author', 'Override Author' ],
[ 'author', 'Third Author' ],
[ 'author', 'Section Author' ],
[ 'author', 'Section Co-Author' ],
[ 'version', '2.0' ],
[ 'published_on', '2024-03-01' ],
[ 'published_by', 'Alexandria Complex' ],
[
'summary',
'This is a complex document with all metadata types Alternative description field'
],
[ 'image', 'https://example.com/cover.jpg' ],
[ 'i', '978-0-123456-78-9' ],
[ 'source', 'https://github.com/alexandria/complex' ],
[ 'type', 'book' ],
[ 'auto-update', 'yes' ],
[ 't', 'additional' ],
[ 't', 'tags' ],
[ 't', 'here' ],
[ 't', 'complex' ],
[ 't', 'metadata' ],
[ 't', 'all-types' ],
[ 'd', 'complex-metadata-document' ],
[ 'title', 'Complex Metadata Document' ],
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with only title and no sections
Parsed AsciiDoc: {
metadata: {
title: 'Document with No Sections',
version: 'Version',
summary: 'This document has no sections'
},
content: '= Document with No Sections\n' +
':summary: This document has no sections\n' +
'\n' +
'This is just preamble content.',
sections: []
}
Index event: {
documentTitle: 'Document with No Sections',
indexDTag: 'document-with-no-sections'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with No Sections' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has no sections' ],
[ 'd', 'document-with-no-sections' ],
[ 'title', 'Document with No Sections' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with special characters in title
Parsed AsciiDoc: {
metadata: {
title: 'Document with Special Characters: Test & More!',
version: 'Version',
summary: 'This document has special characters in the title'
},
content: '= Document with Special Characters: Test & More!\n' +
':summary: This document has special characters in the title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'Document with Special Characters: Test & More!',
indexDTag: 'document-with-special-characters-test-more'
}
Creating section 0: {
title: 'Section 1',
dTag: 'document-with-special-characters-test-more-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with Special Characters: Test & More!' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has special characters in the title' ],
[ 'd', 'document-with-special-characters-test-more' ],
[ 'title', 'Document with Special Characters: Test & More!' ],
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with very long title
Parsed AsciiDoc: {
metadata: {
title: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
version: 'Version',
summary: 'This document has a very long title'
},
content: '= This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality\n' +
':summary: This document has a very long title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
indexDTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
}
Creating section 0: {
title: 'Section 1',
dTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[ 'version', 'Version' ],
[ 'summary', 'This document has a very long title' ],
[
'd',
'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
],
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
✓ tests/unit/eventInput30040.test.ts (14 tests) 424ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:44:30
42|
43| expect(metadata.title).toBe("Test Document with Metadata");
44| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
45| expect(metadata.version).toBe("1.0");
46| expect(metadata.publicationDate).toBe("2024-01-15");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:318:32
316| // Should extract document-level metadata
317| expect(metadata.title).toBe("Test Document");
318| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
319| expect(metadata.version).toBe("1.0");
320| expect(metadata.publishedBy).toBe("Alexandria Test");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 1 failed | 1 passed (2)
Tests 2 failed | 28 passed (30)
Start at 13:19:15
Duration 1.04s
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit
c RERUN src/lib/utils/asciidoc_metadata.ts
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure with Preamble > should build 30040 event set with preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document with Preamble',
authors: [ 'John Doe', 'Section Author' ],
version: '1.0',
publicationDate: '2024-01-15, Alexandria Test',
summary: 'This is a test document with preamble',
tags: [ 'test', 'preamble', 'asciidoc' ]
},
content: '= Test Document with Preamble\n' +
'John Doe <john@example.com>\n' +
'1.0, 2024-01-15, Alexandria Test\n' +
':summary: This is a test document with preamble\n' +
':keywords: test, preamble, asciidoc\n' +
'\n' +
'This is the preamble content that should be included.\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document with Preamble',
indexDTag: 'test-document-with-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-with-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-with-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document with Preamble' ],
[ 'author', 'John Doe' ],
[ 'author', 'Section Author' ],
[ 'version', '1.0' ],
[ 'published_on', '2024-01-15, Alexandria Test' ],
[ 'summary', 'This is a test document with preamble' ],
[ 't', 'test' ],
[ 't', 'preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-with-preamble' ],
[ 'title', 'Test Document with Preamble' ],
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure without Preamble > should build 30040 event set without preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document without Preamble',
authors: [ 'Section Author' ],
version: 'Version',
summary: 'This is a test document without preamble',
tags: [ 'test', 'no-preamble', 'asciidoc' ]
},
content: '= Test Document without Preamble\n' +
':summary: This is a test document without preamble\n' +
':keywords: test, no-preamble, asciidoc\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document without Preamble',
indexDTag: 'test-document-without-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-without-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-without-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document without Preamble' ],
[ 'author', 'Section Author' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a test document without preamble' ],
[ 't', 'test' ],
[ 't', 'no-preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-without-preamble' ],
[ 'title', 'Test Document without Preamble' ],
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure with Preamble > should build 30040 event set with skeleton structure and preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document with Preamble',
version: 'Version',
summary: 'This is a skeleton document with preamble',
tags: [ 'skeleton', 'preamble', 'empty' ]
},
content: '= Skeleton Document with Preamble\n' +
':summary: This is a skeleton document with preamble\n' +
':keywords: skeleton, preamble, empty\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document with Preamble',
indexDTag: 'skeleton-document-with-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-with-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-with-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-with-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document with Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document with preamble' ],
[ 't', 'skeleton' ],
[ 't', 'preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-with-preamble' ],
[ 'title', 'Skeleton Document with Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure without Preamble > should build 30040 event set with skeleton structure without preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document without Preamble',
version: 'Version',
summary: 'This is a skeleton document without preamble',
tags: [ 'skeleton', 'no-preamble', 'empty' ]
},
content: '= Skeleton Document without Preamble\n' +
':summary: This is a skeleton document without preamble\n' +
':keywords: skeleton, no-preamble, empty\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document without Preamble',
indexDTag: 'skeleton-document-without-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-without-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-without-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-without-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document without Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document without preamble' ],
[ 't', 'skeleton' ],
[ 't', 'no-preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-without-preamble' ],
[ 'title', 'Skeleton Document without Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
❯ tests/unit/metadataExtraction.test.ts (16 tests | 2 failed) 246ms
× AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly 154ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract section metadata correctly 8ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract standalone author names and remove them from content 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should handle multiple standalone author names 5ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should not extract non-author lines as authors 4ms
✓ AsciiDoc Metadata Extraction > parseAsciiDocWithMetadata should parse complete document 21ms
✓ AsciiDoc Metadata Extraction > metadataToTags should convert metadata to Nostr tags 2ms
✓ AsciiDoc Metadata Extraction > should handle index card format correctly 4ms
✓ AsciiDoc Metadata Extraction > should handle empty content gracefully 4ms
✓ AsciiDoc Metadata Extraction > should handle keywords as tags 5ms
✓ AsciiDoc Metadata Extraction > should handle both tags and keywords 4ms
✓ AsciiDoc Metadata Extraction > should handle tags only 4ms
✓ AsciiDoc Metadata Extraction > should handle both summary and description 7ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle section-only content correctly 8ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle minimal document header (just title) correctly 1ms
× AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly 7ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card format
Parsed AsciiDoc: {
metadata: { title: 'Test Index Card', version: 'Version' },
content: '= Test Index Card\nindex card',
sections: []
}
Creating index card format (no sections)
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card with metadata
Parsed AsciiDoc: {
metadata: {
title: 'Test Index Card with Metadata',
version: 'Version',
summary: 'This is an index card with metadata',
tags: [ 'index', 'card', 'metadata' ]
},
content: '= Test Index Card with Metadata\n' +
':summary: This is an index card with metadata\n' +
':keywords: index, card, metadata\n' +
'index card',
sections: []
}
Index event: {
documentTitle: 'Test Index Card with Metadata',
indexDTag: 'test-index-card-with-metadata'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'index-card' ],
[ 'title', 'Test Index Card with Metadata' ],
[ 'version', 'Version' ],
[ 'summary', 'This is an index card with metadata' ],
[ 't', 'index' ],
[ 't', 'card' ],
[ 't', 'metadata' ],
[ 'd', 'test-index-card-with-metadata' ],
[ 'title', 'Test Index Card with Metadata' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Complex Metadata Structures > should handle complex metadata with all attribute types
Parsed AsciiDoc: {
metadata: {
title: 'Complex Metadata Document',
authors: [
'Jane Smith',
'Override Author',
'Third Author',
'Section Author',
'Section Co-Author'
],
version: '2.0',
publicationDate: '2024-03-01',
summary: 'This is a complex document with all metadata types Alternative description field',
publishedBy: 'Alexandria Complex',
type: 'book',
coverImage: 'https://example.com/cover.jpg',
isbn: '978-0-123456-78-9',
source: 'https://github.com/alexandria/complex',
autoUpdate: 'yes',
tags: [
'additional',
'tags',
'here',
'complex',
'metadata',
'all-types'
]
},
content: '= Complex Metadata Document\n' +
'Jane Smith <jane@example.com>\n' +
'2.0, 2024-02-20, Alexandria Complex\n' +
':summary: This is a complex document with all metadata types\n' +
':description: Alternative description field\n' +
':keywords: complex, metadata, all-types\n' +
':tags: additional, tags, here\n' +
':author: Override Author\n' +
':author: Third Author\n' +
':version: 3.0\n' +
':published_on: 2024-03-01\n' +
':published_by: Alexandria Complex\n' +
':type: book\n' +
':image: https://example.com/cover.jpg\n' +
':isbn: 978-0-123456-78-9\n' +
':source: https://github.com/alexandria/complex\n' +
':auto-update: yes\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Section with Complex Metadata\n' +
':author: Section Author\n' +
':author: Section Co-Author\n' +
':summary: This section has complex metadata\n' +
':description: Alternative description for section\n' +
':keywords: section, complex, metadata\n' +
':tags: section, tags\n' +
':type: chapter\n' +
':image: https://example.com/section-image.jpg\n' +
'\n' +
'This is the section content.',
sections: [
{
metadata: [Object],
content: 'This is the section content.',
title: 'Section with Complex Metadata'
}
]
}
Index event: {
documentTitle: 'Complex Metadata Document',
indexDTag: 'complex-metadata-document'
}
Creating section 0: {
title: 'Section with Complex Metadata',
dTag: 'complex-metadata-document-section-with-complex-metadata',
content: 'This is the section content.',
metadata: {
title: 'Section with Complex Metadata',
authors: [ 'Section Author', 'Section Co-Author' ],
summary: 'This section has complex metadata Alternative description for section',
type: 'chapter',
coverImage: 'https://example.com/section-image.jpg',
tags: [ 'section', 'tags', 'complex', 'metadata' ]
}
}
A tags: [
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'complex' ],
[ 'title', 'Complex Metadata Document' ],
[ 'author', 'Jane Smith' ],
[ 'author', 'Override Author' ],
[ 'author', 'Third Author' ],
[ 'author', 'Section Author' ],
[ 'author', 'Section Co-Author' ],
[ 'version', '2.0' ],
[ 'published_on', '2024-03-01' ],
[ 'published_by', 'Alexandria Complex' ],
[
'summary',
'This is a complex document with all metadata types Alternative description field'
],
[ 'image', 'https://example.com/cover.jpg' ],
[ 'i', '978-0-123456-78-9' ],
[ 'source', 'https://github.com/alexandria/complex' ],
[ 'type', 'book' ],
[ 'auto-update', 'yes' ],
[ 't', 'additional' ],
[ 't', 'tags' ],
[ 't', 'here' ],
[ 't', 'complex' ],
[ 't', 'metadata' ],
[ 't', 'all-types' ],
[ 'd', 'complex-metadata-document' ],
[ 'title', 'Complex Metadata Document' ],
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with only title and no sections
Parsed AsciiDoc: {
metadata: {
title: 'Document with No Sections',
version: 'Version',
summary: 'This document has no sections'
},
content: '= Document with No Sections\n' +
':summary: This document has no sections\n' +
'\n' +
'This is just preamble content.',
sections: []
}
Index event: {
documentTitle: 'Document with No Sections',
indexDTag: 'document-with-no-sections'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with No Sections' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has no sections' ],
[ 'd', 'document-with-no-sections' ],
[ 'title', 'Document with No Sections' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with special characters in title
Parsed AsciiDoc: {
metadata: {
title: 'Document with Special Characters: Test & More!',
version: 'Version',
summary: 'This document has special characters in the title'
},
content: '= Document with Special Characters: Test & More!\n' +
':summary: This document has special characters in the title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'Document with Special Characters: Test & More!',
indexDTag: 'document-with-special-characters-test-more'
}
Creating section 0: {
title: 'Section 1',
dTag: 'document-with-special-characters-test-more-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with Special Characters: Test & More!' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has special characters in the title' ],
[ 'd', 'document-with-special-characters-test-more' ],
[ 'title', 'Document with Special Characters: Test & More!' ],
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with very long title
Parsed AsciiDoc: {
metadata: {
title: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
version: 'Version',
summary: 'This document has a very long title'
},
content: '= This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality\n' +
':summary: This document has a very long title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
indexDTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
}
Creating section 0: {
title: 'Section 1',
dTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[ 'version', 'Version' ],
[ 'summary', 'This document has a very long title' ],
[
'd',
'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
],
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
✓ tests/unit/eventInput30040.test.ts (14 tests) 374ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:44:30
42|
43| expect(metadata.title).toBe("Test Document with Metadata");
44| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
45| expect(metadata.version).toBe("1.0");
46| expect(metadata.publicationDate).toBe("2024-01-15");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:318:32
316| // Should extract document-level metadata
317| expect(metadata.title).toBe("Test Document");
318| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
319| expect(metadata.version).toBe("1.0");
320| expect(metadata.publishedBy).toBe("Alexandria Test");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 1 failed | 1 passed (2)
Tests 2 failed | 28 passed (30)
Start at 13:20:56
Duration 1.17s
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit
c RERUN src/lib/utils/asciidoc_metadata.ts
❯ tests/unit/metadataExtraction.test.ts (16 tests | 2 failed) 270ms
× AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly 158ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract section metadata correctly 8ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should extract standalone author names and remove them from content 6ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should handle multiple standalone author names 6ms
✓ AsciiDoc Metadata Extraction > extractSectionMetadata should not extract non-author lines as authors 6ms
✓ AsciiDoc Metadata Extraction > parseAsciiDocWithMetadata should parse complete document 26ms
✓ AsciiDoc Metadata Extraction > metadataToTags should convert metadata to Nostr tags 2ms
✓ AsciiDoc Metadata Extraction > should handle index card format correctly 5ms
✓ AsciiDoc Metadata Extraction > should handle empty content gracefully 5ms
✓ AsciiDoc Metadata Extraction > should handle keywords as tags 5ms
✓ AsciiDoc Metadata Extraction > should handle both tags and keywords 4ms
✓ AsciiDoc Metadata Extraction > should handle tags only 4ms
✓ AsciiDoc Metadata Extraction > should handle both summary and description 9ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle section-only content correctly 9ms
✓ AsciiDoc Metadata Extraction > Smart metadata extraction > should handle minimal document header (just title) correctly 1ms
× AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly 11ms
→ expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure with Preamble > should build 30040 event set with preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document with Preamble',
authors: [ 'John Doe', 'Section Author' ],
version: '1.0',
publicationDate: '2024-01-15, Alexandria Test',
summary: 'This is a test document with preamble',
tags: [ 'test', 'preamble', 'asciidoc' ]
},
content: '= Test Document with Preamble\n' +
'John Doe <john@example.com>\n' +
'1.0, 2024-01-15, Alexandria Test\n' +
':summary: This is a test document with preamble\n' +
':keywords: test, preamble, asciidoc\n' +
'\n' +
'This is the preamble content that should be included.\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document with Preamble',
indexDTag: 'test-document-with-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-with-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-with-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document with Preamble' ],
[ 'author', 'John Doe' ],
[ 'author', 'Section Author' ],
[ 'version', '1.0' ],
[ 'published_on', '2024-01-15, Alexandria Test' ],
[ 'summary', 'This is a test document with preamble' ],
[ 't', 'test' ],
[ 't', 'preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-with-preamble' ],
[ 'title', 'Test Document with Preamble' ],
[
'a',
'30041:test-pubkey:test-document-with-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-with-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Normal Structure without Preamble > should build 30040 event set without preamble content
Parsed AsciiDoc: {
metadata: {
title: 'Test Document without Preamble',
authors: [ 'Section Author' ],
version: 'Version',
summary: 'This is a test document without preamble',
tags: [ 'test', 'no-preamble', 'asciidoc' ]
},
content: '= Test Document without Preamble\n' +
':summary: This is a test document without preamble\n' +
':keywords: test, no-preamble, asciidoc\n' +
'\n' +
'== First Section\n' +
':author: Section Author\n' +
':summary: This is the first section\n' +
'\n' +
'This is the content of the first section.\n' +
'\n' +
'== Second Section\n' +
':summary: This is the second section\n' +
'\n' +
'This is the content of the second section.',
sections: [
{
metadata: [Object],
content: 'This is the content of the first section.',
title: 'First Section'
},
{
metadata: [Object],
content: 'This is the content of the second section.',
title: 'Second Section'
}
]
}
Index event: {
documentTitle: 'Test Document without Preamble',
indexDTag: 'test-document-without-preamble'
}
Creating section 0: {
title: 'First Section',
dTag: 'test-document-without-preamble-first-section',
content: 'This is the content of the first section.',
metadata: {
title: 'First Section',
authors: [ 'Section Author' ],
summary: 'This is the first section'
}
}
Creating section 1: {
title: 'Second Section',
dTag: 'test-document-without-preamble-second-section',
content: 'This is the content of the second section.',
metadata: { title: 'Second Section', summary: 'This is the second section' }
}
A tags: [
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'article' ],
[ 'title', 'Test Document without Preamble' ],
[ 'author', 'Section Author' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a test document without preamble' ],
[ 't', 'test' ],
[ 't', 'no-preamble' ],
[ 't', 'asciidoc' ],
[ 'd', 'test-document-without-preamble' ],
[ 'title', 'Test Document without Preamble' ],
[
'a',
'30041:test-pubkey:test-document-without-preamble-first-section'
],
[
'a',
'30041:test-pubkey:test-document-without-preamble-second-section'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure with Preamble > should build 30040 event set with skeleton structure and preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document with Preamble',
version: 'Version',
summary: 'This is a skeleton document with preamble',
tags: [ 'skeleton', 'preamble', 'empty' ]
},
content: '= Skeleton Document with Preamble\n' +
':summary: This is a skeleton document with preamble\n' +
':keywords: skeleton, preamble, empty\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document with Preamble',
indexDTag: 'skeleton-document-with-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-with-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-with-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-with-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document with Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document with preamble' ],
[ 't', 'skeleton' ],
[ 't', 'preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-with-preamble' ],
[ 'title', 'Skeleton Document with Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-with-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Skeleton Structure without Preamble > should build 30040 event set with skeleton structure without preamble
Parsed AsciiDoc: {
metadata: {
title: 'Skeleton Document without Preamble',
version: 'Version',
summary: 'This is a skeleton document without preamble',
tags: [ 'skeleton', 'no-preamble', 'empty' ]
},
content: '= Skeleton Document without Preamble\n' +
':summary: This is a skeleton document without preamble\n' +
':keywords: skeleton, no-preamble, empty\n' +
'\n' +
'== Empty Section 1\n' +
'\n' +
'== Empty Section 2\n' +
'\n' +
'== Empty Section 3',
sections: [
{ metadata: [Object], content: '', title: 'Empty Section 1' },
{ metadata: [Object], content: '', title: 'Empty Section 2' },
{ metadata: [Object], content: '', title: 'Empty Section 3' }
]
}
Index event: {
documentTitle: 'Skeleton Document without Preamble',
indexDTag: 'skeleton-document-without-preamble'
}
Creating section 0: {
title: 'Empty Section 1',
dTag: 'skeleton-document-without-preamble-empty-section-1',
content: '',
metadata: { title: 'Empty Section 1' }
}
Creating section 1: {
title: 'Empty Section 2',
dTag: 'skeleton-document-without-preamble-empty-section-2',
content: '',
metadata: { title: 'Empty Section 2' }
}
Creating section 2: {
title: 'Empty Section 3',
dTag: 'skeleton-document-without-preamble-empty-section-3',
content: '',
metadata: { title: 'Empty Section 3' }
}
A tags: [
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'skeleton' ],
[ 'title', 'Skeleton Document without Preamble' ],
[ 'version', 'Version' ],
[ 'summary', 'This is a skeleton document without preamble' ],
[ 't', 'skeleton' ],
[ 't', 'no-preamble' ],
[ 't', 'empty' ],
[ 'd', 'skeleton-document-without-preamble' ],
[ 'title', 'Skeleton Document without Preamble' ],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-1'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-2'
],
[
'a',
'30041:test-pubkey:skeleton-document-without-preamble-empty-section-3'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card format
Parsed AsciiDoc: {
metadata: { title: 'Test Index Card', version: 'Version' },
content: '= Test Index Card\nindex card',
sections: []
}
Creating index card format (no sections)
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Index Card Format > should build 30040 event set for index card with metadata
Parsed AsciiDoc: {
metadata: {
title: 'Test Index Card with Metadata',
version: 'Version',
summary: 'This is an index card with metadata',
tags: [ 'index', 'card', 'metadata' ]
},
content: '= Test Index Card with Metadata\n' +
':summary: This is an index card with metadata\n' +
':keywords: index, card, metadata\n' +
'index card',
sections: []
}
Index event: {
documentTitle: 'Test Index Card with Metadata',
indexDTag: 'test-index-card-with-metadata'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'index-card' ],
[ 'title', 'Test Index Card with Metadata' ],
[ 'version', 'Version' ],
[ 'summary', 'This is an index card with metadata' ],
[ 't', 'index' ],
[ 't', 'card' ],
[ 't', 'metadata' ],
[ 'd', 'test-index-card-with-metadata' ],
[ 'title', 'Test Index Card with Metadata' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Complex Metadata Structures > should handle complex metadata with all attribute types
Parsed AsciiDoc: {
metadata: {
title: 'Complex Metadata Document',
authors: [
'Jane Smith',
'Override Author',
'Third Author',
'Section Author',
'Section Co-Author'
],
version: '2.0',
publicationDate: '2024-03-01',
summary: 'This is a complex document with all metadata types Alternative description field',
publishedBy: 'Alexandria Complex',
type: 'book',
coverImage: 'https://example.com/cover.jpg',
isbn: '978-0-123456-78-9',
source: 'https://github.com/alexandria/complex',
autoUpdate: 'yes',
tags: [
'additional',
'tags',
'here',
'complex',
'metadata',
'all-types'
]
},
content: '= Complex Metadata Document\n' +
'Jane Smith <jane@example.com>\n' +
'2.0, 2024-02-20, Alexandria Complex\n' +
':summary: This is a complex document with all metadata types\n' +
':description: Alternative description field\n' +
':keywords: complex, metadata, all-types\n' +
':tags: additional, tags, here\n' +
':author: Override Author\n' +
':author: Third Author\n' +
':version: 3.0\n' +
':published_on: 2024-03-01\n' +
':published_by: Alexandria Complex\n' +
':type: book\n' +
':image: https://example.com/cover.jpg\n' +
':isbn: 978-0-123456-78-9\n' +
':source: https://github.com/alexandria/complex\n' +
':auto-update: yes\n' +
'\n' +
'This is the preamble content.\n' +
'\n' +
'== Section with Complex Metadata\n' +
':author: Section Author\n' +
':author: Section Co-Author\n' +
':summary: This section has complex metadata\n' +
':description: Alternative description for section\n' +
':keywords: section, complex, metadata\n' +
':tags: section, tags\n' +
':type: chapter\n' +
':image: https://example.com/section-image.jpg\n' +
'\n' +
'This is the section content.',
sections: [
{
metadata: [Object],
content: 'This is the section content.',
title: 'Section with Complex Metadata'
}
]
}
Index event: {
documentTitle: 'Complex Metadata Document',
indexDTag: 'complex-metadata-document'
}
Creating section 0: {
title: 'Section with Complex Metadata',
dTag: 'complex-metadata-document-section-with-complex-metadata',
content: 'This is the section content.',
metadata: {
title: 'Section with Complex Metadata',
authors: [ 'Section Author', 'Section Co-Author' ],
summary: 'This section has complex metadata Alternative description for section',
type: 'chapter',
coverImage: 'https://example.com/section-image.jpg',
tags: [ 'section', 'tags', 'complex', 'metadata' ]
}
}
A tags: [
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'type', 'complex' ],
[ 'title', 'Complex Metadata Document' ],
[ 'author', 'Jane Smith' ],
[ 'author', 'Override Author' ],
[ 'author', 'Third Author' ],
[ 'author', 'Section Author' ],
[ 'author', 'Section Co-Author' ],
[ 'version', '2.0' ],
[ 'published_on', '2024-03-01' ],
[ 'published_by', 'Alexandria Complex' ],
[
'summary',
'This is a complex document with all metadata types Alternative description field'
],
[ 'image', 'https://example.com/cover.jpg' ],
[ 'i', '978-0-123456-78-9' ],
[ 'source', 'https://github.com/alexandria/complex' ],
[ 'type', 'book' ],
[ 'auto-update', 'yes' ],
[ 't', 'additional' ],
[ 't', 'tags' ],
[ 't', 'here' ],
[ 't', 'complex' ],
[ 't', 'metadata' ],
[ 't', 'all-types' ],
[ 'd', 'complex-metadata-document' ],
[ 'title', 'Complex Metadata Document' ],
[
'a',
'30041:test-pubkey:complex-metadata-document-section-with-complex-metadata'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with only title and no sections
Parsed AsciiDoc: {
metadata: {
title: 'Document with No Sections',
version: 'Version',
summary: 'This document has no sections'
},
content: '= Document with No Sections\n' +
':summary: This document has no sections\n' +
'\n' +
'This is just preamble content.',
sections: []
}
Index event: {
documentTitle: 'Document with No Sections',
indexDTag: 'document-with-no-sections'
}
A tags: []
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with No Sections' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has no sections' ],
[ 'd', 'document-with-no-sections' ],
[ 'title', 'Document with No Sections' ]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with special characters in title
Parsed AsciiDoc: {
metadata: {
title: 'Document with Special Characters: Test & More!',
version: 'Version',
summary: 'This document has special characters in the title'
},
content: '= Document with Special Characters: Test & More!\n' +
':summary: This document has special characters in the title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'Document with Special Characters: Test & More!',
indexDTag: 'document-with-special-characters-test-more'
}
Creating section 0: {
title: 'Section 1',
dTag: 'document-with-special-characters-test-more-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[ 'title', 'Document with Special Characters: Test & More!' ],
[ 'version', 'Version' ],
[ 'summary', 'This document has special characters in the title' ],
[ 'd', 'document-with-special-characters-test-more' ],
[ 'title', 'Document with Special Characters: Test & More!' ],
[
'a',
'30041:test-pubkey:document-with-special-characters-test-more-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
stdout | tests/unit/eventInput30040.test.ts > EventInput 30040 Publishing > Edge Cases > should handle document with very long title
Parsed AsciiDoc: {
metadata: {
title: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
version: 'Version',
summary: 'This document has a very long title'
},
content: '= This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality\n' +
':summary: This document has a very long title\n' +
'\n' +
'== Section 1\n' +
'\n' +
'Content here.',
sections: [
{
metadata: [Object],
content: 'Content here.',
title: 'Section 1'
}
]
}
Index event: {
documentTitle: 'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality',
indexDTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
}
Creating section 0: {
title: 'Section 1',
dTag: 'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1',
content: 'Content here.',
metadata: { title: 'Section 1' }
}
A tags: [
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
]
Final index event: {
kind: 30040,
content: '',
tags: [
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[ 'version', 'Version' ],
[ 'summary', 'This document has a very long title' ],
[
'd',
'this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality'
],
[
'title',
'This is a very long document title that should be handled properly by the system and should not cause any issues with the d-tag generation or any other functionality'
],
[
'a',
'30041:test-pubkey:this-is-a-very-long-document-title-that-should-be-handled-properly-by-the-system-and-should-not-cause-any-issues-with-the-d-tag-generation-or-any-other-functionality-section-1'
]
],
pubkey: 'test-pubkey',
created_at: 1234567890,
id: 'mock-event-id',
sig: 'mock-signature'
}
=== build30040EventSet completed ===
✓ tests/unit/eventInput30040.test.ts (14 tests) 517ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > extractDocumentMetadata should extract document metadata correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:44:30
42|
43| expect(metadata.title).toBe("Test Document with Metadata");
44| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
45| expect(metadata.version).toBe("1.0");
46| expect(metadata.publicationDate).toBe("2024-01-15");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL tests/unit/metadataExtraction.test.ts > AsciiDoc Metadata Extraction > Smart metadata extraction > should handle document with full header correctly
AssertionError: expected [ 'John Doe', 'Jane Smith', …(1) ] to deeply equal [ 'John Doe', 'Jane Smith' ]
- Expected
+ Received
 [
 "John Doe",
 "Jane Smith",
+ "Section Author",
 ]
❯ tests/unit/metadataExtraction.test.ts:318:32
316| // Should extract document-level metadata
317| expect(metadata.title).toBe("Test Document");
318| expect(metadata.authors).toEqual(["John Doe", "Jane Smith"]);
| ^
319| expect(metadata.version).toBe("1.0");
320| expect(metadata.publishedBy).toBe("Alexandria Test");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 1 failed | 1 passed (2)
Tests 2 failed | 28 passed (30)
Start at 13:21:50
Duration 1.36s
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit