123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- import {ProjectFixture} from 'sentry-fixture/project';
- import {render, screen} from 'sentry-test/reactTestingLibrary';
- import usePageFilters from 'sentry/utils/usePageFilters';
- import useProjects from 'sentry/utils/useProjects';
- import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
- import {ModuleName} from 'sentry/views/insights/types';
- import {ModulesOnboarding} from './modulesOnboarding';
- jest.mock('sentry/utils/useProjects');
- jest.mock('sentry/utils/usePageFilters');
- jest.mock('sentry/views/insights/common/queries/useOnboardingProject');
- describe('ModulesOnboarding', () => {
- afterEach(() => {
- jest.resetAllMocks();
- });
- it('renders children correctly', async () => {
- const project = ProjectFixture({hasInsightsCaches: true});
- project.firstTransactionEvent = true;
- project.hasInsightsCaches = true;
- jest.mocked(useProjects).mockReturnValue({
- projects: [project],
- onSearch: jest.fn(),
- reloadProjects: jest.fn(),
- placeholders: [],
- fetching: false,
- hasMore: null,
- fetchError: null,
- initiallyLoaded: false,
- });
- jest.mocked(useOnboardingProject).mockReturnValue(undefined);
- jest.mocked(usePageFilters).mockReturnValue({
- isReady: true,
- desyncedFilters: new Set(),
- pinnedFilters: new Set(),
- shouldPersist: true,
- selection: {
- datetime: {
- period: '10d',
- start: null,
- end: null,
- utc: false,
- },
- environments: [],
- projects: [2],
- },
- });
- render(
- <ModulesOnboarding moduleName={ModuleName.CACHE}>
- <div>Module Content</div>
- </ModulesOnboarding>
- );
- await screen.getByText('Module Content');
- });
- it('renders onboarding content correctly', async () => {
- const project = ProjectFixture();
- jest.mocked(useProjects).mockReturnValue({
- projects: [project],
- onSearch: jest.fn(),
- reloadProjects: jest.fn(),
- placeholders: [],
- fetching: false,
- hasMore: null,
- fetchError: null,
- initiallyLoaded: false,
- });
- jest.mocked(usePageFilters).mockReturnValue({
- isReady: true,
- desyncedFilters: new Set(),
- pinnedFilters: new Set(),
- shouldPersist: true,
- selection: {
- datetime: {
- period: '10d',
- start: null,
- end: null,
- utc: false,
- },
- environments: [],
- projects: [2],
- },
- });
- render(
- <ModulesOnboarding moduleName={ModuleName.CACHE}>
- <div>Module Content</div>
- </ModulesOnboarding>
- );
- await screen.findByText('Bringing you one less hard problem in computer science');
- });
- it('renders performance onboarding if onboardingProject', async () => {
- const project = ProjectFixture();
- jest.mocked(useOnboardingProject).mockReturnValue(project);
- jest.mocked(useProjects).mockReturnValue({
- projects: [project],
- onSearch: jest.fn(),
- reloadProjects: jest.fn(),
- placeholders: [],
- fetching: false,
- hasMore: null,
- fetchError: null,
- initiallyLoaded: false,
- });
- jest.mocked(usePageFilters).mockReturnValue({
- isReady: true,
- desyncedFilters: new Set(),
- pinnedFilters: new Set(),
- shouldPersist: true,
- selection: {
- datetime: {
- period: '10d',
- start: null,
- end: null,
- utc: false,
- },
- environments: [],
- projects: [2],
- },
- });
- render(
- <ModulesOnboarding moduleName={ModuleName.CACHE}>
- <div>Module Content</div>
- </ModulesOnboarding>
- );
- await screen.findByText('Pinpoint problems');
- });
- });
|