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: App navigation #50

Merged
merged 2 commits into from
Jul 17, 2023
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
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.5.2] - 2023-07-18

- `Staking`
- Fix applied to bring the app navigation to its normal flow.

## [3.5.1] - 2023-07-12

- `Staking`
Expand Down Expand Up @@ -327,8 +332,9 @@ Staking Pools

- First release

[unreleased]: https://github.com/cartesi/explorer/compare/v3.5.1...HEAD
[3.5.0]: https://github.com/cartesi/explorer/compare/v3.5.0...v3.5.1
[unreleased]: https://github.com/cartesi/explorer/compare/v3.5.2...HEAD
[3.5.2]: https://github.com/cartesi/explorer/compare/v3.5.1...v3.5.2
[3.5.1]: https://github.com/cartesi/explorer/compare/v3.5.0...v3.5.1
[3.5.0]: https://github.com/cartesi/explorer/compare/v3.4.0...v3.5.0
[3.4.0]: https://github.com/cartesi/explorer/compare/v3.3.0...v3.4.0
[3.3.0]: https://github.com/cartesi/explorer/compare/v3.2.2...v3.3.0
Expand Down
26 changes: 19 additions & 7 deletions apps/staking/__tests__/contexts/ga4Tracker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public License for more details.

import { render, waitFor, act } from '@testing-library/react';
import ReactGA from 'react-ga4';
import { useWallet } from '@explorer/wallet/src/useWallet';
import { act, render, waitFor } from '@testing-library/react';
import ReactGA from 'react-ga4';
import {
measurementID,
anonymizeUser,
GA4TrackerProvider,
CustomDimensions,
GA4TrackerProvider,
anonymizeUser,
measurementID,
} from '../../src/contexts/ga4Tracker';
import { Network } from '../../src/utils/networks';

Expand All @@ -41,11 +41,14 @@ const mockedSet = ReactGA.set as jest.MockedFunction<typeof ReactGA.set>;
const mockUseWallet = useWallet as jest.MockedFunction<typeof useWallet>;

const account = '0x907eA0e65Ecf3af503007B382E1280Aeb46104ad';
const activate = jest.fn();
const deactivate = jest.fn();

const walletMock = {
account,
active: true,
activate: jest.fn(),
deactivate: jest.fn(),
activate,
deactivate,
chainId: Network.MAINNET,
walletName: 'Wallet ABC',
};
Expand Down Expand Up @@ -103,11 +106,16 @@ describe('ga4Tracker context', () => {
};
const mockedImplementation = jest.fn();
mockedEvent.mockImplementation(mockedImplementation);

//Wallet is not connected
mockUseWallet.mockReturnValue({ active: false, activate, deactivate });
const { rerender } = render(
<GA4TrackerProvider>Content</GA4TrackerProvider>
);

await act(() => {
// Return wallet information and rerender
mockUseWallet.mockReturnValue(walletMock);
rerender(<GA4TrackerProvider>Content</GA4TrackerProvider>);
});

Expand All @@ -127,11 +135,15 @@ describe('ga4Tracker context', () => {
};
const mockedImplementation = jest.fn();
mockedSet.mockImplementation(mockedImplementation);
//Wallet is not connected
mockUseWallet.mockReturnValue({ active: false, activate, deactivate });
const { rerender } = render(
<GA4TrackerProvider>Content</GA4TrackerProvider>
);

await act(() => {
// Return wallet information and rerender
mockUseWallet.mockReturnValue(walletMock);
rerender(<GA4TrackerProvider>Content</GA4TrackerProvider>);
});

Expand Down
8 changes: 4 additions & 4 deletions apps/staking/src/contexts/ga4Tracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public License for more details.

import { createContext, ReactNode, useState, useEffect } from 'react';
import ReactGA from 'react-ga4';
import { useWallet } from '@explorer/wallet';
import { ReactNode, createContext, useEffect, useState } from 'react';
import ReactGA from 'react-ga4';

export const measurementID = 'G-0J9KC579GV';

Expand Down Expand Up @@ -60,7 +60,7 @@ const GA4TrackerProvider = (props: TrackingProviderProps) => {
hasUser: !!account,
}));
}
}, [account, analytics]);
}, [account]);

useEffect(() => {
const { isInitialised } = analytics;
Expand All @@ -70,7 +70,7 @@ const GA4TrackerProvider = (props: TrackingProviderProps) => {
};
ReactGA.event('Wallet Selection', params);
}
}, [analytics, walletName]);
}, [walletName]);

// is returning nothing as context-value at the moment
return (
Expand Down