Skip to content

Commit

Permalink
Fix CI (#228)
Browse files Browse the repository at this point in the history
* Wait for CircularProgress to be removed in cypress tests

* Add retry mechanism in NetworkContext

* Increase CircularProgress timeout in cypress tests
  • Loading branch information
ThibautBremand authored Aug 6, 2023
1 parent 7041acd commit a75b237
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/extension/cypress/e2e/networks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe('Switch networks', () => {
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');

// Login
cy.get('input[name="password"]').type(PASSWORD);
cy.contains('button', 'Unlock').click();
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/cypress/e2e/send_token.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('Send Token', () => {
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');

// Login
cy.get('input[name="password"]').type(PASSWORD);
cy.contains('button', 'Unlock').click();
Expand Down
10 changes: 10 additions & 0 deletions packages/extension/cypress/e2e/wallet_management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('Setup the initial wallet (no previous wallet)', () => {
cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({});
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');
});

it('Create a new wallet', () => {
Expand Down Expand Up @@ -241,6 +243,8 @@ describe('Add an additional wallet (with previous wallet)', () => {
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');

// Login
cy.get('input[name="password"]').type(PASSWORD);
cy.contains('button', 'Unlock').click();
Expand Down Expand Up @@ -400,6 +404,8 @@ describe('Edit wallet', () => {
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');

// Login
cy.get('input[name="password"]').type(PASSWORD);
cy.contains('button', 'Unlock').click();
Expand Down Expand Up @@ -537,6 +543,8 @@ describe('Switch wallet', () => {
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');

// Login
cy.get('input[name="password"]').type(PASSWORD);
cy.contains('button', 'Unlock').click();
Expand Down Expand Up @@ -590,6 +598,8 @@ describe('Reset password', () => {
cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({});
}
});

cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist');
});

it('Reset password', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const NetworkProvider: FC = ({ children }) => {
const [network, setNetwork] = useState<Network | string>();

useEffect(() => {
let retryCount = 0;
const maxRetries = 3;

const connectToNetwork = async () => {
const network = loadNetwork();
const ws = new Client(network.server);
Expand All @@ -52,6 +55,12 @@ const NetworkProvider: FC = ({ children }) => {
await ws?.disconnect();
setClient(null);
Sentry.captureException(err);

// If connect fails, retry up to maxRetries times
if (retryCount < maxRetries) {
retryCount += 1;
setTimeout(connectToNetwork, 1000);
}
}
};

Expand Down

0 comments on commit a75b237

Please sign in to comment.