refactor(tests): group test files by feature, drop phase/cluster naming
Restructures the integration test layout so each file is named after
what it covers, not the implementation phase it landed in.
nuwiki-core (renames only):
vimwiki_lexer → lexer
vimwiki_parser → parser
vimwiki_tags → tags
vimwiki_table_alignment → table_alignment
diary_period → diary
list_continuation → lists
transclusion_attrs → transclusion
+ table colspan/rowspan tests moved here from parity_cluster_1
nuwiki-lsp (renames + merges + one split):
cluster_a_list_rewriters → commands_lists
cluster_b_table_rewriters → commands_tables
cluster_c_link_helpers +
phase19_followlink_creates → commands_links
phase13_rename_commands → commands_files
phase17_colorize → commands_colorize
phase17_html_export → html_export
phase15_link_health → link_health
phase18_multi_wiki → multi_wiki
phase19_folding → folding
nav → navigation
lsp_helpers → helpers
phase16_diary +
diary_frequency → diary
phase11_plumbing +
parity_cluster_1 (config) → index_and_config
tags_index_and_lsp +
phase17_backfill → commands_tags
phase14_edit_commands → split into
commands_checkboxes,
commands_headings,
commands_tasks
Net: 30 → 28 integration-test files. 456 → 455 tests (the one
removed test was a dummy `paragraph_render_is_unchanged` whose only
purpose was to keep a `ParagraphNode` import alive in
parity_cluster_1; the import is exercised elsewhere now).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
//! Cluster 8 — transclusion attribute parsing. The basic
|
||||
//! `{{url|alt|key=val}}` shape was already wired; this test pins
|
||||
//! down quote-stripping on quoted values (`key="quoted value"`)
|
||||
//! so an HTML renderer doesn't double-emit `"` artefacts.
|
||||
|
||||
use nuwiki_core::ast::{BlockNode, InlineNode};
|
||||
use nuwiki_core::render::{HtmlRenderer, Renderer};
|
||||
use nuwiki_core::syntax::vimwiki::VimwikiSyntax;
|
||||
use nuwiki_core::syntax::SyntaxPlugin;
|
||||
|
||||
fn parse(src: &str) -> nuwiki_core::ast::DocumentNode {
|
||||
VimwikiSyntax::new().parse(src)
|
||||
}
|
||||
|
||||
fn first_transclusion(doc: &nuwiki_core::ast::DocumentNode) -> &nuwiki_core::ast::TransclusionNode {
|
||||
let para = match &doc.children[0] {
|
||||
BlockNode::Paragraph(p) => p,
|
||||
_ => panic!("expected paragraph"),
|
||||
};
|
||||
for child in ¶.children {
|
||||
if let InlineNode::Transclusion(t) = child {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
panic!("no transclusion in paragraph");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transclusion_attrs_strip_double_quotes() {
|
||||
let doc = parse(r#"{{cat.png|cat|style="border: 1px"}}"#);
|
||||
let t = first_transclusion(&doc);
|
||||
assert_eq!(t.url, "cat.png");
|
||||
assert_eq!(t.alt.as_deref(), Some("cat"));
|
||||
assert_eq!(
|
||||
t.attrs.get("style").map(String::as_str),
|
||||
Some("border: 1px")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transclusion_attrs_strip_single_quotes() {
|
||||
let doc = parse("{{cat.png|cat|class='thumb'}}");
|
||||
let t = first_transclusion(&doc);
|
||||
assert_eq!(t.attrs.get("class").map(String::as_str), Some("thumb"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transclusion_attrs_leave_unquoted_values_alone() {
|
||||
let doc = parse("{{cat.png|cat|width=200}}");
|
||||
let t = first_transclusion(&doc);
|
||||
assert_eq!(t.attrs.get("width").map(String::as_str), Some("200"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transclusion_renders_clean_html_with_quoted_attr() {
|
||||
let doc = parse(r#"{{cat.png|cat|style="border: 1px"}}"#);
|
||||
let out = HtmlRenderer::new().render_to_string(&doc).unwrap();
|
||||
assert!(out.contains(r#"style="border: 1px""#), "got: {out}");
|
||||
assert!(!out.contains("""));
|
||||
}
|
||||
Reference in New Issue
Block a user