|
81 | 81 | ->toContain('View Previous Exceptions'); |
82 | 82 | }); |
83 | 83 |
|
| 84 | +test('comment template has stack trace details as siblings not nested', function () { |
| 85 | + $template = $this->stubLoader->load('comment'); |
| 86 | + |
| 87 | + // Verify in the raw template that the stacktrace section contains exactly 2 sibling |
| 88 | + // <details> blocks (Stack Trace + View Complete Stack Trace), not nested ones. |
| 89 | + $stackTraceStart = strpos($template, '<!-- stacktrace:start -->'); |
| 90 | + $stackTraceEnd = strpos($template, '<!-- stacktrace:end -->'); |
| 91 | + |
| 92 | + expect($stackTraceStart)->not->toBeFalse(); |
| 93 | + expect($stackTraceEnd)->not->toBeFalse(); |
| 94 | + |
| 95 | + $stackTraceSection = substr($template, $stackTraceStart, $stackTraceEnd - $stackTraceStart + strlen('<!-- stacktrace:end -->')); |
| 96 | + |
| 97 | + // Count details tags in the stacktrace section - should be 2 sibling blocks |
| 98 | + preg_match_all('/<details>/', $stackTraceSection, $openTags); |
| 99 | + preg_match_all('/<\/details>/', $stackTraceSection, $closeTags); |
| 100 | + |
| 101 | + expect(count($openTags[0]))->toBe(2) |
| 102 | + ->and(count($closeTags[0]))->toBe(2); |
| 103 | + |
| 104 | + // The first </details> should appear BEFORE the second <details>, |
| 105 | + // proving they are siblings, not nested. |
| 106 | + $firstClose = strpos($stackTraceSection, '</details>'); |
| 107 | + $secondOpen = strpos($stackTraceSection, '<details>', strpos($stackTraceSection, '<details>') + 1); |
| 108 | + expect($firstClose)->toBeLessThan($secondOpen); |
| 109 | + |
| 110 | + // Verify previous exceptions section is outside the stacktrace markers |
| 111 | + $prevStart = strpos($template, '<!-- prev-stacktrace:start -->'); |
| 112 | + expect($prevStart)->toBeGreaterThan($stackTraceEnd); |
| 113 | +}); |
| 114 | + |
84 | 115 | test('it cleans all empty sections', function () { |
85 | 116 | $record = createLogRecord(''); |
86 | 117 |
|
|
0 commit comments