diff --git a/apps/ledger-live-desktop/tests/enum/Account.ts b/apps/ledger-live-desktop/tests/enum/Account.ts index 28523d0cd0d9..7ffbe2e3ae85 100644 --- a/apps/ledger-live-desktop/tests/enum/Account.ts +++ b/apps/ledger-live-desktop/tests/enum/Account.ts @@ -7,12 +7,15 @@ export class Account { public readonly accountName: string, public readonly address: string, public readonly accountType?: AccountType, + public readonly index?: number, ) {} static readonly BTC_NATIVE_SEGWIT_1 = new Account( Currency.BTC, "Bitcoin 1", "bc1qm6tw2c0u842qjs7g2n2c7ulh76f6xn4sk0dsyt", + undefined, + 0, ); static readonly BTC_NATIVE_SEGWIT_2 = new Account( @@ -85,6 +88,8 @@ export class Account { Currency.ETH, "Ethereum 1", "0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6", + undefined, + 0, ); static readonly ETH_2 = new Account( @@ -127,6 +132,8 @@ export class Account { Currency.DOT, "Polkadot 1", "15NKsw4AoSEgBJ5NpHDkAjUmqLRfeSuqZBzZXH9uRg6MWbo3", + undefined, + 0, ); static readonly DOT_2 = new Account( @@ -145,6 +152,8 @@ export class Account { Currency.SOL, "Solana 1", "HxoKQ5eu5MkqaAw7DaGVermrJqeNH8XkVnEKEpFuS9id", + undefined, + 0, ); static readonly SOL_2 = new Account( @@ -157,7 +166,13 @@ export class Account { static readonly TRX_2 = new Account(Currency.TRX, "Tron 2", "TMGGi8n7kDkB8ws9wgunKf2SGNP4PjEyLL"); - static readonly XRP_1 = new Account(Currency.XRP, "XRP 1", "rhQvt8XfAGn1hVVtMUmdGKBUdnKzi2oimV"); + static readonly XRP_1 = new Account( + Currency.XRP, + "XRP 1", + "rhQvt8XfAGn1hVVtMUmdGKBUdnKzi2oimV", + undefined, + 0, + ); static readonly XRP_2 = new Account(Currency.XRP, "XRP 2", "r36cgyrfC1xSQMvjuiSeFJEcBTq31imZS"); @@ -165,6 +180,8 @@ export class Account { Currency.ADA, "Cardano 1", " addr1q9q9q55zyew785z6c2lnrhnzghy038r6mepmqn6v28kupk5ug4c7v5lwwfjwgn4mnpzgmhrhp8xry804kuvfh6ru2ews8d5td8", + undefined, + 0, ); static readonly ADA_2 = new Account( Currency.ADA, @@ -176,6 +193,8 @@ export class Account { Currency.ALGO, "Algorand 1", "HQ6YJWSVG3KVRE56V6UGWMUJLDVNPQUNXJBY7VJ56VMNMGIKVDTC7JEKOU", + undefined, + 0, ); static readonly ALGO_2 = new Account( @@ -194,6 +213,8 @@ export class Account { Currency.XLM, "Stellar 1", "GCAGRZ7XABYSXV7CPFSFWQIUK6XFXECBPWP2SGMVOB2KFWN7YM4TDGSX", + undefined, + 0, ); static readonly XLM_2 = new Account( @@ -206,6 +227,8 @@ export class Account { Currency.BCH, "Bitcoin Cash 1", "qz82kem69vdafku8xf4zpt9p5ytj8umwpujj7wjcv6", + undefined, + 0, ); static readonly BCH_2 = new Account( @@ -218,6 +241,8 @@ export class Account { Currency.ATOM, "Cosmos 1", "cosmos18sdl4lvyjtvpjkkt5smglux9sf4phdcpaddfae", + undefined, + 0, ); static readonly ATOM_2 = new Account( @@ -230,6 +255,8 @@ export class Account { Currency.XTZ, "Tezos 1", "tz1UD2zz5eFTW2Jy26kBnC3ZkdeazUgeFWST", + undefined, + 0, ); static readonly XTZ_2 = new Account( @@ -304,6 +331,7 @@ export class Account { "Tron 1", "TDUKFB9wj3P5f2iNvkRuaDDeWVkTdUVhs1", AccountType.TRC20, + 0, ); static readonly TRX_BTT = new Account( diff --git a/apps/ledger-live-desktop/tests/fixtures/common.ts b/apps/ledger-live-desktop/tests/fixtures/common.ts index 69487afed34a..d8e21ea16e92 100644 --- a/apps/ledger-live-desktop/tests/fixtures/common.ts +++ b/apps/ledger-live-desktop/tests/fixtures/common.ts @@ -12,6 +12,7 @@ import { launchApp } from "tests/utils/electronUtils"; import { captureArtifacts } from "tests/utils/allureUtils"; import { randomUUID } from "crypto"; import { AppInfos } from "tests/enum/AppInfos"; +import { runCliCommand } from "tests/utils/cliUtils"; type TestFixtures = { lang: string; @@ -28,6 +29,7 @@ type TestFixtures = { featureFlags: OptionalFeatureMap; simulateCamera: string; app: Application; + cliCommands: string[]; }; const IS_NOT_MOCK = process.env.MOCK == "0"; @@ -46,6 +48,7 @@ export const test = base.extend({ featureFlags: undefined, simulateCamera: undefined, speculosApp: undefined, + cliCommands: [], app: async ({ page }, use) => { const app = new Application(page); @@ -62,6 +65,7 @@ export const test = base.extend({ const fullFilePath = path.join(userdataDestinationPath, "app.json"); await use(fullFilePath); }, + electronApp: async ( { lang, @@ -73,6 +77,7 @@ export const test = base.extend({ featureFlags, simulateCamera, speculosApp, + cliCommands, }, use, testInfo, @@ -83,6 +88,7 @@ export const test = base.extend({ const fileUserData = userdataOriginalFile ? await fsPromises.readFile(userdataOriginalFile, { encoding: "utf-8" }).then(JSON.parse) : {}; + const userData = merge({ data: { settings } }, fileUserData); await fsPromises.writeFile(`${userdataDestinationPath}/app.json`, JSON.stringify(userData)); @@ -106,6 +112,13 @@ export const test = base.extend({ setEnv("SPECULOS_API_PORT", device?.ports.apiPort?.toString()); process.env.SPECULOS_API_PORT = device?.ports.apiPort; process.env.MOCK = ""; + + if (cliCommands) { + for (const command of cliCommands) { + const fullCommand = `${command} --appjson ${userdataDestinationPath}/app.json`; + await runCliCommand(fullCommand); + } + } } // default environment variables diff --git a/apps/ledger-live-desktop/tests/specs/speculos/README.md b/apps/ledger-live-desktop/tests/specs/speculos/README.md index f5f0f30b73a7..2064c86b41c0 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/README.md +++ b/apps/ledger-live-desktop/tests/specs/speculos/README.md @@ -81,6 +81,8 @@ The command `export COINAPPS="/Users/firstname.lastname/coin-apps` should be adj Before executing any test, don’t forget to build the app, do it whenever the source code changed. ``` +pnpm build:lld +pnpm build:cli pnpm desktop build:testing ``` diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts index f7306aad4e1d..bcde63b74ba9 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts @@ -21,7 +21,11 @@ const accounts = [ for (const account of accounts) { test.describe("Delete Accounts", () => { test.use({ - userdata: "speculos-tests-app", + userdata: "skip-onboarding", + cliCommands: [ + `liveData --currency ${account.account.currency.ticker} --index ${account.account.index} --add`, + ], + speculosApp: account.account.currency.speculosApp, }); test(