Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/pages/GovernancePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ export default function GovernancePage() {
<div style={{ fontWeight: 600, marginBottom: 4 }}>Issue Resolution Rate</div>
<div style={{ ...C.label, marginBottom: 16 }}>Resolution velocity across key repositories</div>
{topRepos.map(r => {
const repoIssues = allIssues.filter(i => i.repoName === r.name)
const repoIssues = allIssues.filter(i =>
i.repoName === r.name &&
i.orgName === r.orgLogin &&
!i.pull_request
)
const closed = repoIssues.filter(i => i.state === 'closed').length
const total = repoIssues.length
const rate = total ? Math.round(closed / total * 100) : null
Expand Down
49 changes: 49 additions & 0 deletions src/pages/GovernancePage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen } from '@testing-library/react'
import GovernancePage from './GovernancePage'

vi.mock('../context/AppContext', () => ({
useApp: () => ({
orgs: [{ login: 'test-org' }],
model: {
allRepos: [
{
id: 1,
name: 'test-repo',
orgLogin: 'test-org',
license: { name: 'MIT' },
archived: false,
fork: false
}
]
},
issuesData: {
'test-org/test-repo': [
{ id: 1, state: 'closed' },
{ id: 2, state: 'open' },
{ id: 3, state: 'closed', pull_request: { url: 'pr/3' } },
{ id: 4, state: 'closed', pull_request: { url: 'pr/4' } }
],

// Added to verify organization-specific filtering
'other-org/test-repo': [
{ id: 5, state: 'closed' }
]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
runAudit: vi.fn(),
govLoading: false,
auditComplete: true,
loading: false,
runGovernanceAnalysis: vi.fn(),
staleRepoStats: []
})
}))

describe('GovernancePage - Issue Resolution Rate', () => {
it('excludes pull requests and issues from other organizations', () => {
render(<GovernancePage />)

expect(screen.getByText('50%')).toBeInTheDocument()
expect(screen.queryByText('75%')).not.toBeInTheDocument()
})
})
Loading