fix: use toHaveText to correctly await swap completion after testId migration

getByTestId('swap-buy-button').waitFor({ state: 'visible' }) resolved
immediately because the button is always rendered; only its text changes.
Replace with expect(...).toHaveText('Buy KRK', { timeout: 60_000 }) to
correctly gate on the button returning to its idle state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-02 23:47:53 +00:00
parent 68601c255a
commit ed5db3b000
3 changed files with 3 additions and 3 deletions

View file

@ -97,7 +97,7 @@ export async function buyKrk(page: Page, ethAmount: string): Promise<void> {
try { try {
await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 }); await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 });
console.log('[swap] Swap in progress...'); console.log('[swap] Swap in progress...');
await page.getByTestId('swap-buy-button').waitFor({ state: 'visible', timeout: 60_000 }); await expect(page.getByTestId('swap-buy-button')).toHaveText('Buy KRK', { timeout: 60_000 });
console.log('[swap] Swap completed'); console.log('[swap] Swap completed');
} catch { } catch {
// Swap completed before the Submitting state could be observed // Swap completed before the Submitting state could be observed

View file

@ -184,7 +184,7 @@ test.describe('Acquire & Stake', () => {
try { try {
await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 }); await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 });
console.log('[TEST] Swap initiated, waiting for completion...'); console.log('[TEST] Swap initiated, waiting for completion...');
await page.getByTestId('swap-buy-button').waitFor({ state: 'visible', timeout: 60_000 }); await expect(page.getByTestId('swap-buy-button')).toHaveText('Buy KRK', { timeout: 60_000 });
console.log('[TEST] Swap completed!'); console.log('[TEST] Swap completed!');
} catch (e) { } catch (e) {
console.log('[TEST] No "Submitting" state detected, swap may have completed instantly'); console.log('[TEST] No "Submitting" state detected, swap may have completed instantly');

View file

@ -193,7 +193,7 @@ test.describe('Max Stake All Tax Rates', () => {
console.log('[TEST] Waiting for swap to process...'); console.log('[TEST] Waiting for swap to process...');
try { try {
await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 }); await page.getByRole('button', { name: /Submitting/i }).waitFor({ state: 'visible', timeout: 5_000 });
await page.getByTestId('swap-buy-button').waitFor({ state: 'visible', timeout: 60_000 }); await expect(page.getByTestId('swap-buy-button')).toHaveText('Buy KRK', { timeout: 60_000 });
console.log('[TEST] Swap completed!'); console.log('[TEST] Swap completed!');
} catch (e) { } catch (e) {
console.log('[TEST] Swap may have completed instantly'); console.log('[TEST] Swap may have completed instantly');