Skip to content

Commit

Permalink
Add login link to error message in fileviewer (#3377)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitvinnakota-codecov authored Oct 11, 2024
1 parent 932bfff commit d88816e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ function ErrorDisplayMessage() {
<p className="border border-solid border-ds-gray-tertiary p-4">
There was a problem getting the source code from your provider. Unable to
show line by line coverage.
<br />
<span>
If you continue to experience this issue, please try{' '}
<A
to={{
pageName: 'login',
}}
hook={undefined}
isExternal={undefined}
>
logging in
</A>{' '}
again to refresh your credentials.
</span>
</p>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,13 @@ describe('CommitFileDiff', () => {
)
expect(criticalFile).toBeInTheDocument()
})

it('renders a login link', async () => {
render(<CommitFileDiff path={'random/path'} />, { wrapper })

const link = await screen.findByText(/logging in/)
expect(link).toBeVisible()
expect(link).toHaveAttribute('href', '/login')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ function ErrorDisplayMessage() {
<p className="border border-solid border-ds-gray-tertiary p-4">
There was a problem getting the source code from your provider. Unable to
show line by line coverage.
<br />
<span>
If you continue to experience this issue, please try{' '}
<A
to={{
pageName: 'login',
}}
hook={undefined}
isExternal={undefined}
>
logging in
</A>{' '}
again to refresh your credentials.
</span>
</p>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ describe('CommitFileDiff', () => {
)
expect(criticalFile).toBeInTheDocument()
})

it('renders a login link', async () => {
render(<CommitFileDiff path={'random/path'} />, { wrapper })

const link = await screen.findByText(/logging in/)
expect(link).toBeVisible()
expect(link).toHaveAttribute('href', '/login')
})
})

describe('code renderer', () => {
Expand Down
10 changes: 10 additions & 0 deletions src/shared/RawFileViewer/RawFileViewer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ describe('RawFileViewer', () => {
)
expect(errorMessage).toBeInTheDocument()
})

it('renders a login link', async () => {
render(
<RawFileViewer title="The FileViewer" commit="cool-commit-sha" />,
{ wrapper: wrapper() }
)
const link = await screen.findByText(/logging in/)
expect(link).toBeVisible()
expect(link).toHaveAttribute('href', '/login')
})
})

describe('displaying unsupported file', () => {
Expand Down
25 changes: 19 additions & 6 deletions src/shared/RawFileViewer/RawFileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useFlags } from 'shared/featureFlags'
import { CODE_RENDERER_TYPE } from 'shared/utils/fileviewer'
import { unsupportedExtensionsMapper } from 'shared/utils/unsupportedExtensionsMapper'
import { getFilenameFromFilePath } from 'shared/utils/url'
import A from 'ui/A'
import CodeRenderer from 'ui/CodeRenderer'
import CodeRendererProgressHeader from 'ui/CodeRenderer/CodeRendererProgressHeader'
import CriticalFileLabel from 'ui/CodeRenderer/CriticalFileLabel'
Expand All @@ -21,12 +22,24 @@ import { VirtualFileRenderer } from 'ui/VirtualFileRenderer'

function ErrorDisplayMessage() {
return (
<div className="border border-solid border-ds-gray-tertiary p-4">
<p>
There was a problem getting the source code from your provider. Unable
to show line by line coverage.
</p>
</div>
<p className="border border-solid border-ds-gray-tertiary p-4">
There was a problem getting the source code from your provider. Unable to
show line by line coverage.
<br />
<span>
If you continue to experience this issue, please try{' '}
<A
to={{
pageName: 'login',
}}
hook={undefined}
isExternal={undefined}
>
logging in
</A>{' '}
again to refresh your credentials.
</span>
</p>
)
}

Expand Down

0 comments on commit d88816e

Please sign in to comment.