Skip to content

Commit

Permalink
Merge pull request #2510 from MahtabBukhari/Replace-Generate-Tests-wi…
Browse files Browse the repository at this point in the history
…th-Analyze-Test-Coverage-in-Repository-Node

Replace "Generate Tests" with "Analyze Test Coverage" in Repository Node
  • Loading branch information
Rassl authored Feb 10, 2025
2 parents 3341bb8 + 4b43542 commit 4d5c6d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/Universe/Graph/UI/NodeControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useUserStore } from '~/stores/useUserStore'
import { ActionDetail, NodeExtended } from '~/types'
import { colors } from '~/utils/colors'
import { buttonColors } from './constants'
import { analyzeGitHubRepository } from '~/network/analyzeGithubRepo'

const reuseableVector3 = new Vector3()

Expand All @@ -43,7 +44,7 @@ export const NodeControls = memo(() => {
// const { open: createBountyModal } = useModal('createBounty')

const [isAdmin] = useUserStore((s) => [s.isAdmin])
const [addNewNode] = useDataStore((s) => [s.addNewNode])
const { addNewNode } = useDataStore((s) => s)

const selectedNode = useSelectedNode()

Expand Down Expand Up @@ -192,6 +193,15 @@ export const NodeControls = memo(() => {
setAnchorEl(null)
}


const handleAnalyzeTestCoverage = async (githubName: string) => {
try {
await analyzeGitHubRepository(githubName)
} catch (error) {
console.error('error during test coverage analysis:', error)
}
}

const handleNodeAction = (action: ActionDetail) => {
setSelectedActionDetail(action)
openNodeAction()
Expand Down Expand Up @@ -294,13 +304,17 @@ export const NodeControls = memo(() => {
<PopoverOption
data-testid="generate_tests"
onClick={() => {
if (selectedNode?.name) {
handleAnalyzeTestCoverage(selectedNode.name)
}

handleClose()
}}
>
<IconWrapper>
<AddCircleIcon data-testid="AddCircleIcon" />
</IconWrapper>
Generate Tests
Analyze Test Coverage
</PopoverOption>
<PopoverOption
data-testid="add_comments"
Expand Down
14 changes: 14 additions & 0 deletions src/network/analyzeGithubRepo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { api } from '~/network/api'
import { NodeExtended } from '~/types'

type GithubRepositoryResponse = {
functions: NodeExtended[]
}

export const analyzeGitHubRepository = async (githubRepository: string): Promise<GithubRepositoryResponse> => {
const url = `/github/analyze?github_repository=${githubRepository}&analysis=["coverage"]`

const res = await api.get<GithubRepositoryResponse>(url)

return res
}

0 comments on commit 4d5c6d0

Please sign in to comment.