Skip to content

Commit

Permalink
fix: remove blockstream from tests and add network form
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Aug 20, 2024
1 parent 27ca424 commit 86af370
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
10 changes: 7 additions & 3 deletions src/app/features/add-network/add-network-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { NetworkSelectors } from '@tests/selectors/network.selectors';
import { useFormikContext } from 'formik';
import { HStack, styled } from 'leather-styles/jsx';

import type { BitcoinNetworkModes } from '@leather.io/models';
import {
BITCOIN_API_BASE_URL_MAINNET,
BITCOIN_API_BASE_URL_TESTNET,
type BitcoinNetworkModes,
} from '@leather.io/models';
import {
CheckmarkIcon,
ChevronDownIcon,
Expand Down Expand Up @@ -60,11 +64,11 @@ export function AddNetworkForm() {
switch (values.bitcoinNetwork) {
case 'mainnet':
setStacksUrl('https://api.hiro.so');
setBitcoinUrl('https://blockstream.info/api');
setBitcoinUrl(BITCOIN_API_BASE_URL_MAINNET);
break;
case 'testnet':
setStacksUrl('https://api.testnet.hiro.so');
setBitcoinUrl('https://blockstream.info/testnet/api');
setBitcoinUrl(BITCOIN_API_BASE_URL_TESTNET);
break;
case 'signet':
setStacksUrl('https://api.testnet.hiro.so');
Expand Down
12 changes: 6 additions & 6 deletions src/app/features/add-network/add-network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NetworkSelectors } from '@tests/selectors/network.selectors';
import { Form, Formik } from 'formik';
import { Stack, styled } from 'leather-styles/jsx';

import { Button } from '@leather.io/ui';
import { Button, Link } from '@leather.io/ui';

import { ErrorLabel } from '@app/components/error-label';
import { Card, Content, Page } from '@app/components/layout';
Expand Down Expand Up @@ -31,21 +31,21 @@ export function AddNetwork() {
>
<styled.span textStyle="body.02">
Use this form to add a new instance of the{' '}
<a
<Link
href="https://github.com/blockstack/stacks-blockchain-api"
target="_blank"
rel="noreferrer"
>
Stacks Blockchain API
</a>{' '}
</Link>{' '}
or{' '}
<a
href="https://github.com/Blockstream/esplora"
<Link
href="https://mempool.space/docs/api/rest"
target="_blank"
rel="noreferrer"
>
Bitcoin Blockchain API
</a>
</Link>
. Make sure you review and trust the host before you add it.
</styled.span>
<AddNetworkForm />
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/networks/networks.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function transformNetworkStateToMultichainStucture(
bitcoin: {
blockchain: 'bitcoin',
bitcoinNetwork: bitcoinNetwork ? bitcoinNetwork : 'testnet',
bitcoinUrl: bitcoinUrl ? bitcoinUrl : 'https://blockstream.info/testnet/api',
bitcoinUrl: bitcoinUrl ? bitcoinUrl : BITCOIN_API_BASE_URL_TESTNET,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/ledger/ledger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const specs = {
};

async function interceptBitcoinRequests(homePage: HomePage) {
const requestPromise = homePage.page.waitForRequest(/bestinslot|blockstream|inscriptions/, {
const requestPromise = homePage.page.waitForRequest(/bestinslot|mempool|inscriptions/, {
timeout: 1000,
});
return requestPromise;
Expand Down
6 changes: 4 additions & 2 deletions tests/specs/network/add-network.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NetworkSelectors } from '@tests/selectors/network.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';

import { BITCOIN_API_BASE_URL_TESTNET } from '@leather.io/models';

import { test } from '../../fixtures/fixtures';

test.describe('Networks tests', () => {
Expand All @@ -19,9 +21,9 @@ test.describe('Networks tests', () => {
await page.getByTestId(NetworkSelectors.AddNetworkBitcoinAPISelector).click();
await page.getByTestId(NetworkSelectors.BitcoinAPIOptionTestnet).click();

const bitcoinUrl = await page.getByTestId(NetworkSelectors.NetworkBitcoinAddress);
const bitcoinUrl = page.getByTestId(NetworkSelectors.NetworkBitcoinAddress);

test.expect(await bitcoinUrl.inputValue()).toEqual('https://blockstream.info/testnet/api');
test.expect(await bitcoinUrl.inputValue()).toEqual(BITCOIN_API_BASE_URL_TESTNET);
});

test('validation error when stacks api url is empty', async ({ networkPage }) => {
Expand Down
4 changes: 3 additions & 1 deletion tests/specs/onboarding/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
import { testSoftwareAccountDefaultWalletState } from '@tests/page-object-models/onboarding.page';
import { OnboardingSelectors } from '@tests/selectors/onboarding.selectors';

import { BITCOIN_API_BASE_URL_MAINNET } from '@leather.io/models';

import { test } from '../../fixtures/fixtures';

test.describe('Onboarding an existing user', () => {
Expand Down Expand Up @@ -64,7 +66,7 @@ test.describe('Onboarding an existing user', () => {
test('Activity tab', async ({ extensionId, globalPage, onboardingPage, homePage, page }) => {
await globalPage.setupAndUseApiCalls(extensionId);
await onboardingPage.signUpNewUser();
await page.route(`**/blockstream.info/api/address/**/txs`, route =>
await page.route(`${BITCOIN_API_BASE_URL_MAINNET}/address/**/txs`, route =>
route.fulfill({
json: [],
})
Expand Down

0 comments on commit 86af370

Please sign in to comment.