From c8fc011ae50cdaf55d3152a2475c2aabee5b57c3 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Sun, 25 Oct 2026 18:59:20 +0530 Subject: [PATCH 1/2] fix(governance): exclude PRs from issue resolution rate --- src/pages/GovernancePage.jsx | 6 ++++- src/pages/GovernancePage.test.jsx | 45 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/pages/GovernancePage.test.jsx 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..26f48f91 --- /dev/null +++ b/src/pages/GovernancePage.test.jsx @@ -0,0 +1,45 @@ + +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' } } + ] + }, + runAudit: vi.fn(), + govLoading: false, + auditComplete: true, + loading: false, + runGovernanceAnalysis: vi.fn(), + staleRepoStats: [] + }) +})) + +describe('GovernancePage - Issue Resolution Rate', () => { + it('excludes pull requests when calculating the issue resolution rate', () => { + render() + + expect(screen.getByText('50%')).toBeInTheDocument() + expect(screen.queryByText('75%')).not.toBeInTheDocument() + }) +}) From 6ea607c63374492728863a896fe2de53ba29be92 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 27 Oct 2026 14:18:24 +0530 Subject: [PATCH 2/2] test(governance): cover cross-organization issue filtering --- src/pages/GovernancePage.test.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/GovernancePage.test.jsx b/src/pages/GovernancePage.test.jsx index 26f48f91..cfb8540c 100644 --- a/src/pages/GovernancePage.test.jsx +++ b/src/pages/GovernancePage.test.jsx @@ -1,4 +1,3 @@ - import { describe, it, expect, vi } from 'vitest' import { render, screen } from '@testing-library/react' import GovernancePage from './GovernancePage' @@ -24,6 +23,11 @@ vi.mock('../context/AppContext', () => ({ { 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(), @@ -36,10 +40,10 @@ vi.mock('../context/AppContext', () => ({ })) describe('GovernancePage - Issue Resolution Rate', () => { - it('excludes pull requests when calculating the 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