fix: getByRole('button', { name: 'Buy' }).last() fragility is duplicated across e2e/01 and this scenario (#398)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-02 23:13:05 +00:00
parent 10643618f7
commit 68601c255a
4 changed files with 11 additions and 11 deletions

View file

@ -80,13 +80,13 @@ export async function buyKrk(page: Page, ethAmount: string): Promise<void> {
await navigateSPA(page, '/app/get-krk');
await expect(page.getByRole('heading', { name: 'Get $KRK Tokens' })).toBeVisible({ timeout: 10_000 });
const swapInput = page.getByLabel('ETH to spend');
const swapInput = page.getByTestId('swap-amount-input');
await expect(swapInput).toBeVisible({ timeout: 15_000 });
await swapInput.fill(ethAmount);
await page.waitForTimeout(500);
const buyButton = page.getByRole('button', { name: 'Buy KRK' });
const buyButton = page.getByTestId('swap-buy-button');
await expect(buyButton).toBeVisible({ timeout: 5_000 });
await page.screenshot({ path: 'test-results/holdout-before-buy.png' });
@ -97,7 +97,7 @@ export async function buyKrk(page: Page, ethAmount: string): Promise<void> {
try {
await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 });
console.log('[swap] Swap in progress...');
await page.getByRole('button', { name: 'Buy KRK' }).waitFor({ state: 'visible', timeout: 60_000 });
await page.getByTestId('swap-buy-button').waitFor({ state: 'visible', timeout: 60_000 });
console.log('[swap] Swap completed');
} catch {
// Swap completed before the Submitting state could be observed