Skip to content

Commit fa11eee

Browse files
committed
chore: reduce tests' flakyness.
1 parent a132299 commit fa11eee

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

frontends/web/src/components/amount/amount-with-unit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const AmountUnit = ({ rotateUnit, unit }: TAmountUnitProps) => {
104104
const classRototable = rotateUnit ? (style.rotatable || '') : '';
105105
const textStyle = `${style.unit || ''} ${classRototable}`;
106106
return (
107-
<span id={`amount-unit-${unit}`} className={textStyle} onClick={rotateUnit}>
107+
<span data-testid={`amount-unit-${unit}`} className={textStyle} onClick={rotateUnit}>
108108
{unit}
109109
</span>
110110
);

frontends/web/tests/banner.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test('Backup reminder banner is shown when currency is > 1000', async ({ page, h
7373

7474
// Then, cycle through the currency units and verify the banner updates accordingly.
7575
for (let i = 0; i < units.length; i++) {
76-
await page.locator(`header [data-testid="amount-unit-${units[currentIndex]!}"]`).click();
76+
await page.locator(`[data-testid="amount-unit-${units[currentIndex]!}"]`).click();
7777
const nextIndex = (currentIndex + 1) % units.length;
7878
await page.waitForTimeout(1000); // wait for the UI to update
7979
await verifyBackupBanner(page, units[nextIndex]!);

frontends/web/tests/base.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { test } from './helpers/fixtures';
1818
import { ServeWallet } from './helpers/servewallet';
1919
import { expect } from '@playwright/test';
20+
import { deleteAccountsFile, deleteConfigFile } from './helpers/fs';
2021

2122
let servewallet: ServeWallet;
2223

@@ -31,10 +32,16 @@ test('App main page loads', async ({ page, host, frontendPort, servewalletPort }
3132
await test.step('Navigate to the app', async () => {
3233
await page.goto(`http://${host}:${frontendPort}`);
3334
const body = page.locator('body');
34-
await expect(body).toContainText('Please connect your BitBox and tap the side to continue.');
35+
await expect(body).toContainText('Please connect your BitBox and tap the side to continue.'),
36+
{ timeout: 15000 };
3537
});
3638
});
3739

38-
test.afterAll(() => {
39-
servewallet.stop();
40+
test.beforeAll(async () => {
41+
deleteAccountsFile();
42+
deleteConfigFile();
43+
});
44+
45+
test.afterAll(async () => {
46+
await servewallet.stop();
4047
});

frontends/web/tests/helpers/regtest.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export async function sendCoins(address: string, amount: number | string): Promi
7878

7979

8080
export function launchRegtest(): Promise<ChildProcess> {
81-
81+
const PROJECT_ROOT = process.env.GITHUB_WORKSPACE || path.resolve(__dirname, '../../..');
8282
// First, clean up cache and headers.
8383
try {
84-
const basePath = path.resolve(__dirname, '../../../../appfolder.dev/cache');
84+
const basePath = path.join(PROJECT_ROOT, 'appfolder.dev/cache');
8585

8686
// Remove headers-rbtc.bin if it exists
8787
const headersPath = path.join(basePath, 'headers-rbtc.bin');
@@ -101,8 +101,7 @@ export function launchRegtest(): Promise<ChildProcess> {
101101
} catch (err) {
102102
console.warn('Warning: Failed to clean up cache or headers before regtest launch:', err);
103103
}
104-
105-
const scriptPath = path.resolve(__dirname, '../../../../scripts/run_regtest.sh');
104+
const scriptPath = path.join(PROJECT_ROOT, 'scripts/run_regtest.sh');
106105

107106
return new Promise((resolve, reject) => {
108107
const proc = spawn('bash', [scriptPath], {

0 commit comments

Comments
 (0)