|
@@ -288,4 +288,80 @@ describe('StacktraceLink', function () {
|
|
|
});
|
|
|
expect(await screen.findByTestId('codecov-link')).toBeInTheDocument();
|
|
|
});
|
|
|
+
|
|
|
+ it('renders the link using a valid sourceLink for a .NET project', async function () {
|
|
|
+ const dotnetFrame = {
|
|
|
+ sourceLink: 'https://www.github.com/username/path/to/file.py#L100',
|
|
|
+ lineNo: '100',
|
|
|
+ } as unknown as Frame;
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/projects/${org.slug}/${project.slug}/stacktrace-link/`,
|
|
|
+ body: {
|
|
|
+ config,
|
|
|
+ integrations: [integration],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ render(
|
|
|
+ <StacktraceLink
|
|
|
+ frame={dotnetFrame}
|
|
|
+ event={{...event, platform: 'csharp'}}
|
|
|
+ line="foo()"
|
|
|
+ />,
|
|
|
+ {
|
|
|
+ context: TestStubs.routerContext(),
|
|
|
+ }
|
|
|
+ );
|
|
|
+ expect(await screen.findByRole('link')).toHaveAttribute(
|
|
|
+ 'href',
|
|
|
+ 'https://www.github.com/username/path/to/file.py#L100'
|
|
|
+ );
|
|
|
+ expect(screen.getByText('Open this line in GitHub')).toBeInTheDocument();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('renders the link using sourceUrl instead of sourceLink if it exists for a .NET project', async function () {
|
|
|
+ const dotnetFrame = {
|
|
|
+ sourceLink: 'https://www.github.com/source/link/url#L1',
|
|
|
+ lineNo: '1',
|
|
|
+ } as unknown as Frame;
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/projects/${org.slug}/${project.slug}/stacktrace-link/`,
|
|
|
+ body: {
|
|
|
+ config,
|
|
|
+ sourceUrl: 'https://www.github.com/url/from/code/mapping',
|
|
|
+ integrations: [integration],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ render(
|
|
|
+ <StacktraceLink
|
|
|
+ frame={dotnetFrame}
|
|
|
+ event={{...event, platform: 'csharp'}}
|
|
|
+ line="foo()"
|
|
|
+ />,
|
|
|
+ {
|
|
|
+ context: TestStubs.routerContext(),
|
|
|
+ }
|
|
|
+ );
|
|
|
+ expect(await screen.findByRole('link')).toHaveAttribute(
|
|
|
+ 'href',
|
|
|
+ 'https://www.github.com/url/from/code/mapping#L1'
|
|
|
+ );
|
|
|
+ expect(screen.getByText('Open this line in GitHub')).toBeInTheDocument();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('hides stacktrace link if there is no source link for .NET projects', async function () {
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/projects/${org.slug}/${project.slug}/stacktrace-link/`,
|
|
|
+ body: {
|
|
|
+ config,
|
|
|
+ integrations: [integration],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const {container} = render(
|
|
|
+ <StacktraceLink frame={frame} event={{...event, platform: 'csharp'}} line="" />,
|
|
|
+ {context: TestStubs.routerContext()}
|
|
|
+ );
|
|
|
+ await waitFor(() => {
|
|
|
+ expect(container).toBeEmptyDOMElement();
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|