123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import {GroupFixture} from 'sentry-fixture/group';
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import {ShortIdBreadcrumb} from './shortIdBreadcrumb';
- describe('ShortIdBreadcrumb', function () {
- const {organization, project} = initializeOrg();
- const group = GroupFixture({shortId: 'ABC-123'});
- beforeEach(() => {
- Object.assign(navigator, {
- clipboard: {writeText: jest.fn().mockResolvedValue('')},
- });
- });
- it('renders short ID', function () {
- render(<ShortIdBreadcrumb {...{organization, project, group}} />);
- expect(screen.getByText('ABC-123')).toBeInTheDocument();
- });
- it('supports copy', async function () {
- render(<ShortIdBreadcrumb {...{organization, project, group}} />);
- async function clickMenuItem(name: string) {
- await userEvent.click(screen.getByRole('button', {name: 'Short-ID copy actions'}));
- await userEvent.click(screen.getByRole('menuitemradio', {name}));
- }
- // Copy short ID
- await clickMenuItem('Copy Short-ID');
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith('ABC-123');
- // Copy short ID URL
- await clickMenuItem('Copy Issue URL');
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
- 'http://localhost/organizations/org-slug/issues/1/'
- );
- // Copy short ID Markdown
- await clickMenuItem('Copy Markdown Link');
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
- '[ABC-123](http://localhost/organizations/org-slug/issues/1/)'
- );
- });
- });
|