Skip to content

Commit

Permalink
test(suite): reload during discovery to test proper cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Feb 11, 2025
1 parent 2400a1a commit 01c8b59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/connect/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,11 @@ const onCallDevice = async (
// TODO: This requires a massive refactoring https://github.com/trezor/trezor-suite/issues/5323
// @ts-expect-error TODO: messageResponse should be assigned from the response of "inner" function
const response = messageResponse;

if (response) {
// todo: shouldReleaseSession should probably be removed (it was added recently). it looks like that we could
// receive 'disconnected during action' which does not mean that device got physically disconnected.
// see
// https://github.com/trezor/trezord-go/blob/db03d99230f5b609a354e3586f1dfc0ad6da16f7/usb/libusb.go#L545
const shouldReleaseSession =
response.success ||
(!response.success &&
Expand Down
14 changes: 14 additions & 0 deletions packages/suite-web/e2e/tests/wallet/discovery.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @group_wallet
// @retry=2

import { getRandomInt } from '@trezor/utils';

import { onNavBar } from '../../support/pageObjects/topBarObject';

// discovery should end within this time frame
Expand Down Expand Up @@ -29,6 +31,18 @@ describe('Discovery', () => {
cy.log('all available networks should return something from discovery');

cy.getTestElement('@dashboard/loading', { timeout: 1000 * 10 });

// wait randomly between 1000 and 3000 ms
cy.wait(getRandomInt(1, 40) * 100);
// trigger reload to simulate interruption. we want to make sure that communication with the device does not
// end up in some de-synced state. if this test becomes flaky, this reload might be the reason.
cy.reload();

// device appears as connected
cy.getTestElement('@deviceStatus-connected');
// dashboard is still loading, discovery starts, no error appears
cy.getTestElement('@dashboard/loading');

cy.getTestElement('@dashboard/loading', { timeout: DISCOVERY_LIMIT }).should('not.exist');
['btc', ...coinsToActivate].forEach(symbol => {
cy.getTestElement(`@wallet/coin-balance/value-${symbol}`);
Expand Down

0 comments on commit 01c8b59

Please sign in to comment.