From ac7de96f90d9cded124a7d0b57d433c3b6708749 Mon Sep 17 00:00:00 2001 From: Abdurrahman SASTIM Date: Fri, 10 Jan 2025 14:22:48 +0100 Subject: [PATCH] test: add test to check that account name change persists after app kill --- .../e2e/page/accounts/account.page.ts | 20 ++++++++- .../speculos/account/accountRename.spec.ts | 45 +++++++++++++++++++ .../AccountSettings/AccountNameRow.tsx | 1 + .../AccountSettings/EditAccountName.tsx | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 apps/ledger-live-mobile/e2e/specs/speculos/account/accountRename.spec.ts diff --git a/apps/ledger-live-mobile/e2e/page/accounts/account.page.ts b/apps/ledger-live-mobile/e2e/page/accounts/account.page.ts index 66d2a749ef82..4c69fce39ba8 100644 --- a/apps/ledger-live-mobile/e2e/page/accounts/account.page.ts +++ b/apps/ledger-live-mobile/e2e/page/accounts/account.page.ts @@ -1,4 +1,10 @@ -import { getElementById, getTextOfElement, scrollToId, tapByElement } from "../../helpers"; +import { + getElementById, + getTextOfElement, + scrollToId, + tapByElement, + typeTextById, +} from "../../helpers"; import { expect } from "detox"; import jestExpect from "expect"; @@ -12,6 +18,8 @@ export default class AccountPage { operationHistorySectionId = (accountId: string) => `operations-history-${accountId}`; accountScreenScrollView = "account-screen-scrollView"; accountAdvancedLogsId = "account-advanced-logs"; + accountRenameRow = () => getElementById("account-settings-rename-row"); + acountRenameTextInputId = "account-rename-text-input"; receiveButton = () => getElementById("account-quick-action-button-Receive"); @Step("Open account settings") @@ -34,6 +42,16 @@ export default class AccountPage { await tapByElement(this.accountDeleteConfirm()); } + @Step("Select account edit name") + async selectAccountRename() { + await tapByElement(this.accountRenameRow()); + } + + @Step("Enter new account name and submit") + async enterNewAccountName(name: string) { + await typeTextById(this.acountRenameTextInputId, name); + } + @Step("Expect operation history to be visible") async expectOperationHistoryVisible(accountId: string) { const id = this.operationHistorySectionId(accountId); diff --git a/apps/ledger-live-mobile/e2e/specs/speculos/account/accountRename.spec.ts b/apps/ledger-live-mobile/e2e/specs/speculos/account/accountRename.spec.ts new file mode 100644 index 000000000000..afbdf8f0af4e --- /dev/null +++ b/apps/ledger-live-mobile/e2e/specs/speculos/account/accountRename.spec.ts @@ -0,0 +1,45 @@ +import { launchApp } from "../../../helpers"; +import { Application } from "../../../page"; +import { CLI } from "../../../utils/cliUtils"; +import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; +import { device } from "detox"; + +const app = new Application(); +const account = Account.BTC_NATIVE_SEGWIT_1; +const newAccountName = "New Account Name"; + +$TmsLink("B2CQA-2996"); +describe("Account name change", () => { + beforeAll(async () => { + await app.init({ + speculosApp: account.currency.speculosApp, + cliCommands: [ + async () => { + return CLI.liveData({ + currency: account.currency.currencyId, + index: account.index, + appjson: app.userdataPath, + add: true, + }); + }, + ], + }); + await app.portfolio.waitForPortfolioPageToLoad(); + }); + + it("should persist Account name change after app restart", async () => { + await app.accounts.openViaDeeplink(); + await app.common.expectAccountName(account.accountName); + await app.common.goToAccountByName(account.accountName); + await app.account.openAccountSettings(); + await app.account.selectAccountRename(); + await app.account.enterNewAccountName(newAccountName); + await app.accounts.openViaDeeplink(); + await app.common.expectAccountName(newAccountName); + await device.terminateApp(); + await launchApp(); + await app.portfolio.waitForPortfolioPageToLoad(); + await app.accounts.openViaDeeplink(); + await app.common.expectAccountName(newAccountName); + }); +}); diff --git a/apps/ledger-live-mobile/src/screens/AccountSettings/AccountNameRow.tsx b/apps/ledger-live-mobile/src/screens/AccountSettings/AccountNameRow.tsx index 6966556628f1..99d018ddab69 100644 --- a/apps/ledger-live-mobile/src/screens/AccountSettings/AccountNameRow.tsx +++ b/apps/ledger-live-mobile/src/screens/AccountSettings/AccountNameRow.tsx @@ -24,6 +24,7 @@ function AccountNameRow({ navigation, account }: Props) { event="AccountNameRow" title={} desc={} + testID="account-settings-rename-row" arrowRight onPress={onPress} > diff --git a/apps/ledger-live-mobile/src/screens/AccountSettings/EditAccountName.tsx b/apps/ledger-live-mobile/src/screens/AccountSettings/EditAccountName.tsx index f2d626b0bad7..dd02727e786a 100644 --- a/apps/ledger-live-mobile/src/screens/AccountSettings/EditAccountName.tsx +++ b/apps/ledger-live-mobile/src/screens/AccountSettings/EditAccountName.tsx @@ -91,6 +91,7 @@ class EditAccountName extends PureComponent< onSubmitEditing={this.onNameEndEditing} clearButtonMode="while-editing" placeholder={i18next.t("account.settings.accountName.placeholder")} + testID="account-rename-text-input" />