Skip to content

Commit f0f3f5a

Browse files
fix(a11y): make the JSON snapshot fallback payload keyboard-focusable and run the history and Mail chip e2e specs against Yii3. (#75)
1 parent 8dcc113 commit f0f3f5a

5 files changed

Lines changed: 47 additions & 8 deletions

File tree

‎e2e/smoke.spec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ for (const [appIndex, app] of debugApps().entries()) {
226226
await expectDebuggerLayout(page, entry, "light");
227227

228228
if (entry.kind === "history") {
229-
await expect(page.locator("tr[data-key]")).toHaveCount(2);
229+
await expect(page.locator("tr[data-yii-debug-tag]")).toHaveCount(2);
230230
}
231231

232232
await expectNoRuntimeDiagnostics(

‎e2e/support/environment.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export function debugPageURL(app, entry, options = {}) {
109109
let path;
110110

111111
if (entry.kind === "history") {
112-
path = "/debug/index";
112+
// Yii2 resolves the module default action at `/debug`; Yii3 serves the history only there.
113+
path = "/debug";
113114
} else if (entry.kind === "compare") {
114115
path = "/debug/compare";
115116
} else if (entry.kind === "phpinfo") {

‎e2e/toolbar-mail.spec.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ for (const app of debugApps()) {
1616
test(`${app.name} Mail chip label opens the capture that sent the mail`, async ({
1717
page,
1818
}) => {
19-
test.skip(
20-
app.id === "yii3",
21-
"Yii3 has no Mail panel until the Phase 5 port.",
22-
);
23-
2419
const diagnostics = collectRuntimeDiagnostics(page);
2520

2621
// Serve the page toolbar from the seeded GET that follows the mail-sending POST; later AJAX loads are untouched.
22+
// Yii2 serves the payload at `toolbar-data`, Yii3 at `toolbar`.
2723
await page.route(
28-
/toolbar-data/,
24+
/toolbar(?:-data)?[?&]/,
2925
(route) => {
3026
const url = new URL(route.request().url());
3127

‎resources/views/snapshot.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
->content('JSON snapshot'),
5555
)
5656
->render();
57+
// The payload scrolls horizontally on narrow viewports, so it takes keyboard focus to stay reachable.
5758
$panelBody = $panelContent ?? Pre::tag()
5859
->class('yii-debug-panel-payload')
60+
->addAttribute('tabindex', '0')
5961
->html(Code::tag()->content($payload))
6062
->render();
6163
?>

‎tests/View/SnapshotViewTest.php‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPForge\Debug\Tests\View;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use PHPUnit\Framework\TestCase;
9+
10+
use function dirname;
11+
use function ob_get_clean;
12+
use function ob_start;
13+
14+
/**
15+
* Unit tests for the JSON fallback of the shared `snapshot.php` panel view.
16+
*/
17+
#[Group('view')]
18+
final class SnapshotViewTest extends TestCase
19+
{
20+
public function testJsonFallbackPayloadIsKeyboardFocusable(): void
21+
{
22+
$failure = null;
23+
$method = 'GET';
24+
$panelContent = null;
25+
$panelLabel = 'router';
26+
$payload = '{&quot;routes&quot;: []}';
27+
$renderError = null;
28+
$url = 'https://example.test/';
29+
30+
ob_start();
31+
require dirname(__DIR__, 2) . '/resources/views/snapshot.php';
32+
$html = (string) ob_get_clean();
33+
34+
self::assertMatchesRegularExpression(
35+
'~<pre\b(?=[^>]*\bclass="yii-debug-panel-payload")(?=[^>]*\btabindex="0")[^>]*>~',
36+
$html,
37+
'The scrollable payload must be reachable by keyboard.',
38+
);
39+
}
40+
}

0 commit comments

Comments
 (0)