diff --git a/src/pages/GovernancePage.jsx b/src/pages/GovernancePage.jsx index 63956997..945dda93 100644 --- a/src/pages/GovernancePage.jsx +++ b/src/pages/GovernancePage.jsx @@ -336,7 +336,11 @@ export default function GovernancePage() {
Issue Resolution Rate
Resolution velocity across key repositories
{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 diff --git a/src/pages/GovernancePage.test.jsx b/src/pages/GovernancePage.test.jsx new file mode 100644 index 00000000..cfb8540c --- /dev/null +++ b/src/pages/GovernancePage.test.jsx @@ -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' } + ] + }, + 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() + + expect(screen.getByText('50%')).toBeInTheDocument() + expect(screen.queryByText('75%')).not.toBeInTheDocument() + }) +}) \ No newline at end of file