-
Notifications
You must be signed in to change notification settings - Fork 53
Description
PDD-CLI Bug: Assumes Verbose Button Text When UIs Prefer Concise Labels
PDD-CLI generates E2E test selectors expecting verbose, descriptive button text when actual UIs use short, concise labels for space/design reasons.
Why this matters: Tests fail to find buttons because PDD expects "Run Action Now" but button just says "Run".
Concrete Example
For a dashboard with action buttons:
// PDD generated test (WRONG):
test('can run action', async ({ page }) => {
await page.goto('/actions');
// Expects verbose button text
await page.getByRole('button', { name: 'Run Now' }).click();
});But the actual UI uses concise labels:
// ActionsTable.tsx (actual implementation)
export function ActionsTable() {
return (
<table>
<tr>
<td>{action.name}</td>
<td><button onClick={handleRun}>Run</button></td> {/* Short label */}
</tr>
</table>
);
}What went wrong: PDD assumed button would say "Run Now" (more descriptive) but UI designers chose "Run" (more concise).
Impact: Test fails with locator.getByRole('button', { name: 'Run Now' }) not found.
Why PDD Makes This Mistake
PDD-CLI currently:
- Generates "obvious" button labels based on action descriptions
- Assumes verbose text improves clarity
- Doesn't consider UI design constraints (space, visual hierarchy)
But it should:
- Parse actual button text from generated components
- Prefer data-testid for action buttons
- Use flexible matching when generating tests before UI
How to Prevent This in PDD-CLI
What PDD should do differently:
-
Add data-testid to action buttons:
// In component <button data-testid="run-action-btn" onClick={handleRun}> Run </button> // In test page.getByTestId('run-action-btn').click()
-
Parse actual button text: If UI exists, extract real labels instead of assuming.
-
Use partial matching:
getByRole('button', { name: /Run/ })instead of exact match.
Example improvement:
Current: "Run action" → assume button text "Run Now"
→ Generate: getByRole('button', { name: 'Run Now' })
→ Test fails
Improved: "Run action" → generate button with data-testid="run-action-btn"
→ Generate test: getByTestId('run-action-btn')
→ Resilient to text changes
Severity
P2 - Medium Priority
- Frequency: Medium - common for action buttons in tables/lists
- Impact: Test failures requiring manual selector fixes
- Detectability: High - tests fail immediately
- Prevention cost: Low - data-testid generation is simple
Category
test-generation
Related Issues
- Add failing tests for issue #409: Environment Variable Pollution #416 - Exact string matches before seeing UI (same assumption problem)
- Add additional test coverage for PDD tag brace escaping fix #417 - Dynamic UI text not handled (similar text matching issue)
- Bug: Agentic fix doesn't push commits when exiting early at Step 2 #419 - Fragile CSS class selectors (alternative bad selector strategy)
For Contributors: Discovered in frontend/e2e/crm.spec.ts where button text was "Run" not "Run Now", fixed in commit 34a651d5.