-
Notifications
You must be signed in to change notification settings - Fork 134
fix(action-card): make action card focusable and keyboard activatable #2598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5aa12a3
ff31bd9
d4e88e8
f1ad162
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2024 Siemens AG | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| import { expect } from '@playwright/test'; | ||
| import { regressionTest } from '@utils/test'; | ||
|
|
||
| regressionTest.describe('accessibility', () => { | ||
| regressionTest('default', async ({ mount, makeAxeBuilder }) => { | ||
| await mount(` | ||
| <ix-action-card | ||
| heading="Scan for new devices" | ||
| subheading="Secondary text" | ||
| ></ix-action-card> | ||
| `); | ||
|
|
||
| const accessibilityScanResults = await makeAxeBuilder().analyze(); | ||
|
|
||
| expect(accessibilityScanResults.violations).toEqual([]); | ||
| }); | ||
|
|
||
| regressionTest('passive', async ({ mount, makeAxeBuilder }) => { | ||
| await mount(` | ||
| <ix-action-card | ||
| heading="Scan for new devices" | ||
| subheading="Secondary text" | ||
| passive | ||
| ></ix-action-card> | ||
| `); | ||
|
|
||
| const accessibilityScanResults = await makeAxeBuilder().analyze(); | ||
|
|
||
| expect(accessibilityScanResults.violations).toEqual([]); | ||
| }); | ||
|
Comment on lines
+13
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Add keyboard behavior regression tests for Enter/Space and passive mode. The PR’s core change is keyboard activatability, but this file does not assert Enter/Space click activation or passive-mode non-activation, so the behavior can regress undetected. ⌨️ Proposed behavior tests+regressionTest('keyboard activates on Enter and Space', async ({ mount, page }) => {
+ await mount(`
+ <ix-action-card heading="Scan for new devices" subheading="Secondary text"></ix-action-card>
+ `);
+
+ const host = page.locator('ix-action-card');
+ await expect(host).toHaveClass(/\bhydrated\b/);
+
+ const button = page.getByRole('button');
+ await button.focus();
+
+ const clickSpy = page.waitForEvent('console'); // replace with component click-event listener helper used in this repo
+ await page.keyboard.press('Enter');
+ await page.keyboard.press('Space');
+ await clickSpy;
+});
+
+regressionTest('passive is not keyboard-focusable', async ({ mount, page }) => {
+ await mount(`
+ <ix-action-card heading="Scan for new devices" subheading="Secondary text" passive></ix-action-card>
+ `);
+
+ await expect(page.locator('ix-action-card')).toHaveClass(/\bhydrated\b/);
+ await expect(page.getByRole('button')).toHaveAttribute('tabindex', '-1');
+});As per coding guidelines, “Follow this test order within each file … 4. Behavior tests (user interactions, state changes).” 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| }); | ||
|
Comment on lines
+12
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Add the required This file currently runs axe scans only. It is missing the mandatory ✅ Proposed test additions regressionTest.describe('accessibility', () => {
regressionTest('default', async ({ mount, makeAxeBuilder, page }) => {
await mount(`
<ix-action-card
heading="Scan for new devices"
subheading="Secondary text"
></ix-action-card>
`);
+ await expect(page.locator('ix-action-card')).toHaveClass(/\bhydrated\b/);
+
const accessibilityScanResults = await makeAxeBuilder().analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
@@
await mount(`
<ix-action-card
heading="Scan for new devices"
subheading="Secondary text"
passive
></ix-action-card>
`);
+ await expect(page.locator('ix-action-card')).toHaveClass(/\bhydrated\b/);
+
const accessibilityScanResults = await makeAxeBuilder().analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
+
+ regressionTest('renders', async ({ mount, page }) => {
+ await mount(`
+ <ix-action-card
+ heading="Scan for new devices"
+ subheading="Secondary text"
+ ></ix-action-card>
+ `);
+
+ await expect(page.locator('ix-action-card')).toHaveClass(/\bhydrated\b/);
+ await expect(page.getByRole('button')).toBeVisible();
+ });
});As per coding guidelines, “Every test file should include a 'renders' test verifying basic hydration” and “Always verify components are hydrated before making further assertions … 🤖 Prompt for AI AgentsSources: Coding guidelines, Path instructions |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Passive-state CSS selectors won’t match the component’s passive attribute.
Line 44 and Line 49 target
:host(.passive), but the passive state is used as an attribute (passive), so these branches won’t apply reliably and passive styling/interaction gating can regress.🔧 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents