feat: short-form level for every module with a heading title (trial)
contact-form, cta, toggle, accordion-item, slide, number-counter and team-member (name) take level like heading/blurb; paths from Divi's conversion outlines, checked live with divi-shortform-check.php. A test keeps the guide's field table in sync with ShortformMap. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -202,4 +202,41 @@ final class ModuleCatalogTest extends TestCase
|
||||
self::assertSame('richtext', $catalog->pathKind('divi/text', 'content.innerContent'));
|
||||
self::assertIsString($catalog->kinds('divi/text')['content.innerContent']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trial feedback: every short-form module with a heading title offers `level` (Divi's
|
||||
* conversion outlines map header_level/title_level to <title>.decoration.font.font headingLevel).
|
||||
*/
|
||||
public function testModulesWithAHeadingTitleOfferLevel(): void
|
||||
{
|
||||
$expected = [
|
||||
'heading' => 'title', 'blurb' => 'title', 'cta' => 'title', 'toggle' => 'title',
|
||||
'accordion-item' => 'title', 'slide' => 'title', 'contact-form' => 'title',
|
||||
'number-counter' => 'title', 'team-member' => 'name',
|
||||
];
|
||||
foreach ($expected as $type => $element) {
|
||||
$level = ShortformMap::fields($type)['level'] ?? null;
|
||||
self::assertNotNull($level, $type);
|
||||
self::assertSame($element . '.decoration.font.font', $level['path'], $type);
|
||||
self::assertSame('headingLevel', $level['sub'], $type);
|
||||
self::assertSame('level', $level['kind'], $type);
|
||||
}
|
||||
}
|
||||
|
||||
/** The field table of the divi-shortform guide lists every short-form field. */
|
||||
public function testShortformGuideTableListsEveryField(): void
|
||||
{
|
||||
$guide = (string) file_get_contents(dirname(__DIR__, 5) . '/docs/guides/divi-shortform.md');
|
||||
$rows = array_values(array_filter(
|
||||
explode("\n", $guide),
|
||||
static fn (string $line): bool => str_starts_with($line, '| `')
|
||||
));
|
||||
foreach (ShortformMap::types() as $type) {
|
||||
$row = current(array_filter($rows, static fn (string $line): bool => str_contains($line, '`' . $type . '`')));
|
||||
self::assertIsString($row, $type . ' has a row');
|
||||
foreach (array_keys(ShortformMap::fields($type)) as $field) {
|
||||
self::assertStringContainsString('`' . $field . '`', $row, $type . '.' . $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user