Repository navigation
fix(analytics): label GitHub's combined open count and split it where audited (#375) #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
muditagrawal2007
wants to merge
1
commit into
AOSSIE-Org:main
Choose a base branch
from
muditagrawal2007:fix/375-open-issues-and-prs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest' | ||
| import { render, screen } from '@testing-library/react' | ||
| import { MemoryRouter } from 'react-router-dom' | ||
| import RepositoriesPage from './RepositoriesPage' | ||
|
|
||
| const { app } = vi.hoisted(() => ({ app: {} })) | ||
|
|
||
| vi.mock('../context/AppContext', () => ({ useApp: () => app })) | ||
|
|
||
| // The banner owns the PAT gate and the "run complete analysis" flow; it is | ||
| // not what this test is about. | ||
| vi.mock('../components/AnalysisBanner', () => ({ default: () => null })) | ||
|
|
||
| const repo = (overrides = {}) => ({ | ||
| id: 1, | ||
| name: 'DebateAI', | ||
| orgLogin: 'AOSSIE-Org', | ||
| html_url: 'https://github.com/AOSSIE-Org/DebateAI', | ||
| description: 'A debate app', | ||
| stargazers_count: 12, | ||
| forks_count: 3, | ||
| open_issues_count: 312, | ||
| healthScore: 71, | ||
| activityClassification: 'Active', | ||
| language: 'TypeScript', | ||
| pushed_at: '2026-10-01T12:00:00Z', | ||
| ...overrides, | ||
| }) | ||
|
|
||
| const openIssue = () => ({ state: 'open' }) | ||
| const openPull = () => ({ state: 'open', pull_request: {} }) | ||
|
|
||
| function renderPage() { | ||
| return render( | ||
| <MemoryRouter> | ||
| <RepositoriesPage /> | ||
| </MemoryRouter> | ||
| ) | ||
| } | ||
|
|
||
| describe('RepositoriesPage open issue and pull request counts', () => { | ||
| beforeEach(() => { | ||
| Object.assign(app, { | ||
| model: { totalRepos: [repo()] }, | ||
| issuesData: {}, | ||
| isComplete: true, | ||
| loading: false, | ||
| runFullExplore: vi.fn(), | ||
| }) | ||
| }) | ||
|
|
||
| it('labels the column as open issues and pull requests', () => { | ||
| renderPage() | ||
|
|
||
| expect( | ||
| screen.getByRole('columnheader', { name: /Open Issues & PRs/i }) | ||
| ).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('shows GitHub’s combined count in the cell', () => { | ||
| renderPage() | ||
|
|
||
| expect(screen.getByText('312')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('splits the count in the tooltip once the repository has been audited', () => { | ||
| app.issuesData = { | ||
| 'AOSSIE-Org/DebateAI': [ | ||
| ...Array.from({ length: 156 }, () => openIssue()), | ||
| ...Array.from({ length: 156 }, () => openPull()), | ||
| ], | ||
| } | ||
|
|
||
| renderPage() | ||
|
|
||
| const tooltip = screen.getByText('312').closest('td').getAttribute('title') | ||
| expect(tooltip).toContain('156 open issues') | ||
| expect(tooltip).toContain('156 open pull requests') | ||
| }) | ||
|
|
||
| it('shows the split next to the combined count once the repository has been audited', () => { | ||
| app.issuesData = { | ||
| 'AOSSIE-Org/DebateAI': [ | ||
| ...Array.from({ length: 156 }, () => openIssue()), | ||
| ...Array.from({ length: 156 }, () => openPull()), | ||
| ], | ||
| } | ||
|
|
||
| renderPage() | ||
|
|
||
| expect(screen.getByText('156 issues · 156 PRs')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('does not show a split that the audit could not confirm', () => { | ||
| app.issuesData = { | ||
| 'AOSSIE-Org/DebateAI': [openIssue(), openPull()], | ||
| } | ||
|
|
||
| renderPage() | ||
|
|
||
| expect(screen.queryByText(/issues · .*PRs/)).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('explains that the count is combined when the repository has not been audited', () => { | ||
| renderPage() | ||
|
|
||
| const tooltip = screen.getByText('312').closest('td').getAttribute('title') | ||
| expect(tooltip).toContain('combined') | ||
| }) | ||
|
|
||
| it('does not borrow another organization’s audit data for the tooltip', () => { | ||
| app.issuesData = { | ||
| 'Other-Org/DebateAI': [openIssue(), openPull()], | ||
| } | ||
|
|
||
| renderPage() | ||
|
|
||
| const tooltip = screen.getByText('312').closest('td').getAttribute('title') | ||
| expect(tooltip).toContain('combined') | ||
| }) | ||
|
|
||
| it('flags partial audit data instead of presenting it as exact', () => { | ||
| app.issuesData = { | ||
| 'AOSSIE-Org/DebateAI': [openIssue(), openPull()], | ||
| } | ||
|
|
||
| renderPage() | ||
|
|
||
| const tooltip = screen.getByText('312').closest('td').getAttribute('title') | ||
| expect(tooltip).toContain('partial') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { buildReposCSV } from './analytics' | ||
|
|
||
| const repo = (overrides = {}) => ({ | ||
| name: 'DebateAI', | ||
| orgLogin: 'AOSSIE-Org', | ||
| stargazers_count: 12, | ||
| forks_count: 3, | ||
| open_issues_count: 312, | ||
| healthScore: 71, | ||
| activityClassification: 'Active', | ||
| language: 'TypeScript', | ||
| pushed_at: '2026-10-01T12:00:00Z', | ||
| ...overrides, | ||
| }) | ||
|
|
||
| const openIssue = () => ({ state: 'open' }) | ||
| const openPull = () => ({ state: 'open', pull_request: {} }) | ||
|
|
||
| describe('buildReposCSV', () => { | ||
| it('labels the combined column as open issues and pull requests', () => { | ||
| const [header] = buildReposCSV([repo()]).split('\n') | ||
|
|
||
| expect(header).toContain('Open Issues & PRs') | ||
| }) | ||
|
|
||
| it('keeps GitHub’s combined count in the combined column', () => { | ||
| const [, row] = buildReposCSV([repo()]).split('\n') | ||
|
|
||
| expect(row.split(',')[4]).toBe('312') | ||
| }) | ||
|
|
||
| it('fills the issue and pull request columns from audit data', () => { | ||
| const csv = buildReposCSV([repo()], { | ||
| 'AOSSIE-Org/DebateAI': [ | ||
| ...Array.from({ length: 156 }, () => openIssue()), | ||
| ...Array.from({ length: 156 }, () => openPull()), | ||
| ], | ||
| }) | ||
| const [, row] = csv.split('\n') | ||
|
|
||
| expect(row.split(',')[5]).toBe('156') | ||
| expect(row.split(',')[6]).toBe('156') | ||
| }) | ||
|
|
||
| it('leaves the split columns empty when the repository has not been audited', () => { | ||
| const [, row] = buildReposCSV([repo()]).split('\n') | ||
|
|
||
| expect(row.split(',')[5]).toBe('') | ||
| expect(row.split(',')[6]).toBe('') | ||
| }) | ||
|
|
||
| it('does not borrow another organization’s audit data for a repository', () => { | ||
| const csv = buildReposCSV([repo()], { | ||
| 'Other-Org/DebateAI': [openIssue(), openPull()], | ||
| }) | ||
| const [, row] = csv.split('\n') | ||
|
|
||
| expect(row.split(',')[5]).toBe('') | ||
| expect(row.split(',')[6]).toBe('') | ||
| }) | ||
|
|
||
| it('exports one row per repository', () => { | ||
| const csv = buildReposCSV([repo(), repo({ name: 'PictoPy', open_issues_count: 7 })]) | ||
|
|
||
| expect(csv.split('\n')).toHaveLength(3) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the partial-audit status accessible without hover.
When audit counts are partial, the cell puts that status only in
title. A keyboard user cannot focus this<td>, and a touch user cannot hover it. Show a partial indicator in the cell, or provide a focusable control with the description. Keep the combined count visible.🧰 Tools
🪛 ast-grep (0.45.3)
[warning] 299-309: A list component should have a key to prevent re-rendering
Context: <td
title={describeOpenCounts(openCounts)}
style={{ padding: '10px 14px', fontSize: 13, color: r.open_issues_count > 30 ? 'var(--red)' : 'var(--text2)', whiteSpace: 'nowrap' }}
>
{openCounts?.exact && (
<div style={{ fontSize: 11, color: 'var(--text2)' }}>
{openCounts.openIssues} issues · {openCounts.openPulls} PRs
)}
Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.
(list-component-needs-key)