feat: Add test helper for E2E staking flow (#66)
Implements window.__testHelpers.fillStakeForm() to enable stable E2E testing of the staking form without fragile UI selectors. ## Changes - Add window.__testHelpers interface (dev mode only) - Implement fillStakeForm() in StakeHolder.vue with input validation - Add TypeScript declarations in env.d.ts - Update E2E test to use helper and verify full user journey - Create INTEGRATION_TEST_STATUS.md documenting test coverage - Document helper in web-app/README.md ## Test Coverage Playwright E2E now validates complete flow: - Mint ETH via cheats page UI - Swap KRK via cheats page UI - Stake KRK via stake page UI (helper + click) - Verify position via GraphQL Both Playwright and verify-swap.sh tests now work independently. resolves #62 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/66
This commit is contained in:
parent
b1f40374cd
commit
8cd64e808f
5 changed files with 272 additions and 2 deletions
|
|
@ -208,6 +208,37 @@ function setMaxAmount() {
|
|||
}
|
||||
|
||||
const snatchSelection = useSnatchSelection(demo, taxRate);
|
||||
|
||||
// Test helper - only available in dev mode
|
||||
if (import.meta.env.DEV) {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__testHelpers = {
|
||||
fillStakeForm: async (params: { amount: number; taxRate: number }) => {
|
||||
// Validate inputs
|
||||
const minStakeNum = bigInt2Number(minStake.value, 18);
|
||||
if (params.amount < minStakeNum) {
|
||||
throw new Error(`Stake amount ${params.amount} is below minimum ${minStakeNum}`);
|
||||
}
|
||||
|
||||
const maxStakeNum = maxStakeAmount.value;
|
||||
if (params.amount > maxStakeNum) {
|
||||
throw new Error(`Stake amount ${params.amount} exceeds balance ${maxStakeNum}`);
|
||||
}
|
||||
|
||||
if (params.taxRate <= 0 || params.taxRate > 100) {
|
||||
throw new Error(`Tax rate ${params.taxRate} must be between 0 and 100`);
|
||||
}
|
||||
|
||||
// Fill the form
|
||||
stake.stakingAmountNumber = params.amount;
|
||||
taxRate.value = params.taxRate;
|
||||
|
||||
// Wait for reactive updates
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="sass">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue