reworked stack
This commit is contained in:
parent
6cbb1781ce
commit
f7ef56f65f
12 changed files with 853 additions and 458 deletions
|
|
@ -1,13 +1,16 @@
|
|||
import { expect, test, type APIRequestContext } from '@playwright/test';
|
||||
import { Wallet } from 'ethers';
|
||||
import { createWalletContext } from '../setup/wallet-provider';
|
||||
import { startStack, waitForStackReady, stopStack } from '../setup/stack';
|
||||
import { getStackConfig, validateStackHealthy } from '../setup/stack';
|
||||
|
||||
const ACCOUNT_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
|
||||
const ACCOUNT_ADDRESS = new Wallet(ACCOUNT_PRIVATE_KEY).address.toLowerCase();
|
||||
const STACK_RPC_URL = process.env.STACK_RPC_URL ?? 'http://127.0.0.1:8545';
|
||||
const STACK_WEBAPP_URL = process.env.STACK_WEBAPP_URL ?? 'http://localhost:5173';
|
||||
const STACK_GRAPHQL_URL = process.env.STACK_GRAPHQL_URL ?? 'http://localhost:42069/graphql';
|
||||
|
||||
// Get stack configuration from environment (or defaults)
|
||||
const STACK_CONFIG = getStackConfig();
|
||||
const STACK_RPC_URL = STACK_CONFIG.rpcUrl;
|
||||
const STACK_WEBAPP_URL = STACK_CONFIG.webAppUrl;
|
||||
const STACK_GRAPHQL_URL = STACK_CONFIG.graphqlUrl;
|
||||
|
||||
async function fetchPositions(request: APIRequestContext, owner: string) {
|
||||
const response = await request.post(STACK_GRAPHQL_URL, {
|
||||
|
|
@ -42,17 +45,10 @@ async function fetchPositions(request: APIRequestContext, owner: string) {
|
|||
}
|
||||
|
||||
test.describe('Acquire & Stake', () => {
|
||||
// Validate that a healthy stack exists before running tests
|
||||
// Tests do NOT start their own stack - stack must be running already
|
||||
test.beforeAll(async () => {
|
||||
await startStack();
|
||||
await waitForStackReady({
|
||||
rpcUrl: STACK_RPC_URL,
|
||||
webAppUrl: STACK_WEBAPP_URL,
|
||||
graphqlUrl: STACK_GRAPHQL_URL,
|
||||
});
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
await stopStack();
|
||||
await validateStackHealthy(STACK_CONFIG);
|
||||
});
|
||||
|
||||
test('users can swap KRK via UI', async ({ browser, request }) => {
|
||||
|
|
@ -153,22 +149,30 @@ test.describe('Acquire & Stake', () => {
|
|||
|
||||
// Wait for the stake form to be initialized
|
||||
console.log('[TEST] Waiting for stake form to load...');
|
||||
await page.waitForSelector('text=Token Amount', { timeout: 15_000 });
|
||||
const tokenAmountSlider = page.getByRole('slider', { name: 'Token Amount' });
|
||||
await expect(tokenAmountSlider).toBeVisible({ timeout: 15_000 });
|
||||
|
||||
// Use the test helper to fill the stake form
|
||||
console.log('[TEST] Filling stake form via test helper...');
|
||||
await page.evaluate(async () => {
|
||||
if (!window.__testHelpers) {
|
||||
throw new Error('Test helpers not available');
|
||||
}
|
||||
await window.__testHelpers.fillStakeForm({
|
||||
amount: 100, // Stake 100 KRK
|
||||
taxRateIndex: 2, // 5% tax rate option
|
||||
});
|
||||
});
|
||||
console.log('[TEST] Filling stake form via accessible controls...');
|
||||
|
||||
// Take screenshot before interaction
|
||||
await page.screenshot({ path: 'test-results/before-stake-fill.png' });
|
||||
|
||||
// Check if input is visible and enabled
|
||||
const stakeAmountInput = page.getByLabel('Staking Amount');
|
||||
console.log('[TEST] Checking if staking amount input is visible...');
|
||||
await expect(stakeAmountInput).toBeVisible({ timeout: 10_000 });
|
||||
console.log('[TEST] Staking amount input is visible, filling value...');
|
||||
await stakeAmountInput.fill('100');
|
||||
console.log('[TEST] Filled staking amount!');
|
||||
|
||||
const taxSelect = page.getByRole('combobox', { name: 'Tax' });
|
||||
console.log('[TEST] Selecting tax rate...');
|
||||
await taxSelect.selectOption({ value: '2' });
|
||||
console.log('[TEST] Tax rate selected!');
|
||||
|
||||
console.log('[TEST] Clicking stake button...');
|
||||
const stakeButton = page.getByRole('button', { name: /Stake|Snatch and Stake/i });
|
||||
// Use the main form's submit button (large/block), not the small position card buttons
|
||||
const stakeButton = page.getByRole('main').getByRole('button', { name: /Stake|Snatch and Stake/i });
|
||||
await expect(stakeButton).toBeVisible({ timeout: 5_000 });
|
||||
await stakeButton.click();
|
||||
|
||||
|
|
@ -190,7 +194,7 @@ test.describe('Acquire & Stake', () => {
|
|||
console.log(`[TEST] Found ${positions.length} position(s)`);
|
||||
|
||||
expect(positions.length).toBeGreaterThan(0);
|
||||
const activePositions = positions.filter(p => p.status === 'OPEN');
|
||||
const activePositions = positions.filter(p => p.status === 'Active');
|
||||
expect(activePositions.length).toBeGreaterThan(0);
|
||||
|
||||
console.log(`[TEST] ✅ Staking successful! Created ${activePositions.length} active position(s)`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue