Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
2 changes: 1 addition & 1 deletion extension/e2e-tests/addCollectible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ test("Add a collectible to an account", async ({
test.slow();
await loginToTestAccount({ page, extensionId, context, stubOverrides });
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();

// add the collectible
await expect(page.getByTestId("account-view")).toBeVisible();
Expand Down
4 changes: 2 additions & 2 deletions extension/e2e-tests/buyWithOnramp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test("should show add XLM page and open Coinbase", async ({
await loginToTestAccount({ page, extensionId, context, stubOverrides });

await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
Expand Down Expand Up @@ -140,7 +140,7 @@ test("should show Buy with Coinbase and open Coinbase", async ({
await loginToTestAccount({ page, extensionId, context, stubOverrides });

await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
Expand Down
2 changes: 1 addition & 1 deletion extension/e2e-tests/helpers/login-pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const loginToTestAccountPT = async ({
timeout: 50000,
});
await page.getByTestId("network-selector-open").click();
await page.getByText("Test Net").click();
await page.getByText("Testnet").click();
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
Expand Down
10 changes: 5 additions & 5 deletions extension/e2e-tests/helpers/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { generateMnemonic } = StellarHDWallet;
export const PASSWORD = "My-password123";

/**
* Creates a new wallet and logs into the extension on Test Net.
* Creates a new wallet and logs into the extension on Testnet.
*/
export const login = async ({
page,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const login = async ({
timeout: 10000,
});
await page.getByTestId("network-selector-open").click();
await page.getByText("Test Net").click();
await page.getByText("Testnet").click();

// Wait for account-balances API call with TESTNET network param before clicking
const balancesPromise = page.waitForResponse(
Expand Down Expand Up @@ -156,17 +156,17 @@ export const loginToTestAccount = async ({
timeout: 50000,
});
await page.getByTestId("network-selector-open").click();
await page.getByText("Test Net").click();
await page.getByText("Testnet").click();
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
};

export const switchToMainnet = async (page: Page) => {
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();
await expect(page.getByTestId("network-selector-open")).toContainText(
"Main Net",
"Mainnet",
{ timeout: 30000 },
);
};
6 changes: 3 additions & 3 deletions extension/e2e-tests/hideCollectible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test("Hide and unhide a collectible", async ({
test.slow();
await loginToTestAccount({ page, extensionId });
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();

// Navigate to collectibles tab
await expect(page.getByTestId("account-view")).toBeVisible();
Expand Down Expand Up @@ -188,7 +188,7 @@ test("Hidden collectibles view shows empty state when no collectibles are hidden
test.slow();
await loginToTestAccount({ page, extensionId });
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();

// Navigate to collectibles tab
await expect(page.getByTestId("account-view")).toBeVisible();
Expand Down Expand Up @@ -251,7 +251,7 @@ test("Hiding a collectible removes it from the main view", async ({
test.slow();
await loginToTestAccount({ page, extensionId });
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();

// Navigate to collectibles tab
await expect(page.getByTestId("account-view")).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {

const TX_TO_SIGN =
"AAAAAgAAAADLvQoIbFw9k0tgjZoOrLTuJJY9kHFYp/YAEAlt/xirbAAAAGQAAAfjAAAOpQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAAAAAAAAvrwgAAAAAAAAAAA";
const SECOND_TX_TO_SIGN =
"AAAAAgAAAADLvQoIbFw9k0tgjZoOrLTuJJY9kHFYp/YAEAlt/xirbAAAAGQAAAUVAAAA/QAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAAAAAAABfXhAAAAAAAAAAAA";
const SIGNED_TX =
"AAAAAgAAAADLvQoIbFw9k0tgjZoOrLTuJJY9kHFYp/YAEAlt/xirbAAAAGQAAAfjAAAOpQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAAAAAAAAvrwgAAAAAAAAAAB/xirbAAAAEBWgE2DhhukpAdJTOhBxvuvePAJH+gBbD3hQQljuidQbTFDMEyak7c2fOjyK2moqVhf3AUpCIMSlALglwFXumQH";

Expand Down Expand Up @@ -69,6 +71,8 @@ const JSON_SIGNED_MSG =

const isIntegrationMode = process.env.IS_INTEGRATION_MODE === "true";

test.describe.configure({ mode: "default" });

test("should sign transaction when allowed", async ({
page,
extensionId,
Expand Down Expand Up @@ -408,22 +412,23 @@ test("should sign correct transactions when Freighter receives multiple requests
await pageThree.goto(
"https://play.freighter.app/#/extension/playground/signTransaction",
);
await pageThree
.getByRole("textbox")
.first()
.fill(
"AAAAAgAAAADLvQoIbFw9k0tgjZoOrLTuJJY9kHFYp/YAEAlt/xirbAAAAGQAAAUVAAAA/QAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAAAAAAABfXhAAAAAAAAAAAA",
);
await pageThree.getByRole("textbox").first().fill(SECOND_TX_TO_SIGN);
await pageThree
.getByRole("textbox")
.nth(1)
.fill("Test SDF Network ; September 2015");
await pageThree.getByText("Sign Transaction XDR").click();

const txPopup2 = await txPopupPromise2;
await stubAccountBalances(txPopup2);
await stubScanTx(txPopup2);
await expect(txPopup2.getByText("Confirm Transaction")).toBeVisible();
await expect(txPopup2.getByText("GDF3…ZEFY")).toBeVisible();
await expect(txPopup2.getByText("-10")).toBeVisible();
const encodedParams = txPopup2.url().split("?")[1];
const popupParams = JSON.parse(
Buffer.from(encodedParams, "base64").toString("utf8"),
);
expect(popupParams.transactionXdr).toBe(SECOND_TX_TO_SIGN);

await txPopup.getByRole("button", { name: "Confirm" }).click();
await expect(pageTwo.locator("#result-signTx")).toHaveText(SIGNED_TX);
Expand Down Expand Up @@ -823,9 +828,10 @@ test("should add an unverified SEP-41 token when allowed", async ({
extensionId,
context,
}) => {
await stubIsSac(context);

await loginToTestAccount({ page, extensionId, context, isIntegrationMode });
await stubIsSac(context);
await stubTokenDetails(context);
await stubScanAssetSafe(context);
await allowDapp({ page });

// open a second tab and go to docs playground
Expand All @@ -845,7 +851,7 @@ test("should add an unverified SEP-41 token when allowed", async ({

const popup = await popupPromise;

await expect(popup.getByText("E2E Token")).toBeDefined();
await expect(popup.getByText("E2E Token")).toBeVisible();
Comment thread
JFWooten4 marked this conversation as resolved.
await expect(popup.getByTestId("add-token-unverified")).toBeVisible();
await expectPageToHaveScreenshot({
page: popup,
Expand Down Expand Up @@ -1058,12 +1064,13 @@ test("should not add a SEP-41 token when the domain is not allowed", async ({
extensionId,
context,
}) => {
await loginToTestAccount({ page, extensionId, context, isIntegrationMode });
if (!isIntegrationMode) {
await stubIsSac(context);
await stubTokenDetails(context);
await stubScanAssetSafe(context);
}

await loginToTestAccount({ page, extensionId, context, isIntegrationMode });

// open a second tab and go to docs playground
const pageTwo = await page.context().newPage();
await pageTwo.waitForLoadState();
Expand Down
6 changes: 3 additions & 3 deletions extension/e2e-tests/loadAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ test("Switches network and fetches correct balances while clearing cache", async
await expect(page.getByTestId("asset-amount")).toHaveText("2");

await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();

await expect(page.getByTestId("asset-amount")).toHaveText("1");

Expand Down Expand Up @@ -259,7 +259,7 @@ test("Switches network and fetches correct balances while clearing cache", async
await route.fulfill({ json });
});
await page.getByTestId("network-selector-open").click();
await page.getByText("Test Net").click();
await page.getByText("Testnet").click();
await expect(page.getByTestId("asset-amount")).toHaveText("999,111");
});

Expand Down Expand Up @@ -601,7 +601,7 @@ test("Loads wallets data and token prices on Mainnet in batches", async ({
};
await loginToTestAccount({ page, extensionId, context, stubOverrides });
await page.getByTestId("network-selector-open").click();
await page.getByText("Main Net").click();
await page.getByText("Mainnet").click();
await expect(page.getByTestId("account-assets")).toContainText("XLM");
await page.getByTestId("account-view-account-name").click();
await expect(page.getByText("Wallets")).toBeVisible();
Expand Down
6 changes: 3 additions & 3 deletions extension/e2e-tests/onboarding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ test("Import 12 word wallet by pasting", async ({ page, context }) => {
}, TEST_MNEMONIC_12_WORDS);

// paste text from clipboard
await page.locator("#MnemonicPhrase-1").press("Meta+v");
await page.locator("#MnemonicPhrase-1").press("ControlOrMeta+v");
Comment thread
JFWooten4 marked this conversation as resolved.

await expectPageToHaveScreenshot(
{
Expand Down Expand Up @@ -295,7 +295,7 @@ test("Import 24 word wallet by pasting", async ({ page, context }) => {
);

// paste text from clipboard
await page.locator("#MnemonicPhrase-1").press("Meta+v");
await page.locator("#MnemonicPhrase-1").press("ControlOrMeta+v");

await expectPageToHaveScreenshot(
{
Expand Down Expand Up @@ -596,7 +596,7 @@ test("Overwrites account when user abandons mnemonic phrase confirmation", async
);
await page.getByTestId("account-view-account-name").click();

expect(page.getByTestId("wallet-row-select")).toHaveCount(1);
await expect(page.getByTestId("wallet-row-select")).toHaveCount(1);

await page.getByTestId("BackButton").click();
await page.getByTestId("account-options-dropdown").click();
Expand Down
2 changes: 2 additions & 0 deletions extension/e2e-tests/sendPayment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BrowserContext, Page } from "@playwright/test";
import { login, loginToTestAccount, switchToMainnet } from "./helpers/login";
import { TEST_TOKEN_ADDRESS } from "./helpers/test-token";
import {
stubAccountBalances,
stubAccountBalancesE2e,
stubAccountBalancesWithUnfundedDestination,
stubAccountBalancesWithUSDC,
Expand Down Expand Up @@ -73,6 +74,7 @@ test("Swap doesn't throw error when account is unfunded", async ({
page,
extensionId,
}) => {
await stubAccountBalances(page, "0");
await login({ page, extensionId });

await page.getByTestId("nav-link-swap").click();
Expand Down
7 changes: 6 additions & 1 deletion extension/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, devices } from "@playwright/test";

const TEST_TIMEOUT_MS = 60_000;

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand All @@ -10,7 +12,10 @@ import { defineConfig, devices } from "@playwright/test";
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
timeout: 15000,
timeout: TEST_TIMEOUT_MS,
expect: {
timeout: 20_000,
},
testDir: "./e2e-tests",
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NETWORK_NAMES } from "@shared/constants/stellar";

import { getNetworkDisplayName } from "../getNetworkDisplayName";

const DISPLAY_NAMES = {
mainnet: "translated-mainnet",
testnet: "translated-testnet",
futurenet: "translated-futurenet",
};

describe("getNetworkDisplayName", () => {
it.each([
[NETWORK_NAMES.PUBNET, DISPLAY_NAMES.mainnet],
[NETWORK_NAMES.TESTNET, DISPLAY_NAMES.testnet],
[NETWORK_NAMES.FUTURENET, DISPLAY_NAMES.futurenet],
])("maps %s to its display name", (networkName, expected) => {
expect(getNetworkDisplayName(networkName, DISPLAY_NAMES)).toBe(expected);
});

it("preserves custom network names", () => {
expect(getNetworkDisplayName("My Network", DISPLAY_NAMES)).toBe(
"My Network",
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { NETWORK_NAMES } from "@shared/constants/stellar";

interface NetworkDisplayNames {
mainnet: string;
testnet: string;
futurenet: string;
}

export const getNetworkDisplayName = (
networkName: string,
displayNames: NetworkDisplayNames,
) => {
switch (networkName) {
case NETWORK_NAMES.PUBNET:
return displayNames.mainnet;
case NETWORK_NAMES.TESTNET:
return displayNames.testnet;
case NETWORK_NAMES.FUTURENET:
return displayNames.futurenet;
default:
return networkName;
}
};
11 changes: 10 additions & 1 deletion extension/src/popup/components/account/AccountHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { NetworkDetails } from "@shared/constants/stellar";
import { MobileAppBanner } from "popup/components/account/MobileAppBanner";
import { AccountTabs } from "popup/components/account/AccountTabs";
import { MaintenanceBanner } from "popup/components/MaintenanceBanner";
import { getNetworkDisplayName } from "./getNetworkDisplayName";

import "./styles.scss";

Expand Down Expand Up @@ -62,6 +63,11 @@ export const AccountHeader = ({
onDiscoverClick,
}: AccountHeaderProps) => {
const { t } = useTranslation();
const networkDisplayNames = {
mainnet: t("Mainnet"),
testnet: t("Testnet"),
futurenet: t("Futurenet"),
};
const networkDetails = useSelector(settingsNetworkDetailsSelector);
const networksList = useSelector(settingsNetworksListSelector);
const [isNetworkSelectorOpen, setIsNetworkSelectorOpen] = useState(false);
Expand Down Expand Up @@ -264,7 +270,10 @@ export const AccountHeader = ({
>
<NetworkIcon index={i} />
<div className="AccountHeader__network-copy">
{n.networkName}
{getNetworkDisplayName(
n.networkName,
networkDisplayNames,
)}
</div>
{isActiveNetwork(n, networkDetails) ? (
<div className="AccountHeader__network-selector__check">
Expand Down
3 changes: 3 additions & 0 deletions extension/src/popup/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
"Fullscreen mode": "Fullscreen mode",
"Function Name": "Function Name",
"Fund with Friendbot": "Fund with Friendbot",
"Futurenet": "Futurenet",
"Get started by adding a collectible.": "Get started by adding a collectible.",
"Get started by adding an asset.": "Get started by adding an asset.",
"Go back": "Go back",
Expand Down Expand Up @@ -372,6 +373,7 @@
"Lost your password? Want to replace your accounts?": "Lost your password? Want to replace your accounts?",
"Low": "Low",
"Low Threshold": "Low Threshold",
"Mainnet": "Mainnet",
"Make sure it is a funded Stellar account and try again.": "Make sure it is a funded Stellar account and try again.",
"Make sure you have your 12 word backup phrase": "Make sure you have your 12 word backup phrase",
"Make sure you have your current 12 words backup phrase before continuing.": "Make sure you have your current 12 words backup phrase before continuing.",
Expand Down Expand Up @@ -628,6 +630,7 @@
"Tags": "Tags",
"Terms of Service": "Terms of Service",
"Terms of Use": "Terms of Use",
"Testnet": "Testnet",
"The authorization entry is for {{network}}.": "The authorization entry is for {{network}}.",
"The authorization entry is for a different network than the one you are connected to.": "The authorization entry is for a different network than the one you are connected to.",
"The authorization entry is malformed or contains invalid data.": "The authorization entry is malformed or contains invalid data.",
Expand Down
Loading
Loading