Skip to content

Commit 5bd4b26

Browse files
authored
Merge pull request #14750 from LedgerHQ/fix/flaky-test-on-address-poisoning
🔧 fix(address-poisoning): test flaky due to react 19 change
2 parents eb912d7 + 742321d commit 5bd4b26

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

apps/ledger-live-desktop/tests/page/account.page.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,21 @@ export class AccountPage extends AppPage {
5959
async clickReceive() {
6060
await this.receiveButton.click();
6161
}
62+
63+
@step("Navigate to token account")
64+
async navigateToToken(tokenTestId: string) {
65+
const tokenRow = this.page.getByTestId(tokenTestId);
66+
// Wait for the token row to be attached to the DOM before navigating to it.
67+
// React 19's concurrent rendering may temporarily detach elements during re-renders
68+
await tokenRow.waitFor({ state: "attached" });
69+
await tokenRow.click();
70+
}
71+
72+
async operationRowByTestId(operationTestId: string) {
73+
const operationRow = this.page.getByTestId(operationTestId);
74+
// Wait for the operation row to be attached to the DOM before returning it.
75+
// React 19's concurrent rendering may temporarily detach elements during re-renders
76+
await operationRow.waitFor({ state: "attached" });
77+
return operationRow;
78+
}
6279
}

apps/ledger-live-desktop/tests/specs/settings/hide-token-null-value-ff.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,36 @@ test("Hide Token Null Value with evm in feature flag", async ({ page }) => {
2222
const accountsPage = new AccountsPage(page);
2323
const accountPage = new AccountPage(page);
2424

25-
await test.step("check if operations is filtered by zero amount", async () => {
25+
await test.step("check if operations is not filtered by zero amount because of FF", async () => {
2626
await layout.goToSettings();
2727
await settingsPage.goToAccountsTab();
2828
expect(await settingsPage.isFilterTokenOperationsZeroAmountToggleChecked()).toBe(true);
2929
await layout.goToAccounts();
3030
await accountsPage.navigateToAccountByName(Account.ETH_2.accountName);
3131
await accountPage.scrollToOperations();
3232

33-
const mainAccountOperationRowNoValue = page.getByTestId(
33+
const mainAccountOperationRowNoValue = await accountPage.operationRowByTestId(
3434
"operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:",
3535
);
3636
await expect(mainAccountOperationRowNoValue).toBeVisible();
3737
expect(await mainAccountOperationRowNoValue.textContent()).not.toContain("ETH");
3838

39-
const mainAccountOperationWithValue = page.getByTestId(
39+
const mainAccountOperationWithValue = await accountPage.operationRowByTestId(
4040
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:",
4141
);
4242
await expect(mainAccountOperationWithValue).toBeVisible();
4343
expect(await mainAccountOperationWithValue.textContent()).toContain("ETH");
4444

45-
await page.getByTestId("token-row-USDC").click();
45+
await accountPage.navigateToToken("token-row-USDC");
4646
await accountPage.scrollToOperations();
4747

48-
const tokenAccountOperationRowNoValue = page.getByTestId(
48+
const tokenAccountOperationRowNoValue = await accountPage.operationRowByTestId(
4949
"operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:|1",
5050
);
5151
await expect(tokenAccountOperationRowNoValue).toBeVisible();
5252
expect(await tokenAccountOperationRowNoValue.textContent()).not.toContain("USDC");
5353

54-
const tokenAccountOperationRowWithValue = page.getByTestId(
54+
const tokenAccountOperationRowWithValue = await accountPage.operationRowByTestId(
5555
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:|1",
5656
);
5757
await expect(tokenAccountOperationRowWithValue).toBeVisible();

apps/ledger-live-desktop/tests/specs/settings/hide-token-null-value.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ test("Hide Token Null Value", async ({ page }) => {
2525
await accountsPage.navigateToAccountByName(Account.ETH_2.accountName);
2626
await accountPage.scrollToOperations();
2727

28-
const mainAccountOperationRowNoValue = page.getByTestId(
28+
const mainAccountOperationRowNoValue = await accountPage.operationRowByTestId(
2929
"operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:",
3030
);
3131
await expect(mainAccountOperationRowNoValue).toBeVisible();
3232
expect(await mainAccountOperationRowNoValue.textContent()).not.toContain("ETH");
3333

34-
const mainAccountOperationWithValue = page.getByTestId(
34+
const mainAccountOperationWithValue = await accountPage.operationRowByTestId(
3535
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:",
3636
);
3737
await expect(mainAccountOperationWithValue).toBeVisible();
3838
expect(await mainAccountOperationWithValue.textContent()).toContain("ETH");
3939

40-
await page.getByTestId("token-row-USDC").click();
40+
await accountPage.navigateToToken("token-row-USDC");
4141
await accountPage.scrollToOperations();
4242

43-
const tokenAccountOperationRowNoValue = page.getByTestId(
43+
const tokenAccountOperationRowNoValue = await accountPage.operationRowByTestId(
4444
"operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:|1",
4545
);
4646
await expect(tokenAccountOperationRowNoValue).toBeVisible();
4747
expect(await tokenAccountOperationRowNoValue.textContent()).not.toContain("USDC");
4848

49-
const tokenAccountOperationRowWithValue = page.getByTestId(
49+
const tokenAccountOperationRowWithValue = await accountPage.operationRowByTestId(
5050
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:|1",
5151
);
5252
await expect(tokenAccountOperationRowWithValue).toBeVisible();
@@ -62,26 +62,26 @@ test("Hide Token Null Value", async ({ page }) => {
6262
await accountsPage.navigateToAccountByName(Account.ETH_2.accountName);
6363
await accountPage.scrollToOperations();
6464

65-
const mainAccountOperationRowNoValue = page.getByTestId(
65+
const mainAccountOperationRowNoValue = await accountPage.operationRowByTestId(
6666
"operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:",
6767
);
6868
await expect(mainAccountOperationRowNoValue).toBeVisible();
6969
expect(await mainAccountOperationRowNoValue.textContent()).not.toContain("ETH");
7070

71-
const mainAccountOperationWithValue = page.getByTestId(
71+
const mainAccountOperationWithValue = await accountPage.operationRowByTestId(
7272
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:",
7373
);
7474
await expect(mainAccountOperationWithValue).toBeVisible();
7575
expect(await mainAccountOperationWithValue.textContent()).toContain("ETH");
7676

77-
await page.getByTestId("token-row-USDC").click();
77+
await accountPage.navigateToToken("token-row-USDC");
7878
await accountPage.scrollToOperations();
7979

8080
await expect(
8181
page.getByTestId("operation-row-mock_op_0_mock:1:ethereum:true_ethereum_1:|1"),
8282
).toHaveCount(0);
8383

84-
const tokenAccountOperationRowWithValue = page.getByTestId(
84+
const tokenAccountOperationRowWithValue = await accountPage.operationRowByTestId(
8585
"operation-row-mock_op_1_mock:1:ethereum:true_ethereum_1:|1",
8686
);
8787
await expect(tokenAccountOperationRowWithValue).toBeVisible();

0 commit comments

Comments
 (0)