Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {OrganizationFixture} from 'sentry-fixture/organization';
import {ProjectFixture} from 'sentry-fixture/project';

import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';

import PageFiltersStore from 'sentry/stores/pageFiltersStore';
import ProjectsStore from 'sentry/stores/projectsStore';
Expand All @@ -14,8 +14,6 @@ describe('PageOverviewSidebar', () => {
const organization = OrganizationFixture({
features: ['performance-web-vitals-seer-suggestions', 'gen-ai-features'],
});
let userIssueMock: jest.Mock;
let eventsMock: jest.Mock;
let seerSetupCheckMock: jest.Mock;
let seerPreferencesMock: jest.Mock;

Expand Down Expand Up @@ -53,13 +51,6 @@ describe('PageOverviewSidebar', () => {
},
});

eventsMock = MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events/`,
body: {
data: [{trace: '123', timestamp: '2025-01-01T00:00:00Z'}],
},
});

MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/issues/`,
body: [
Expand Down Expand Up @@ -89,12 +80,6 @@ describe('PageOverviewSidebar', () => {
},
},
});

userIssueMock = MockApiClient.addMockResponse({
url: `/projects/${organization.slug}/${project.slug}/user-issue/`,
body: {event_id: '123'},
method: 'POST',
});
});

afterEach(() => {
Expand Down Expand Up @@ -218,110 +203,5 @@ describe('PageOverviewSidebar', () => {
).toBeInTheDocument();
expect(screen.getByText('View Suggestion')).toBeInTheDocument();
});

it('should create issues when run seer analysis button is clicked', async () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/issues/`,
body: [],
});
render(
<PageOverviewSidebar
transaction={TRANSACTION_NAME}
projectScore={{lcpScore: 80}}
projectData={[
{
'p75(measurements.lcp)': 1000,
'p75(measurements.cls)': 0.1,
'p75(measurements.fcp)': 1800,
'p75(measurements.ttfb)': 600,
'p75(measurements.inp)': 200,
},
]}
/>,
{organization}
);
const runSeerAnalysisButton = await screen.findByText('Run Seer Analysis');
expect(runSeerAnalysisButton).toBeInTheDocument();
await userEvent.click(runSeerAnalysisButton);
expect(userIssueMock).toHaveBeenCalledWith(
'/projects/org-slug/project-slug/user-issue/',
expect.objectContaining({
method: 'POST',
data: expect.objectContaining({
issueType: 'web_vitals',
vital: 'lcp',
score: 80,
value: 1000,
transaction: TRANSACTION_NAME,
}),
})
);
expect(screen.queryByText('Run Seer Analysis')).not.toBeInTheDocument();
});

it('should create multiple issues with trace ids when run seer analysis button is clicked', async () => {
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/issues/`,
body: [],
});
render(
<PageOverviewSidebar
transaction={TRANSACTION_NAME}
projectScore={{
lcpScore: 80,
clsScore: 80,
fcpScore: 80,
ttfbScore: 100,
inpScore: 80,
}}
projectData={[
{
'p75(measurements.lcp)': 2500,
'p75(measurements.cls)': 0.1,
'p75(measurements.fcp)': 1800,
'p75(measurements.ttfb)': 600,
'p75(measurements.inp)': 200,
},
]}
/>,
{organization}
);

const runSeerAnalysisButton = await screen.findByText('Run Seer Analysis');
expect(runSeerAnalysisButton).toBeInTheDocument();
expect(eventsMock).toHaveBeenCalledTimes(5);
await userEvent.click(runSeerAnalysisButton);
['lcp', 'cls', 'fcp', 'inp'].forEach(vital => {
expect(userIssueMock).toHaveBeenCalledWith(
'/projects/org-slug/project-slug/user-issue/',
expect.objectContaining({
method: 'POST',
data: expect.objectContaining({
issueType: 'web_vitals',
vital,
score: 80,
transaction: TRANSACTION_NAME,
traceId: '123',
}),
})
);
});
// TTFB has a score over 90, so it should not be created as an issue
expect(userIssueMock).not.toHaveBeenCalledWith(
'/projects/org-slug/project-slug/user-issue/',
expect.objectContaining({
method: 'POST',
data: expect.objectContaining({
issueType: 'web_vitals',
vital: 'ttfb',
score: 100,
transaction: TRANSACTION_NAME,
traceId: '123',
timestamp: '2025-01-01T00:00:00Z',
}),
})
);
expect(screen.queryByText('Run Seer Analysis')).not.toBeInTheDocument();
});
});
});
Loading
Loading