Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1ef592c
refactor(function): convert title and body parameters to invoke param…
rulasg Oct 20, 2025
4e83117
feat(graphql): add Invoke-RemoveIssue function and GraphQL mutation f…
rulasg Oct 20, 2025
ab5229c
refactor(graphql): simplify repo fragment structure
rulasg Oct 20, 2025
948949d
fix(New-ProjectIssue): handle missing repository case in New-ProjectI…
rulasg Oct 20, 2025
c8ebc73
refactor(function): rename Get-ProjectIssue to Get-ProjectIssueDirect…
rulasg Oct 20, 2025
f965154
feat(testNewProjectItem): improve Test_GetProjectIssueDirect and add …
rulasg Oct 26, 2025
4f67605
refactor(test): update repository object handling in Get-Mock_Project…
rulasg Oct 26, 2025
4e2d143
Merge branch 'main' into remove-projectitem
rulasg Oct 26, 2025
29b41bb
refactor(MockCall_Project700): clean up code and add issue URL to pro…
rulasg Oct 26, 2025
1c55158
Merge branch 'remove-issue' into remove-projectitem
rulasg Oct 26, 2025
0ca58ad
fix(Get-ContentIdFromUrlDirect) : Call Get-ProjectIssueDirect
rulasg Oct 26, 2025
e633831
feat(graphql): add deleteIssue mock . Update repository graphql query
rulasg Oct 26, 2025
80bcb6d
refactor(Get-ProjectIssue): streamline cache checks and improve direc…
rulasg Oct 26, 2025
a2a3c8a
feat(Remove-IssueDirect): implement function to remove issue by URL
rulasg Oct 26, 2025
781c2da
feat(Remove-ProjectItem): streamline item removal logic and improve e…
rulasg Oct 26, 2025
8906b5a
feat(test): add tests for project item removal and issue deletion
rulasg Oct 26, 2025
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
34 changes: 24 additions & 10 deletions Test/private/MockCall_Project700.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@

# Repository Info
$repoContent = Get-MockFileContentJson -fileName $project.repofile -AsHashtable
$project.repository = $repoContent.data.repository
$project.repository.owner = $repoContent.data.repository.owner.login
$project.repository.Remove('parent')

$project.repo = @{
id = $repoContent.data.repository.id
owner = $repoContent.data.repository.owner.login
name = $repoContent.data.repository.name
nameWithOwner = $repoContent.data.repository.nameWithOwner
getRepoMockFile = $project.repofile
object = $repoContent.data.repository
}
$project.repo.object.Remove('parent')
$project.repo.object.owner = $repoContent.data.repository.owner.login

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# Project info
$project.id = $pActual.id
$project.owner = $pActual.owner.login
Expand All @@ -54,13 +61,20 @@
$project.items.totalCount = $pActual.items.nodes.count
$project.items.doneCount = 6 # too complicated to read from structure

# Create issue in repo
$project.createIssueInRepo = @{
name = $project.repository.name
owner = $project.repository.owner
id = $project.repository.id
issueUrl = "https://github.com/octodemo/rulasg-dev-1/issues/30"
# issueToCreateAddAndRemove
$id = "I_kwDOPrRnkc7T2Al2"
$itemId ="PVTI_lADOAlIw4c4BCe3VzggVZH8"
$project.issueToCreateAddAndRemove= @{
id = $id
number = 46
url = "https://github.com/octodemo/rulasg-dev-1/issues/46"
getIssueOrPullRequestMockFile = "invoke-getissueorpullrequest-46.json"
itemId = $itemId
addIssueToOProjectMockFile = "invoke-additemtoproject-$($project.id)-$id.json"
createIssueMockfile = "invoke-createissue-$($project.repo.id).json"
removeIssueFromProjectMockFile = "invoke-removeitemfromproject-$($project.id)-$itemId.json"
}

# Issues to find
$project.issueToFind = @{}
$project.issueToFind.Ids = ($pActual.items.nodes | Where-Object { $_.content.title -eq "Issue to find" }).Id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"data": {
"addProjectV2ItemById": {
"item": {
"id": "PVTI_lADOAlIw4c4BCe3VzggVZH8",
"type": "ISSUE",
"fullDatabaseId": "135619711",
"project": {
"id": "PVT_kwDOAlIw4c4BCe3V",
"url": "https://github.com/orgs/octodemo/projects/700"
},
"content": {
"__typename": "Issue",
"id": "I_kwDOPrRnkc7T2Al2",
"body": "",
"title": "kkk",
"updatedAt": "2025-10-26T16:02:46Z",
"createdAt": "2025-10-26T16:02:46Z",
"number": 46,
"url": "https://github.com/octodemo/rulasg-dev-1/issues/46",
"state": "OPEN",
"repository": {
"name": "rulasg-dev-1",
"owner": {
"login": "octodemo"
}
},
"comments": {
"totalCount": 0,
"nodes": []
}
},
"fieldValues": {
"nodes": [
{
"__typename": "ProjectV2ItemFieldRepositoryValue",
"repository": {
"url": "https://github.com/octodemo/rulasg-dev-1"
},
"field": {
"__typename": "ProjectV2Field",
"id": "PVTF_lADOAlIw4c4BCe3Vzg0rg-k",
"name": "Repository",
"dataType": "REPOSITORY"
}
},
{
"__typename": "ProjectV2ItemFieldTextValue",
"text": "kkk",
"field": {
"__typename": "ProjectV2Field",
"id": "PVTF_lADOAlIw4c4BCe3Vzg0rg-M",
"name": "Title",
"dataType": "TITLE"
}
}
]
}
}
}
}
}
11 changes: 9 additions & 2 deletions Test/private/mocks/invoke-createissue-R_kgDOPrRnkQ.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"data": {
"createIssue": {
"issue": {
"id": "I_kwDOPrRnkc7Sj4N0",
"url": "https://github.com/octodemo/rulasg-dev-1/issues/30"
"title": "kkk",
"body": "",
"number": 46,
"url": "https://github.com/octodemo/rulasg-dev-1/issues/46",
"id": "I_kwDOPrRnkc7T2Al2",
"repository": {
"id": "R_kgDOPrRnkQ",
"nameWithOwner": "octodemo/rulasg-dev-1"
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions Test/private/mocks/invoke-getissueorpullrequest-46.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data": {
"resource": {
"__typename": "Issue",
"title": "kkk",
"body": "",
"number": 46,
"url": "https://github.com/octodemo/rulasg-dev-1/issues/46",
"id": "I_kwDOPrRnkc7T2Al2",
"repository": {
"id": "R_kgDOPrRnkQ",
"nameWithOwner": "octodemo/rulasg-dev-1"
}
}
}
}
10 changes: 10 additions & 0 deletions Test/private/mocks/invoke-removeissue-any.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"deleteIssue": {
"repository": {
"id": "R_kgDOPrRnkQ",
"url": "https://github.com/octodemo/rulasg-dev-1"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"deleteProjectV2Item": {
"deletedItemId": "PVTI_lADOAlIw4c4BCe3VzggVZH8"
}
}
}
62 changes: 50 additions & 12 deletions Test/public/issues/New-ProjectIssue.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,62 @@
Reset-InvokeCommandMock
Mock_DatabaseRoot

$p = Get-Mock_Project_700 ;
$r = $p.createIssueInRepo
$p = Get-Mock_Project_700

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$r = $p.repo

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$i = $p.issueToCreateAddAndRemove

$title = "Test Issue from New-ProjectIssueDirect"
$body = "This is a test issue created by New-ProjectIssueDirect test"
$command = "Invoke-CreateIssue -RepositoryId $($r.id) -Title ""$title"" -Body ""$body"""
$issueTitle = "Random value title"
$issueBody = "Random value body"
$mockfilename = $i.createIssueMockfile

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# MockCall_GetProject $p
MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $r.getRepoMockFile
MockCallJson -Command "Invoke-CreateIssue -RepositoryId $($r.id) -Title ""$issueTitle"" -Body ""$issueBody""" -FileName $mockfilename

MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $p.repoFile
MockCallJson -command $command -FileName "invoke-createissue-$($r.id).json"
$params = @{
RepoOwner = $r.owner
RepoName = $r.name
Title = $issueTitle
Body = $issueBody
}

$result = New-ProjectIssueDirect @params

$result = New-ProjectIssueDirect -RepoOwner $r.owner -RepoName $r.name -Title "Test Issue from New-ProjectIssueDirect" -Body "This is a test issue created by New-ProjectIssueDirect test"
# Assert
Assert-AreEqual -Expected $i.url -Presented $result

# Invoke-CreateIssue -RepositoryId $result.Id -Title "Test Issue from New-ProjectIssueDirect" -Body "This is a test issue created by New-ProjectIssueDirect test" -ProjectIds @($p.id)
}

# Assert
Assert-AreEqual -Expected $r.issueUrl -Presented $result
function Test_NewProjectIssue{
Reset-InvokeCommandMock
Mock_DatabaseRoot

$p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number
$r = $p.repo
$i = $p.issueToCreateAddAndRemove
$issueTitle = "Random value title"
$issueBody = "Random value body"
$mockfilenameCreate = "invoke-createissue-$($r.id).json"
$mockfilenameGet = "invoke-getissueorpullrequest-$($i.number).json"

MockCall_GetProject $p
MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $r.getRepoMockFile
MockCallJson -Command "Invoke-CreateIssue -RepositoryId $($r.id) -Title ""$issueTitle"" -Body ""$issueBody""" -FileName $mockfilenameCreate
MockCallJson -Command "Invoke-GetIssueOrPullRequest -Url $($i.url)" -fileName $mockfilenameGet
MockCallJson -Command "Invoke-AddItemToProject -ProjectId $($p.id) -ContentId $($i.id)" -fileName $i.addIssueToOProjectMockFile

# Create issue
$params = @{
ProjectOwner = $owner
ProjectNumber = $projectNumber
RepoOwner = $r.owner
RepoName = $r.name
Title = $issueTitle
Body = $issueBody
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$result = New-ProjectIssue @params

Assert-AreEqual -Expected $result -Presented $i.itemId
}

test
38 changes: 38 additions & 0 deletions Test/public/issues/Remove-ProjectIssue.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function Test_RemoveProjectIssue_SUCCESS {

Reset-InvokeCommandMock
Mock_DatabaseRoot

$p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number
$i = $p.issueToCreateAddAndRemove

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
MockCall_GetProject $p

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# Add item to project to remover it later
MockCallJson -Command "Invoke-GetIssueOrPullRequest -Url $($i.url)" -fileName $i.getIssueOrPullRequestMockFile
MockCallJson -Command "Invoke-AddItemToProject -ProjectId $($p.id) -ContentId $($i.id)" -fileName $i.addIssueToOProjectMockFile
$itemId = Add-ProjectItem -owner $owner -projectNumber $projectNumber -Url $i.url
$item = Get-ProjectItem -Id $itemId
Assert-AreEqual -expected $i.id -Presented $item.contentId

MockCallJson -Command "Invoke-RemoveItemFromProject -ProjectId $($p.id) -ItemId $($i.itemId)" -fileName $i.removeIssueFromProjectMockFile

# Act
$result = Remove-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId

# Assert
Assert-AreEqual -Expected $i.url -Presented $result
Assert-IsFalse -Condition $(Test-ProjectItem -Url $i.url)

# Remove issue assocaited
$itemId = Add-ProjectItem -owner $owner -projectNumber $projectNumber -Url $i.url
Assert-IsTrue -Condition $(Test-ProjectItem -Url $i.url)
MockCallJson -Command "Invoke-RemoveIssue -IssueId $($i.id)" -FileName "invoke-removeissue-any.json"

# Act
$result = Remove-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId -DeleteIssue

# Assert
Assert-IsTrue -Condition $result

}
8 changes: 5 additions & 3 deletions Test/public/repository/get-repository.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ function Test_GetRepository{
Mock_DatabaseRoot

$p = Get-Mock_Project_700 ;
$r = $p.repository
$r = $p.repo
$ro = $p.repo.object


MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $p.repoFile

$result = Get-Repository -Owner $r.owner -Name $r.name

#Assert
foreach ( $key in $r.Keys ){
Assert-AreEqual -Expected:$r.$key -Presented:$result.$key
foreach ( $key in $ro.Keys ){
Assert-AreEqual -Expected:$ro.$key -Presented:$result.$key
}

# Assert repo cache created
Expand Down
2 changes: 1 addition & 1 deletion private/item/getResourceid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Get-ContentIdFromUrlDirect{
[Parameter(Mandatory,Position = 0)][string]$Url
)

$issue = Get-ProjectIssue -Url $url
$issue = Get-ProjectIssueDirect -Url $url

$ret = $issue.id

Expand Down
4 changes: 2 additions & 2 deletions public/driver/issue/Invoke-CreateDraftItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function Invoke-CreateDraftItem{
$variables = @{
input = @{
projectId = $ProjectId
title = $Title
body = $Body
title = $Title | ConvertTo-InvokeParameterString
body = $Body | ConvertTo-InvokeParameterString
}
}

Expand Down
4 changes: 2 additions & 2 deletions public/driver/issue/Invoke-CreateIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function Invoke-CreateIssue {
$variables = @{
input = @{
repositoryId = $RepositoryId
title = $Title
body = $Body
title = $Title | ConvertTo-InvokeParameterString
body = $Body | ConvertTo-InvokeParameterString

#projectIds = $ProjectIds
# assigneeIds = $AssigneeIds
Expand Down
17 changes: 17 additions & 0 deletions public/driver/issue/Invoke-RemoveIssue.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function Invoke-RemoveIssue {

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-RemoveIssue' does not have a help comment. Note

The cmdlet 'Invoke-RemoveIssue' does not have a help comment.
param(
[Parameter(Mandatory = $true)][string]$IssueId
)

$query = Get-GraphQLString "removeIssue.mutant"

$variables = @{
input = @{
issueId = $IssueId
}
}

$response = Invoke-GraphQL -Query $query -Variables $variables

return $response
} Export-ModuleMember -Function Invoke-RemoveIssue
4 changes: 2 additions & 2 deletions public/driver/issue/Invoke-UpdateDraftIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function Invoke-UpdateDraftIssue{

# Title can not be empty
if(-not [string]::IsNullOrWhiteSpace($Title)){
$variables.input.title = $Title
$variables.input.title = $Title | ConvertTo-InvokeParameterString
}

# This will avoid to empty the body
if(-not [string]::IsNullOrWhiteSpace($Body)){
$variables.input.body = $Body
$variables.input.body = $Body | ConvertTo-InvokeParameterString
}

# Check if variables are is empty
Expand Down
6 changes: 3 additions & 3 deletions public/driver/issue/Invoke-UpdateIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@

# Title can not be empty
if(-not [string]::IsNullOrWhiteSpace($Title)){
$variables.input.title = $Title
}
$variables.input.title = $Title | ConvertTo-InvokeParameterString
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

# This will avoid to empty the body
if(-not [string]::IsNullOrWhiteSpace($Body)){
$variables.input.body = $Body
$variables.input.body = $Body | ConvertTo-InvokeParameterString
}

# Check if variables are is empty
Expand Down
4 changes: 2 additions & 2 deletions public/driver/issue/Invoke-UpdatePullRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function Invoke-UpdatePullRequest{

# Title can not be empty
if(-not [string]::IsNullOrWhiteSpace($Title)){
$variables.input.title = $Title
$variables.input.title = $Title | ConvertTo-InvokeParameterString
}

# This will avoid to empty the body
if(-not [string]::IsNullOrWhiteSpace($Body)){
$variables.input.body = $Body
$variables.input.body = $Body | ConvertTo-InvokeParameterString
}

# Check if variables are is empty
Expand Down
Loading