Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ledger test for bitcoin api calls #5581

Merged
merged 1 commit into from
Jun 28, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"@leather.io/constants": "0.8.0",
"@leather.io/crypto": "1.0.2",
"@leather.io/models": "0.10.0",
"@leather.io/query": "0.9.2",
"@leather.io/query": "0.9.3",
"@leather.io/tokens": "0.6.0",
"@leather.io/ui": "1.5.1",
"@leather.io/utils": "0.9.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/specs/ledger/ledger.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TEST_ACCOUNT_1_STX_ADDRESS } from '@tests/mocks/constants';
import type { HomePage } from '@tests/page-object-models/home.page';
import { makeLedgerTestAccountWalletState } from '@tests/page-object-models/onboarding.page';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';

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

Expand All @@ -9,6 +11,13 @@ const specs = {
withBitcoinKeysOnly: makeLedgerTestAccountWalletState(['bitcoin']),
};

async function interceptBitcoinRequests(homePage: HomePage) {
const requestPromise = homePage.page.waitForRequest(/bestinslot|blockstream|inscriptions/, {
pete-watters marked this conversation as resolved.
Show resolved Hide resolved
timeout: 1000,
});
return requestPromise;
}

test.describe('App with Ledger', () => {
for (const [testName, state] of Object.entries(specs)) {
test.describe(testName, () => {
Expand All @@ -33,6 +42,17 @@ test.describe('App with Ledger', () => {
const stacksAddress = await homePage.getReceiveStxAddress();
test.expect(stacksAddress).toEqual(TEST_ACCOUNT_1_STX_ADDRESS);
});

test('there are no bitcoin requests', async ({ homePage }) => {
const requestPromise = interceptBitcoinRequests(homePage);

await homePage.page.getByTestId(SettingsSelectors.CurrentAccountDisplayName).click();

await test
.expect(async () => await test.expect(requestPromise).rejects.toThrowError())
.toPass()
.catch();
});
Comment on lines +46 to +55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Explicit error handling needed in test case.

The test case for ensuring no Bitcoin API calls is correctly structured. However, the catch block is currently empty, which may suppress errors silently. Ensure that errors are handled explicitly to catch and address any potential issues during test execution.

  • File: tests/specs/ledger/ledger.spec.ts
  • Lines: 46-55
Analysis chain

Test case for no Bitcoin API calls.

The test case is correctly structured to ensure that no Bitcoin API calls are made under specific conditions. However, ensure that the catch block is appropriately handling any potential errors that could arise during the test execution.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the error handling in the test case.

# Test: Search for error handling patterns in other tests.
rg --type python $'catch'

Length of output: 55



Script:

#!/bin/bash
# Description: Verify the error handling in the test case.

# Test: Search for error handling patterns in TypeScript tests.
rg --type typescript 'catch'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify the error handling in the test case.

# Test: Search for error handling patterns in TypeScript tests.
rg --type ts 'catch'

Length of output: 6694

}

test('that you can navigate to activity page', async ({ homePage }) => {
Expand Down
Loading