Skip to content

Commit fa10b37

Browse files
committed
test: add real SEC EDGAR 8-K filings and comprehensive tests
- Download 15 real 8-K filings from Apple, Microsoft, Amazon, Tesla, Meta, and Alphabet covering diverse item types (1.01, 2.02, 5.02, 5.03, 5.07, 7.01, 8.01, 9.01) - Replace synthetic XML mock data with real SEC EDGAR HTML/XHTML filings - Fix parser detection: use regex for edgarSubmission root element instead of <?xml prefix (XHTML inline XBRL files also start with <?xml) - Add 31 comprehensive tests: parsing all files, storage with filing metadata, item type coverage, cross-entity querying, amendment handling, edge cases (null/empty items, semicolons, deduplication, unknown items), XML signature processing, Form_8_K_ITEMS validation - Total: 470 tests pass across 45 files https://claude.ai/code/session_01SKG4qTyjPAtmuSipiEiAio
1 parent 1c658cd commit fa10b37

21 files changed

Lines changed: 6654 additions & 251 deletions

src/sec/forms/miscellaneous-filings/Form_8_K.test.ts

Lines changed: 818 additions & 153 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/Form_8_K.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@ export class Form_8_K extends Form {
1818
throw new Error(`Invalid form: ${form}`);
1919
}
2020

21-
// 8-K primary documents can be HTML (most common) or structured XML.
22-
// Detect XML vs HTML by checking for an XML declaration or edgarSubmission root.
23-
const trimmed = xml.trimStart();
24-
const isXml =
25-
trimmed.startsWith("<?xml") ||
26-
trimmed.startsWith("<edgarSubmission") ||
27-
trimmed.startsWith("<EDGARSUBMISSION");
21+
// 8-K primary documents can be HTML/XHTML (most common) or structured XML
22+
// with an edgarSubmission root element. Many HTML files start with <?xml>
23+
// (inline XBRL), so we must check for the actual root element.
24+
const hasEdgarSubmission = /\bedgarSubmission\b/i.test(xml.slice(0, 500));
2825

29-
if (isXml) {
26+
if (hasEdgarSubmission) {
3027
const parser = Form_8_K.getParser(Form8KSubmissionSchema);
3128
const json = parser.parse(xml) as Form8KSubmission;
3229
return json.edgarSubmission;
3330
}
3431

35-
// For HTML primary documents, return a minimal result.
32+
// For HTML/XHTML primary documents, return a minimal result.
3633
// Structured data (items, dates) is obtained from the filing index metadata.
3734
return {};
3835
}

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000032019325000007-primary_doc.htm

Lines changed: 8 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000101872426000002-primary_doc.htm

Lines changed: 8 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000110465925108507-primary_doc.htm

Lines changed: 807 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000110465926021050-primary_doc.htm

Lines changed: 508 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000114036124038403-primary_doc.htm

Lines changed: 789 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000114036124040659-primary_doc.htm

Lines changed: 634 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000114036125005876-primary_doc.htm

Lines changed: 1320 additions & 0 deletions
Large diffs are not rendered by default.

src/sec/forms/miscellaneous-filings/mock_data/form-8k/000114036125018400-primary_doc.htm

Lines changed: 782 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)