|
@@ -5,7 +5,6 @@ import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
|
|
|
|
|
|
import type {Organization as TOrganization} from 'sentry/types';
|
|
|
import useDeadRageSelectors from 'sentry/utils/replays/hooks/useDeadRageSelectors';
|
|
|
-import useReplayList from 'sentry/utils/replays/hooks/useReplayList';
|
|
|
import {
|
|
|
useHaveSelectedProjectsSentAnyReplayEvents,
|
|
|
useReplayOnboardingSidebarPanel,
|
|
@@ -14,26 +13,12 @@ import useOrganization from 'sentry/utils/useOrganization';
|
|
|
import useProjectSdkNeedsUpdate from 'sentry/utils/useProjectSdkNeedsUpdate';
|
|
|
import ListPage from 'sentry/views/replays/list/listContent';
|
|
|
|
|
|
-jest.mock('sentry/utils/replays/hooks/useReplayOnboarding');
|
|
|
jest.mock('sentry/utils/replays/hooks/useDeadRageSelectors');
|
|
|
+jest.mock('sentry/utils/replays/hooks/useReplayOnboarding');
|
|
|
jest.mock('sentry/utils/replays/hooks/useReplayPageview');
|
|
|
jest.mock('sentry/utils/useOrganization');
|
|
|
jest.mock('sentry/utils/useProjectSdkNeedsUpdate');
|
|
|
-jest.mock('sentry/utils/replays/hooks/useReplayList', () => {
|
|
|
- return {
|
|
|
- __esModule: true,
|
|
|
- default: jest.fn(() => {
|
|
|
- return {
|
|
|
- fetchError: undefined,
|
|
|
- isFetching: false,
|
|
|
- pageLinks: null,
|
|
|
- replays: [],
|
|
|
- };
|
|
|
- }),
|
|
|
- };
|
|
|
-});
|
|
|
|
|
|
-const mockUseReplayList = jest.mocked(useReplayList);
|
|
|
const mockUseDeadRageSelectors = jest.mocked(useDeadRageSelectors);
|
|
|
|
|
|
const mockUseHaveSelectedProjectsSentAnyReplayEvents = jest.mocked(
|
|
@@ -63,8 +48,8 @@ function getMockContext(mockOrg: TOrganization) {
|
|
|
}
|
|
|
|
|
|
describe('ReplayList', () => {
|
|
|
+ let mockFetchReplayListRequest;
|
|
|
beforeEach(() => {
|
|
|
- mockUseReplayList.mockClear();
|
|
|
mockUseHaveSelectedProjectsSentAnyReplayEvents.mockClear();
|
|
|
mockUseProjectSdkNeedsUpdate.mockClear();
|
|
|
mockUseDeadRageSelectors.mockClear();
|
|
@@ -73,6 +58,10 @@ describe('ReplayList', () => {
|
|
|
url: '/organizations/org-slug/tags/',
|
|
|
body: [],
|
|
|
});
|
|
|
+ mockFetchReplayListRequest = MockApiClient.addMockResponse({
|
|
|
+ url: `/organizations/org-slug/replays/`,
|
|
|
+ body: {},
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
it('should render the onboarding panel when the org is on AM1', async () => {
|
|
@@ -94,7 +83,7 @@ describe('ReplayList', () => {
|
|
|
await waitFor(() =>
|
|
|
expect(screen.getByText('Get to the root cause faster')).toBeInTheDocument()
|
|
|
);
|
|
|
- expect(mockUseReplayList).not.toHaveBeenCalled();
|
|
|
+ expect(mockFetchReplayListRequest).not.toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
it('should render the onboarding panel when the org is on AM1 and has sent some replays', async () => {
|
|
@@ -116,7 +105,7 @@ describe('ReplayList', () => {
|
|
|
await waitFor(() =>
|
|
|
expect(screen.getByText('Get to the root cause faster')).toBeInTheDocument()
|
|
|
);
|
|
|
- expect(mockUseReplayList).not.toHaveBeenCalled();
|
|
|
+ expect(mockFetchReplayListRequest).not.toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
it('should render the onboarding panel when the org is on AM2 and has never sent a replay', async () => {
|
|
@@ -138,7 +127,7 @@ describe('ReplayList', () => {
|
|
|
await waitFor(() =>
|
|
|
expect(screen.getByText('Get to the root cause faster')).toBeInTheDocument()
|
|
|
);
|
|
|
- expect(mockUseReplayList).not.toHaveBeenCalled();
|
|
|
+ expect(mockFetchReplayListRequest).not.toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
it('should render the rage-click sdk update banner when the org is AM2, has sent replays, but the sdk version is low', async () => {
|
|
@@ -152,12 +141,6 @@ describe('ReplayList', () => {
|
|
|
isFetching: false,
|
|
|
needsUpdate: true,
|
|
|
});
|
|
|
- mockUseReplayList.mockReturnValue({
|
|
|
- replays: [],
|
|
|
- isFetching: false,
|
|
|
- fetchError: undefined,
|
|
|
- pageLinks: null,
|
|
|
- });
|
|
|
|
|
|
render(<ListPage />, {
|
|
|
context: getMockContext(mockOrg),
|
|
@@ -167,7 +150,7 @@ describe('ReplayList', () => {
|
|
|
expect(screen.queryByText('Introducing Rage and Dead Clicks')).toBeInTheDocument();
|
|
|
expect(screen.queryByTestId('replay-table')).toBeInTheDocument();
|
|
|
});
|
|
|
- expect(mockUseReplayList).toHaveBeenCalled();
|
|
|
+ expect(mockFetchReplayListRequest).toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
it('should fetch the replay table and show selector tables when the org is on AM2, has sent some replays, and has a newer SDK version', async () => {
|
|
@@ -181,12 +164,6 @@ describe('ReplayList', () => {
|
|
|
isFetching: false,
|
|
|
needsUpdate: false,
|
|
|
});
|
|
|
- mockUseReplayList.mockReturnValue({
|
|
|
- replays: [],
|
|
|
- isFetching: false,
|
|
|
- fetchError: undefined,
|
|
|
- pageLinks: null,
|
|
|
- });
|
|
|
mockUseDeadRageSelectors.mockReturnValue({
|
|
|
isLoading: false,
|
|
|
isError: false,
|
|
@@ -202,6 +179,6 @@ describe('ReplayList', () => {
|
|
|
await waitFor(() =>
|
|
|
expect(screen.queryAllByTestId('selector-widget')).toHaveLength(2)
|
|
|
);
|
|
|
- expect(mockUseReplayList).toHaveBeenCalled();
|
|
|
+ expect(mockFetchReplayListRequest).toHaveBeenCalled();
|
|
|
});
|
|
|
});
|