import {initializeOrg} from 'sentry-test/initializeOrg';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import ProjectQuickLinks from 'sentry/views/projectDetail/projectQuickLinks';
describe('ProjectDetail > ProjectQuickLinks', function () {
const {organization, router, routerContext} = initializeOrg({
organization: {features: ['performance-view']},
});
afterEach(() => {
jest.clearAllMocks();
});
it('renders a list', function () {
render(
,
{context: routerContext}
);
expect(screen.getByRole('heading', {name: 'Quick Links'})).toBeInTheDocument();
expect(screen.getAllByRole('link')).toHaveLength(3);
const userFeedback = screen.getByRole('link', {name: 'User Feedback'});
const keyTransactions = screen.getByRole('link', {name: 'View Transactions'});
const mostChangedTransactions = screen.getByRole('link', {
name: 'Most Improved/Regressed Transactions',
});
userEvent.click(userFeedback);
expect(router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/user-feedback/',
query: {project: '2'},
});
userEvent.click(keyTransactions);
expect(router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/performance/',
query: {project: '2'},
});
userEvent.click(mostChangedTransactions);
expect(router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/performance/trends/',
query: {
cursor: undefined,
project: '2',
query: 'tpm():>0.01 transaction.duration:>0 transaction.duration:<15min',
},
});
});
it('disables link if feature is missing', async function () {
render(
,
{context: routerContext}
);
const keyTransactions = screen.getByText('View Transactions');
userEvent.click(keyTransactions);
expect(router.push).toHaveBeenCalledTimes(0);
userEvent.hover(keyTransactions);
expect(
await screen.findByText("You don't have access to this feature")
).toBeInTheDocument();
});
});