Skip to content

Commit

Permalink
test: ✨ Use CLI to build app.json - delete account
Browse files Browse the repository at this point in the history
  • Loading branch information
VicAlbr committed Oct 11, 2024
1 parent ad25a4d commit 4a36a6b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
30 changes: 29 additions & 1 deletion apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -85,6 +88,8 @@ export class Account {
Currency.ETH,
"Ethereum 1",
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
undefined,
0,
);

static readonly ETH_2 = new Account(
Expand Down Expand Up @@ -127,6 +132,8 @@ export class Account {
Currency.DOT,
"Polkadot 1",
"15NKsw4AoSEgBJ5NpHDkAjUmqLRfeSuqZBzZXH9uRg6MWbo3",
undefined,
0,
);

static readonly DOT_2 = new Account(
Expand All @@ -145,6 +152,8 @@ export class Account {
Currency.SOL,
"Solana 1",
"HxoKQ5eu5MkqaAw7DaGVermrJqeNH8XkVnEKEpFuS9id",
undefined,
0,
);

static readonly SOL_2 = new Account(
Expand All @@ -157,14 +166,22 @@ 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");

static readonly ADA_1 = new Account(
Currency.ADA,
"Cardano 1",
" addr1q9q9q55zyew785z6c2lnrhnzghy038r6mepmqn6v28kupk5ug4c7v5lwwfjwgn4mnpzgmhrhp8xry804kuvfh6ru2ews8d5td8",
undefined,
0,
);
static readonly ADA_2 = new Account(
Currency.ADA,
Expand All @@ -176,6 +193,8 @@ export class Account {
Currency.ALGO,
"Algorand 1",
"HQ6YJWSVG3KVRE56V6UGWMUJLDVNPQUNXJBY7VJ56VMNMGIKVDTC7JEKOU",
undefined,
0,
);

static readonly ALGO_2 = new Account(
Expand All @@ -194,6 +213,8 @@ export class Account {
Currency.XLM,
"Stellar 1",
"GCAGRZ7XABYSXV7CPFSFWQIUK6XFXECBPWP2SGMVOB2KFWN7YM4TDGSX",
undefined,
0,
);

static readonly XLM_2 = new Account(
Expand All @@ -206,6 +227,8 @@ export class Account {
Currency.BCH,
"Bitcoin Cash 1",
"qz82kem69vdafku8xf4zpt9p5ytj8umwpujj7wjcv6",
undefined,
0,
);

static readonly BCH_2 = new Account(
Expand All @@ -218,6 +241,8 @@ export class Account {
Currency.ATOM,
"Cosmos 1",
"cosmos18sdl4lvyjtvpjkkt5smglux9sf4phdcpaddfae",
undefined,
0,
);

static readonly ATOM_2 = new Account(
Expand All @@ -230,6 +255,8 @@ export class Account {
Currency.XTZ,
"Tezos 1",
"tz1UD2zz5eFTW2Jy26kBnC3ZkdeazUgeFWST",
undefined,
0,
);

static readonly XTZ_2 = new Account(
Expand Down Expand Up @@ -304,6 +331,7 @@ export class Account {
"Tron 1",
"TDUKFB9wj3P5f2iNvkRuaDDeWVkTdUVhs1",
AccountType.TRC20,
0,
);

static readonly TRX_BTT = new Account(
Expand Down
13 changes: 13 additions & 0 deletions apps/ledger-live-desktop/tests/fixtures/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +29,7 @@ type TestFixtures = {
featureFlags: OptionalFeatureMap;
simulateCamera: string;
app: Application;
cliCommands: string[];
};

const IS_NOT_MOCK = process.env.MOCK == "0";
Expand All @@ -46,6 +48,7 @@ export const test = base.extend<TestFixtures>({
featureFlags: undefined,
simulateCamera: undefined,
speculosApp: undefined,
cliCommands: [],

app: async ({ page }, use) => {
const app = new Application(page);
Expand All @@ -62,6 +65,7 @@ export const test = base.extend<TestFixtures>({
const fullFilePath = path.join(userdataDestinationPath, "app.json");
await use(fullFilePath);
},

electronApp: async (
{
lang,
Expand All @@ -73,6 +77,7 @@ export const test = base.extend<TestFixtures>({
featureFlags,
simulateCamera,
speculosApp,
cliCommands,
},
use,
testInfo,
Expand All @@ -83,6 +88,7 @@ export const test = base.extend<TestFixtures>({
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));

Expand All @@ -106,6 +112,13 @@ export const test = base.extend<TestFixtures>({
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
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-desktop/tests/specs/speculos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4a36a6b

Please sign in to comment.