storeEventMetric({
owner,
@@ -98,7 +98,7 @@ function WorkflowYMLStep({
})
}
>
- {frameworkInstructions[framework].workflow}
+ {frameworkInstructions[framework].githubActionsWorkflow}
{
return { user }
}
- describe('step one', () => {
+ describe('output coverage step', () => {
it('renders header', async () => {
setup({})
render(, { wrapper })
- const header = await screen.findByText(/Step 1/)
+ const header = await screen.findByText(
+ /Step \d: Output a Coverage report file in your CI/
+ )
+ expect(header).toBeInTheDocument()
+ })
+
+ it('renders body', async () => {
+ setup({})
+ render(, { wrapper })
+
+ const body = await screen.findByText(/Select your language below/)
+ expect(body).toBeInTheDocument()
+
+ const jest = await screen.findByText(/Jest/)
+ expect(jest).toBeInTheDocument()
+ })
+ })
+
+ describe('token step', () => {
+ it('renders header', async () => {
+ setup({})
+ render(, { wrapper })
+
+ const header = await screen.findByText(
+ /Step \d: add repository token as a secret to your CI Provider/
+ )
expect(header).toBeInTheDocument()
})
@@ -151,12 +176,12 @@ describe('OtherCI', () => {
})
})
- describe('step two', () => {
+ describe('install step', () => {
beforeEach(() => setup({}))
it('renders header', async () => {
render(, { wrapper })
- const header = await screen.findByText(/Step 2/)
+ const header = await screen.findByText(/Step \d: add the/)
expect(header).toBeInTheDocument()
const headerLink = await screen.findByRole('link', {
@@ -177,12 +202,14 @@ describe('OtherCI', () => {
})
})
- describe('step three', () => {
+ describe('upload step', () => {
it('renders header', async () => {
setup({})
render(, { wrapper })
- const header = await screen.findByText(/Step 3/)
+ const header = await screen.findByText(
+ /Step \d: upload coverage to Codecov via the CLI after your tests have run/
+ )
expect(header).toBeInTheDocument()
})
@@ -231,8 +258,17 @@ describe('OtherCI', () => {
})
})
- describe('step four', () => {
+ describe('merge step', () => {
beforeEach(() => setup({}))
+ it('renders header', async () => {
+ render(, { wrapper })
+
+ const header = await screen.findByText(
+ /Step \d: merge to main or your preferred feature branch/
+ )
+ expect(header).toBeInTheDocument()
+ })
+
it('renders body', async () => {
render(, { wrapper })
diff --git a/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.tsx b/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.tsx
index f2820b49c1..3504b7d24c 100644
--- a/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.tsx
+++ b/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.tsx
@@ -1,3 +1,4 @@
+import { useState } from 'react'
import { useParams } from 'react-router-dom'
import config from 'config'
@@ -13,6 +14,11 @@ import { InstructionBox } from './TerminalInstructions'
import ExampleBlurb from '../ExampleBlurb'
import LearnMoreBlurb from '../LearnMoreBlurb'
+import OutputCoverageStep from '../OutputCoverageStep/OutputCoverageStep'
+import {
+ Framework,
+ UseFrameworkInstructions,
+} from '../UseFrameworkInstructions'
interface URLParams {
provider: string
@@ -40,12 +46,25 @@ function OtherCI() {
orgUploadToken ? ` -r ${owner}/${repo}` : ''
}`
+ const [framework, setFramework] = useState('Jest')
+ const frameworkInstruction = UseFrameworkInstructions({
+ orgUploadToken,
+ owner,
+ repo,
+ })
+
return (
-
-
-
-
+
+
+
+
+
@@ -54,17 +73,17 @@ function OtherCI() {
export default OtherCI
-interface Step1Props {
+interface TokenStepProps {
tokenCopy: string
uploadToken: string
}
-function Step1({ tokenCopy, uploadToken }: Step1Props) {
+function TokenStep({ tokenCopy, uploadToken }: TokenStepProps) {
return (
- Step 1: add {tokenCopy} token as a secret to your CI Provider
+ Step 2: add {tokenCopy} token as a secret to your CI Provider
@@ -81,12 +100,12 @@ function Step1({ tokenCopy, uploadToken }: Step1Props) {
)
}
-function Step2() {
+function InstallStep() {
return (
- Step 2: add the{' '}
+ Step 3: add the{' '}
- Step 3: upload coverage to Codecov via the CLI after your tests have
+ Step 4: upload coverage to Codecov via the CLI after your tests have
run
@@ -126,12 +145,12 @@ function Step3({ uploadCommand }: Step3Props) {
)
}
-function Step4() {
+function MergeStep() {
return (
- Step 4: merge to main or your preferred feature branch
+ Step 5: merge to main or your preferred feature branch
diff --git a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.test.tsx b/src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.test.tsx
similarity index 96%
rename from src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.test.tsx
rename to src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.test.tsx
index 23db3782be..5a6775e174 100644
--- a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.test.tsx
+++ b/src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.test.tsx
@@ -12,6 +12,8 @@ import { ThemeContextProvider } from 'shared/ThemeContext'
import OutputCoverageStep from './OutputCoverageStep'
+import { Framework, FrameworkInstructions } from '../UseFrameworkInstructions'
+
vi.mock('config')
const server = setupServer()
@@ -69,27 +71,27 @@ describe('OutputCoverageStep', () => {
}
}
- const framework = 'Jest'
- const frameworkInstructions = {
+ const framework: Framework = 'Jest'
+ const frameworkInstructions: FrameworkInstructions = {
Jest: {
install: 'npm install --save-dev jest',
run: 'npx jest --coverage',
- workflow: undefined,
+ githubActionsWorkflow: '',
},
Vitest: {
install: '',
run: '',
- workflow: undefined,
+ githubActionsWorkflow: '',
},
Pytest: {
install: '',
run: '',
- workflow: undefined,
+ githubActionsWorkflow: '',
},
Go: {
install: undefined,
run: 'go test -coverprofile=coverage.txt',
- workflow: undefined,
+ githubActionsWorkflow: '',
},
}
const setFramework = vi.fn()
diff --git a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.tsx b/src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.tsx
similarity index 97%
rename from src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.tsx
rename to src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.tsx
index 9ae72e7c6d..4637d8f56c 100644
--- a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/OutputCoverageStep.tsx
+++ b/src/pages/RepoPage/CoverageOnboarding/OutputCoverageStep/OutputCoverageStep.tsx
@@ -7,7 +7,7 @@ import { Card } from 'ui/Card'
import { CodeSnippet } from 'ui/CodeSnippet'
import Select from 'ui/Select'
-import { Framework, FrameworkInstructions } from './types'
+import { Framework, FrameworkInstructions } from '../UseFrameworkInstructions'
interface OutputCoverageStepProps {
framework: Framework
diff --git a/src/pages/RepoPage/CoverageOnboarding/UseFrameworkInstructions.tsx b/src/pages/RepoPage/CoverageOnboarding/UseFrameworkInstructions.tsx
new file mode 100644
index 0000000000..7d3278ba0c
--- /dev/null
+++ b/src/pages/RepoPage/CoverageOnboarding/UseFrameworkInstructions.tsx
@@ -0,0 +1,174 @@
+import { useMemo } from 'react'
+
+export type Framework = 'Jest' | 'Vitest' | 'Pytest' | 'Go'
+export type FrameworkInstructions = ReturnType
+
+interface UseFrameworkInstructionsArgs {
+ orgUploadToken?: string | null
+ owner: string
+ repo: string
+}
+
+export function UseFrameworkInstructions({
+ orgUploadToken,
+ owner,
+ repo,
+}: UseFrameworkInstructionsArgs) {
+ return useMemo(
+ () => ({
+ Jest: {
+ install: 'npm install --save-dev jest',
+ run: 'npx jest --coverage',
+ githubActionsWorkflow: `name: Run tests and upload coverage
+
+on:
+ push
+
+jobs:
+ test:
+ name: Run tests and collect coverage
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Node
+ uses: actions/setup-node@v4
+
+ - name: Install dependencies
+ run: npm install
+
+ - name: Run tests
+ run: npx jest --coverage
+
+ - name: Upload results to Codecov
+ uses: codecov/codecov-action@v5
+ with:
+ token: \${{ secrets.CODECOV_TOKEN }}${
+ orgUploadToken
+ ? `
+ slug: ${owner}/${repo}`
+ : ''
+ }
+`,
+ },
+ Vitest: {
+ install: 'npm install --save-dev vitest @vitest/coverage-v8',
+ run: 'npx vitest run --coverage',
+ githubActionsWorkflow: `name: Run tests and upload coverage
+
+on:
+ push
+
+jobs:
+ test:
+ name: Run tests and collect coverage
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Node
+ uses: actions/setup-node@v4
+
+ - name: Install dependencies
+ run: npm install
+
+ - name: Run tests
+ run: npx vitest run --coverage
+
+ - name: Upload results to Codecov
+ uses: codecov/codecov-action@v5
+ with:
+ token: \${{ secrets.CODECOV_TOKEN }}${
+ orgUploadToken
+ ? `
+ slug: ${owner}/${repo}`
+ : ''
+ }
+`,
+ },
+ Pytest: {
+ install: 'pip install pytest pytest-cov',
+ run: 'pytest --cov-branch --cov-report=xml',
+ githubActionsWorkflow: `name: Run tests and upload coverage
+
+on:
+ push
+
+jobs:
+ test:
+ name: Run tests and collect coverage
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+
+ - name: Install dependencies
+ run: pip install pytest pytest-cov
+
+ - name: Run tests
+ run: pytest --cov-branch --cov-report=xml
+
+ - name: Upload results to Codecov
+ uses: codecov/codecov-action@v5
+ with:
+ token: \${{ secrets.CODECOV_TOKEN }}${
+ orgUploadToken
+ ? `
+ slug: ${owner}/${repo}`
+ : ''
+ }
+`,
+ },
+ Go: {
+ install: undefined,
+ run: 'go test -coverprofile=coverage.txt',
+ githubActionsWorkflow: `name: Run tests and upload coverage
+
+on:
+ push
+
+jobs:
+ test:
+ name: Run tests and collect coverage
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+
+ - name: Install dependencies
+ run: go mod download
+
+ - name: Run tests
+ run: go test -coverprofile=coverage.txt
+
+ - name: Upload results to Codecov
+ uses: codecov/codecov-action@v5
+ with:
+ token: \${{ secrets.CODECOV_TOKEN }}${
+ orgUploadToken
+ ? `
+ slug: ${owner}/${repo}`
+ : ''
+ }
+`,
+ },
+ }),
+ [orgUploadToken, owner, repo]
+ )
+}