diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml index 0517e5b37..0b179f6b1 100644 --- a/.github/workflows/runTests.yml +++ b/.github/workflows/runTests.yml @@ -20,7 +20,7 @@ jobs: - run: yarn build:freighter-api - run: yarn build:extension - run: yarn test:ci - - run: yarn test:e2e + - run: ${{ github.base_ref == 'master' && 'IS_INTEGRATION_MODE=true' }} yarn test:e2e - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/extension/e2e-tests/addAsset.test.ts b/extension/e2e-tests/addAsset.test.ts index 2a373159b..e7d05a184 100644 --- a/extension/e2e-tests/addAsset.test.ts +++ b/extension/e2e-tests/addAsset.test.ts @@ -2,12 +2,43 @@ import { test, expect, expectPageToHaveScreenshot } from "./test-fixtures"; import { loginToTestAccount, PASSWORD } from "./helpers/login"; import { TEST_TOKEN_ADDRESS } from "./helpers/test-token"; -test.skip("Adding unverified Soroban token", async ({ page, extensionId }) => { +const USDC_TOKEN_ADDRESS = + "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA"; + +const STELLAR_EXPERT_ASSET_LIST_JSON = { + name: "StellarExpert Top 50", + provider: "StellarExpert", + description: + "Dynamically generated list based on technical asset metrics, including payments and trading volumes, interoperability, userbase, etc. Assets included in this list were not verified by StellarExpert team. StellarExpert is not affiliated with issuers, and does not endorse or advertise assets in the list. Assets reported for fraudulent activity removed from the list automatically.", + version: "1.0", + network: "testnet", + feedback: "https://stellar.expert", + assets: [ + { + code: "USDC", + issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", + contract: USDC_TOKEN_ADDRESS, + name: "USDC", + org: "unknown", + domain: "centre.io", + decimals: 7, + }, + ], +}; + +test("Adding unverified Soroban token", async ({ page, extensionId }) => { + console.log(process.env.IS_INTEGRATION_MODE); + if (!process.env.IS_INTEGRATION_MODE) { + await page.route("*/**/testnet/asset-list/top50", async (route) => { + const json = [STELLAR_EXPERT_ASSET_LIST_JSON]; + await route.fulfill({ json }); + }); + } test.slow(); await loginToTestAccount({ page, extensionId }); await page.getByTestId("account-options-dropdown").click(); - await page.getByText("Manage Assets").click({ force: true }); + await page.getByText("Manage assets").click({ force: true }); await expect(page.getByText("Your assets")).toBeVisible(); await expectPageToHaveScreenshot({ page, @@ -34,13 +65,12 @@ test.skip("Adding unverified Soroban token", async ({ page, extensionId }) => { await expect(page.getByTestId("account-view")).toContainText("E2E"); }); test("Adding Soroban verified token", async ({ page, extensionId }) => { - const assetsList = await fetch( - "https://api.stellar.expert/explorer/testnet/asset-list/top50", - ); - const assetsListData = await assetsList.json(); - const verifiedToken = - assetsListData?.assets[0]?.contract || - "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA"; + if (!process.env.IS_INTEGRATION_MODE) { + await page.route("*/**/testnet/asset-list/top50", async (route) => { + const json = [STELLAR_EXPERT_ASSET_LIST_JSON]; + await route.fulfill({ json }); + }); + } test.slow(); await loginToTestAccount({ page, extensionId }); @@ -51,7 +81,7 @@ test("Adding Soroban verified token", async ({ page, extensionId }) => { await expect(page.getByText("Your assets")).toBeVisible(); await page.getByText("Add an asset").click({ force: true }); await page.getByText("Add manually").click({ force: true }); - await page.getByTestId("search-token-input").fill(verifiedToken); + await page.getByTestId("search-token-input").fill(USDC_TOKEN_ADDRESS); await expect(page.getByTestId("asset-notification")).toHaveText( "On your listsFreighter uses asset lists to check assets you interact with. You can define your own assets lists in Settings.", );