Merge pull request 'fix: Dozens of bare waitForTimeout() calls remain throughout e2e tests (#418)' (#496) from fix/issue-418 into master
This commit is contained in:
commit
5bea99ddf4
1 changed files with 11 additions and 29 deletions
|
|
@ -143,43 +143,31 @@ export async function connectWallet(page: Page): Promise<void> {
|
|||
const navbarTitle = page.locator('.navbar-title').first();
|
||||
await navbarTitle.waitFor({ state: 'visible', timeout: 60_000 });
|
||||
|
||||
// Trigger resize event for mobile detection
|
||||
// Trigger resize event for mobile detection; connectButton.isVisible below waits for layout
|
||||
await page.evaluate(() => {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Give time for wallet connectors to initialize
|
||||
await page.waitForTimeout(2_000);
|
||||
|
||||
|
||||
// Try desktop Connect button first
|
||||
const connectButton = page.locator('.connect-button--disconnected').first();
|
||||
|
||||
if (await connectButton.isVisible({ timeout: 5_000 })) {
|
||||
console.log('[HELPER] Found desktop Connect button');
|
||||
await connectButton.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
// Click the first wallet connector
|
||||
// Wait for the connector panel to open — .connectors-element appearing is the observable event
|
||||
const injectedConnector = page.locator('.connectors-element').first();
|
||||
if (await injectedConnector.isVisible({ timeout: 5_000 })) {
|
||||
console.log('[HELPER] Clicking wallet connector...');
|
||||
await injectedConnector.click();
|
||||
await page.waitForTimeout(2_000);
|
||||
}
|
||||
await injectedConnector.waitFor({ state: 'visible', timeout: 10_000 });
|
||||
console.log('[HELPER] Clicking wallet connector...');
|
||||
await injectedConnector.click();
|
||||
} else {
|
||||
// Try mobile fallback
|
||||
const mobileLoginIcon = page.locator('.navbar-end svg').first();
|
||||
if (await mobileLoginIcon.isVisible({ timeout: 2_000 })) {
|
||||
console.log('[HELPER] Using mobile login icon');
|
||||
await mobileLoginIcon.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
|
||||
const injectedConnector = page.locator('.connectors-element').first();
|
||||
if (await injectedConnector.isVisible({ timeout: 5_000 })) {
|
||||
await injectedConnector.click();
|
||||
await page.waitForTimeout(2_000);
|
||||
}
|
||||
await injectedConnector.waitFor({ state: 'visible', timeout: 10_000 });
|
||||
await injectedConnector.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,10 +501,7 @@ export async function attemptStake(
|
|||
|
||||
const baseUrl = page.url().split('#')[0];
|
||||
await page.goto(`${baseUrl}stake`);
|
||||
|
||||
// Wait longer for page to load and stats to initialize
|
||||
await page.waitForTimeout(3_000);
|
||||
|
||||
|
||||
try {
|
||||
// Wait for stake form to fully load
|
||||
const tokenAmountSlider = page.getByRole('slider', { name: 'Token Amount' });
|
||||
|
|
@ -542,13 +527,11 @@ export async function attemptStake(
|
|||
const stakeAmountInput = page.getByLabel('Staking Amount');
|
||||
await stakeAmountInput.waitFor({ state: 'visible', timeout: 10_000 });
|
||||
await stakeAmountInput.fill(amount);
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
|
||||
// Select tax rate
|
||||
const taxSelect = page.getByRole('combobox', { name: 'Tax' });
|
||||
await taxSelect.selectOption({ value: taxRateIndex });
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
|
||||
// Take screenshot before attempting to click
|
||||
const screenshotDir = join('test-results', 'usertest', personaName.toLowerCase().replace(/\s+/g, '-'));
|
||||
mkdirSync(screenshotDir, { recursive: true });
|
||||
|
|
@ -612,7 +595,6 @@ export async function attemptStake(
|
|||
// May complete instantly
|
||||
}
|
||||
|
||||
await page.waitForTimeout(3_000);
|
||||
recordAction(`Stake ${amount} KRK at ${taxRateIndex}% tax`, true, undefined, report);
|
||||
console.log(`[${personaName}] Stake successful`);
|
||||
} catch (error: any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue