Skip to content

Commit

Permalink
add changeset + unimported
Browse files Browse the repository at this point in the history
  • Loading branch information
VicAlbr committed Jan 6, 2025
1 parent 76cf3d6 commit 4364a11
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .changeset/tame-geese-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": minor
"@ledgerhq/live-common": minor
---

test: Refactoring of the Swap Enum + updating Provider Selection + Updating device for e2e tests
48 changes: 28 additions & 20 deletions apps/ledger-live-desktop/src/renderer/reducers/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,38 @@ export function getCurrentDevice(state: { devices: DevicesState; settings: Setti
};
}

if (
getEnv("DEVICE_PROXY_URL") ||
getEnv("SPECULOS_API_PORT") ||
(getEnv("MOCK") && !getEnv("MOCK_NO_BYPASS"))
) {
// bypass the listen devices (we should remove modelId here by instead get it at open time if needed)
return {
deviceId: "",
wired: true,
modelId: DeviceModelId.nanoSP,
};
const envConditions = [
{ condition: getEnv("DEVICE_PROXY_URL"), modelId: DeviceModelId.nanoS },
{ condition: getEnv("MOCK") && !getEnv("MOCK_NO_BYPASS"), modelId: DeviceModelId.nanoS },
{ condition: getEnv("SPECULOS_API_PORT"), modelId: DeviceModelId.nanoSP },
];

for (const { condition, modelId } of envConditions) {
if (condition) {
return {
deviceId: "",
wired: true,
modelId,
};
}
}
return state.devices.currentDevice;
}
export function getDevices(state: { devices: DevicesState }) {
if (getEnv("DEVICE_PROXY_URL") || getEnv("SPECULOS_API_PORT")) {
// bypass the listen devices
return [
{
deviceId: "",
wired: true,
modelId: DeviceModelId.nanoSP,
},
];
const envConditions = [
{ condition: getEnv("DEVICE_PROXY_URL"), modelId: DeviceModelId.nanoS },
{ condition: getEnv("SPECULOS_API_PORT"), modelId: DeviceModelId.nanoSP },
];
for (const { condition, modelId } of envConditions) {
if (condition) {
return [
{
deviceId: "",
wired: true,
modelId,
},
];
}
}
return state.devices.devices;
}
Expand Down
22 changes: 12 additions & 10 deletions apps/ledger-live-desktop/tests/page/swap.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,21 @@ export class SwapPage extends AppPage {
return provider && !provider.kyc;
});

const nativeProviders = providersWithoutKYC.filter(providerName => {
for (const providerName of providersWithoutKYC) {
const provider = Object.values(Provider).find(p => p.uiName === providerName);
return provider && provider.isNative;
});
if (provider && provider.isNative) {
const providerLocator = webview
.locator(`//span[@data-testid='quote-card-provider-name' and text()='${providerName}']`)
.first();

await providerLocator.isVisible();
await providerLocator.click();

for (const providerName of nativeProviders) {
const providerSelected = webview
.locator(`//span[@data-testid='quote-card-provider-name' and text()='${providerName}']`)
.first();
await providerSelected.isVisible();
await providerSelected.click();
return providerName;
return providerName;
}
}

throw new Error("No valid providers found");
}

async waitForExchangeToBeAvailable() {
Expand Down
11 changes: 3 additions & 8 deletions libs/ledger-live-common/.unimportedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,7 @@
"src/wallet-api/version.ts",
"src/errors/transactionBroadcastErrors.ts"
],
"extensions": [
".ts",
".js",
".jsx",
".tsx"
],
"extensions": [".ts", ".js", ".jsx", ".tsx"],
"ignorePatterns": [
"**/node_modules/**",
"**/__tests__/**",
Expand Down Expand Up @@ -327,7 +322,7 @@
"src/e2e/enum/DeviceLabels.ts",
"src/e2e/enum/Fee.ts",
"src/e2e/enum/Nft.ts",
"src/e2e/enum/OperationType.ts",
"src/e2e/enum/TransactionStatus.ts",
"src/e2e/enum/Swap.ts",
"src/exchange/swap/const/blockchain.ts",
"src/families/cardano/logic.ts",
Expand Down Expand Up @@ -437,4 +432,4 @@
"use-sync-external-store/shim",
"whatwg-fetch"
]
}
}

0 comments on commit 4364a11

Please sign in to comment.