reworked stack

This commit is contained in:
johba 2025-10-07 21:57:32 +00:00
parent 6cbb1781ce
commit f7ef56f65f
12 changed files with 853 additions and 458 deletions

View file

@ -34,52 +34,15 @@ npm run build
## Testing
### Test Helpers
### Accessibility Hooks
The application exposes test helpers on `window.__testHelpers` in development mode to facilitate E2E testing.
The staking form now exposes semantic controls that Playwright can exercise directly:
#### Available Helpers
- Slider: `page.getByRole('slider', { name: 'Token Amount' })`
- Amount input: `page.getByLabel('Staking Amount')`
- Tax selector: `page.getByLabel('Tax')`
##### `fillStakeForm(params)`
Programmatically fills the staking form without requiring fragile UI selectors.
**Parameters:**
- `amount` (number): Amount of KRK tokens to stake (must be >= minimum stake)
- `taxRateIndex` (number): Index of the tax rate option (must match one of the configured options)
**Example:**
```typescript
// In Playwright test
await page.evaluate(async () => {
await window.__testHelpers.fillStakeForm({
amount: 100,
taxRateIndex: 2,
});
});
// Then click the stake button
const stakeButton = page.getByRole('button', { name: /Stake|Snatch and Stake/i });
await stakeButton.click();
```
**Validation:**
- Throws if amount is below minimum stake
- Throws if amount exceeds wallet balance
- Throws if `taxRateIndex` does not match an available option
**TypeScript Support:**
Type declarations are available in `env.d.ts`:
```typescript
interface Window {
__testHelpers?: {
fillStakeForm: (params: { amount: number; taxRateIndex: number }) => Promise<void>;
};
}
```
**Security:**
Test helpers are only available when `import.meta.env.DEV === true` and are automatically stripped from production builds.
Tests should rely on these roles and labels instead of private helpers.
### E2E Tests