Skip to content

Commit bd3fab8

Browse files
authored
Job url (#151)
1 parent a5fa1a6 commit bd3fab8

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

src/components/app/CICommitLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ export const CICommitLink: React.FunctionComponent<IProps> = ({ ci: ci }) => {
1616
return (
1717
<>
1818
<FontAwesomeIcon icon={faLink} />
19-
<a href={commitLink}>{ci.git.revision.substring(0, 7)}</a>
19+
Git Ref <a href={commitLink}>{ci.git.revision.substring(0, 7)}</a>
2020
</>
2121
)
2222
}
2323
return (
2424
<>
25-
<FontAwesomeIcon icon={faLink} /> {ci.git?.revision.substring(0, 7)}
25+
<FontAwesomeIcon icon={faLink} /> Git Ref {ci.git?.revision.substring(0, 7)}
2626
</>
2727
)
2828
}

src/components/app/CIJobLink.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as messages from '@cucumber/messages'
2+
import { faLink } from '@fortawesome/free-solid-svg-icons'
3+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4+
import React from 'react'
5+
6+
interface IProps {
7+
ci: messages.Ci
8+
}
9+
10+
export const CIJobLink: React.FunctionComponent<IProps> = ({ ci: ci }) => {
11+
if (ci.url && ci.buildNumber) {
12+
return (
13+
<>
14+
<FontAwesomeIcon icon={faLink} />
15+
Job <a href={ci.url}> {ci.buildNumber}</a>
16+
</>
17+
)
18+
}
19+
return <></>
20+
}

src/components/app/ExecutionSummary.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,11 @@ describe('ExecutionSummary', () => {
128128

129129
expect(getByText('cucumber-js 8.0.0-rc.1')).toBeVisible()
130130
})
131+
it('should include the job link', () => {
132+
const { getByText } = render(<ExecutionSummary {...DEFAULT_PROPS} />)
133+
const jobLinkElement = getByText(DEFAULT_PROPS.meta?.ci?.buildNumber as string)
134+
expect(jobLinkElement).toBeVisible()
135+
expect(jobLinkElement.getAttribute('href')).toEqual(DEFAULT_PROPS.meta?.ci?.url)
136+
})
131137
})
132138
})

src/components/app/ExecutionSummary.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { formatDistanceStrict, formatDuration, intervalToDuration } from 'date-f
1111
import React from 'react'
1212

1313
import { CICommitLink } from './CICommitLink'
14+
import { CIJobLink } from './CIJobLink'
1415
import styles from './ExecutionSummary.module.scss'
1516
import { CucumberLogo } from './icons/CucumberLogo'
1617
import { OSIcon } from './OSIcon'
@@ -98,6 +99,9 @@ export const ExecutionSummary: React.FunctionComponent<IExecutionSummaryProps> =
9899
<span className={styles.gitItem}>
99100
<CICommitLink ci={meta.ci} />
100101
</span>
102+
<span className={styles.gitItem}>
103+
<CIJobLink ci={meta.ci} />
104+
</span>
101105
</>
102106
) : (
103107
'-'

0 commit comments

Comments
 (0)