12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import {ProjectFixture} from 'sentry-fixture/project';
- 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', async function () {
- render(
- <ProjectQuickLinks
- organization={organization}
- location={router.location}
- project={ProjectFixture()}
- />,
- {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',
- });
- await userEvent.click(userFeedback);
- expect(router.push).toHaveBeenCalledWith({
- pathname: '/organizations/org-slug/user-feedback/',
- query: {project: '2'},
- });
- await userEvent.click(keyTransactions);
- expect(router.push).toHaveBeenCalledWith({
- pathname: '/organizations/org-slug/performance/',
- query: {project: '2'},
- });
- await 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(
- <ProjectQuickLinks
- organization={{...organization, features: []}}
- location={router.location}
- project={ProjectFixture()}
- />,
- {context: routerContext}
- );
- const keyTransactions = screen.getByText('View Transactions');
- await userEvent.click(keyTransactions);
- expect(router.push).toHaveBeenCalledTimes(0);
- await userEvent.hover(keyTransactions);
- expect(
- await screen.findByText("You don't have access to this feature")
- ).toBeInTheDocument();
- });
- });
|