Fail when the showcase search skips an example a page renders
Plan step 38 review: the index reads example titles out of each section's source with a regex, which once skipped all six Progress examples without a sound; the existing test only checked that indexed anchors exist. A new test renders every section and canonical layout page and requires the index's examples for it to equal the titled examples the page draws, both ways, so a format the regex misses (or an anchor it invents) fails by page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Opus 5
parent
79ca9a28b4
commit
5fb8fc6b8f
@@ -90,6 +90,33 @@ it('indexes every section, example and component for the search, each linking to
|
||||
});
|
||||
});
|
||||
|
||||
it('indexes exactly the examples each page renders, so an example the index misses fails here', function () {
|
||||
$index = collect($this->getJson('/material/search.json')->assertOk()->json())->where('kind', 'Example');
|
||||
$pages = collect(Sections::all())->keys()->map(fn (string $key): string => route('livewire-material.section', $key, false))
|
||||
->merge(collect(Sections::layoutPages())->except('layout')->pluck('url'));
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$html = $this->withoutVite()->get($page)->assertOk()->getContent();
|
||||
|
||||
preg_match_all('/<[a-z]+\b[^>]*\bdata-md-showcase-example\b[^>]*>/', $html, $tags);
|
||||
|
||||
$rendered = collect($tags[0])
|
||||
->map(fn (string $tag): ?string => preg_match('/\bid="([^"]+)"/', $tag, $id) === 1 ? $id[1] : null)
|
||||
->filter()
|
||||
->sort()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$indexed = $index->filter(fn (array $entry): bool => strtok($entry['url'], '#') === $page)
|
||||
->map(fn (array $entry): string => substr($entry['url'], strpos($entry['url'], '#') + 1))
|
||||
->sort()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
expect($indexed)->toBe($rendered, "{$page}: the search index and the page disagree on its examples");
|
||||
}
|
||||
});
|
||||
|
||||
it('does not mount the showcase when disabled', function () {
|
||||
rebootWithShowcase(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user