Skip to content

Commit

Permalink
add API stubbing for addAsset and test gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
piyalbasu committed Dec 16, 2024
1 parent d97dd32 commit 90830f5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
50 changes: 40 additions & 10 deletions extension/e2e-tests/addAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 });
Expand All @@ -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.",
);
Expand Down

0 comments on commit 90830f5

Please sign in to comment.