mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import {GroupFixture} from 'sentry-fixture/group';
|
|
|
|
import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
|
|
|
|
import {ShortIdBreadrcumb} from './shortIdBreadcrumb';
|
|
|
|
describe('ShortIdBreadrcumb', 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(<ShortIdBreadrcumb {...{organization, project, group}} />);
|
|
|
|
expect(screen.getByText('ABC-123')).toBeInTheDocument();
|
|
});
|
|
|
|
it('supports copy', async function () {
|
|
render(<ShortIdBreadrcumb {...{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/)'
|
|
);
|
|
});
|
|
});
|