Skip to content

Commit

Permalink
test: add test to check that account name change persists after app kill
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Jan 10, 2025
1 parent 1b4cbc0 commit ac7de96
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
20 changes: 19 additions & 1 deletion apps/ledger-live-mobile/e2e/page/accounts/account.page.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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")
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function AccountNameRow({ navigation, account }: Props) {
event="AccountNameRow"
title={<Trans i18nKey="account.settings.accountName.title" />}
desc={<Trans i18nKey="account.settings.accountName.desc" />}
testID="account-settings-rename-row"
arrowRight
onPress={onPress}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
</Box>
<Button
Expand Down

0 comments on commit ac7de96

Please sign in to comment.