Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a52b11d
fix(test): correct function name typos in project item tests
rulasg Sep 18, 2025
81d5885
feat(test): add callPrivateContext for invoking private functions in …
rulasg Sep 18, 2025
e1256bc
test(projectDatabase): add tests for ConvertTo-Number function
rulasg Sep 18, 2025
c464e71
fix(ConvertTo-Number): add validation for number format
rulasg Sep 18, 2025
57999a5
fix(mock): update project details in invoke-GitHubOrgProjectWithField…
rulasg Sep 19, 2025
b4f0aa5
big bang - test not pass
rulasg Sep 22, 2025
330e1e6
refactor(mock): rename MockCall_GitHubOrgProjectWithFields_700 to Moc…
rulasg Sep 22, 2025
4f7e6fc
Test_FindProjectItemByTitle_SUCCESS
rulasg Sep 22, 2025
11ca429
Test_EditProjectItems_Direct
rulasg Sep 22, 2025
6553787
add project to mock item data
rulasg Sep 22, 2025
843f87d
Test_EditProjectItemWithValues_Integration
rulasg Sep 22, 2025
19e648b
Test_InvokeProjectInjection
rulasg Sep 22, 2025
dd98646
fix: wrong mock files
rulasg Sep 22, 2025
a206233
Test_GetItemDirect_SUCCESS
rulasg Sep 22, 2025
55ab7bf
Test_GetProjectItem_SUCCESS
rulasg Sep 22, 2025
460147c
Test_GetProjetItemList_SUCCESS
rulasg Sep 22, 2025
e319160
Test_ProjectItemList_ExcludeDone
rulasg Sep 22, 2025
3731978
refactor: reorder parameters in Get-ProjectFields function
rulasg Sep 22, 2025
fe2e725
Test_FindProjectItemByTitle_SUCCESS*
rulasg Sep 22, 2025
d9ae270
Test_ProjectItemList_ExcludeDone
rulasg Sep 22, 2025
f53fce0
Test_SaveProjectDatabase_SafeId_Flag_PrivateCall
rulasg Sep 22, 2025
f315b14
refactor(test): consolidate variable assignments in test functions
rulasg Sep 22, 2025
b15bf91
refactor(test): standardize variable naming in test functions
rulasg Sep 22, 2025
0196af1
Test_ShowProjectItem_SUCCESS, Test_ShowProjectItem_SUCCESS and remove…
rulasg Sep 22, 2025
9f09e45
MockCall_GetItem ; MockCall_GitHubUpdateItemValues
rulasg Sep 22, 2025
62f2338
Test_TestProjectItemStaged
rulasg Sep 22, 2025
c1f018c
Test_UpdateProjectDatabase_Fail_With_Staged
rulasg Sep 22, 2025
d39b31a
Test_Sync_ProjectDatabase_ClearValues
rulasg Sep 22, 2025
6d53870
fix(environment): owner and project number caching logic
rulasg Sep 23, 2025
895db46
feat(Search-ProjectItem): add PassThru parameter and improve aliasing…
rulasg Sep 23, 2025
b073f64
feat(Search-ProjectItem): enhance attribute handling and add alias fo…
rulasg Sep 23, 2025
6984109
feat(issue-comment): add functionality to add comments to issues with…
rulasg Sep 23, 2025
a38c652
feat(Open-ProjectItem): add InProject parameter to control URL retrie…
rulasg Sep 24, 2025
68b4dea
refactor(Search-ProjectItem): reorder Attributes parameter for improv…
rulasg Sep 24, 2025
cc05c57
feat(issue-comment): implement functionality to add comments to issue…
rulasg Sep 24, 2025
fb0e5a8
refactor(Set-ProjecthelperPrompt): add alias 'sphp' for improved usab…
rulasg Sep 24, 2025
d8ff510
Refactor project item tests for case sensitivity and improve hashtabl…
rulasg Sep 25, 2025
beb1f36
Test_SaveProjectDatabase_Safe_PrivateCall
rulasg Sep 25, 2025
e8e5682
Test_Sync_ProjectDatabaseAsync_ClearValues
rulasg Sep 25, 2025
7a3e379
Test_SearchProjectItemByTitle_SUCCESS
rulasg Sep 25, 2025
5796342
Test_SearchProjectItem_SUCCESS
rulasg Sep 25, 2025
b4cd53f
Test_ShowProjectItemsStaged
rulasg Sep 25, 2025
eac50f6
Test_ShowProjectItem_SUCCESS_Multiple
rulasg Sep 25, 2025
95c1b41
minor fixes
rulasg Sep 25, 2025
f511c92
Test_SyncProjectItemsBetweenProjects_SameValues
rulasg Sep 25, 2025
f032e67
Test_UpdateProjectItemsBetweenProjects
rulasg Sep 25, 2025
2ae751d
refactor(MockCall_Project700): rename project variable for consistency
rulasg Sep 25, 2025
c3b8f79
Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh
rulasg Sep 26, 2025
86b3e3c
feat(helper): Write-MyDebug
rulasg Sep 26, 2025
138da1e
feat(debug): enhance debugging output in Sync-Project and UpdateProje…
rulasg Sep 26, 2025
d49c83e
refactor(openFilesUrls): remove unnecessary Export-ModuleMember for O…
rulasg Sep 26, 2025
774f32a
fix(Update-ItemField): add resultDataType for clearProjectV2ItemField…
rulasg Sep 26, 2025
371e176
style(Sync-Project): remove unnecessary -NoNewLine from Write-MyHost
rulasg Sep 26, 2025
5f38ee4
Test_Sync_ProjectDatabaseAsync_ClearValues
rulasg Sep 26, 2025
8a73223
Test_Sync_ProjectDatabase_ClearValues
rulasg Sep 26, 2025
a8c003c
Test_UpdateProjectItemStatusOnDueDate
rulasg Sep 27, 2025
17fc7da
Test_UpdateProjectWithIntegration
rulasg Sep 27, 2025
0eaaaae
Test_UpdateProjectWithInjection
rulasg Sep 27, 2025
9650ed2
Test_UpdateProjectWithInjection_Failed_1
rulasg Sep 27, 2025
ae47e19
Test_SyncProjectItemsStaged_SUCCESS_SingleSelect
rulasg Sep 27, 2025
0e6272d
fix(test): small fix of tets
rulasg Sep 27, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/**
.DS_Store
.DS_Store
*.patch
29 changes: 29 additions & 0 deletions Test/include/callPrivateContext.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# CALL PRIVATE FUNCTIONS
#
# This file enables tests to invoke private (non-exported) functions
# defined inside the main module by evaluating a provided scriptblock
# in the module context.
#
# It relies on variables initialized by module.helper.ps1.
# REQUIRED:
# $MODULE_PATH - Full path to the module .psm1 file (or a file inside its folder)
#
# THIS INCLUDE REQUIRES module.helper.ps1
if(-not $MODULE_PATH){ throw "Missing MODULE_PATH variable initialization. Check for module.helper.ps1 file." }

function Invoke-PrivateContext {

Check notice

Code scanning / PSScriptAnalyzer

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

The cmdlet 'Invoke-PrivateContext' does not have a help comment.
param (
[Parameter(Mandatory, Position = 0)]
[scriptblock]$ScriptBlock
)

$modulePath = $MODULE_PATH | Split-Path -Parent
$module = Import-Module -Name $modulePath -PassThru

if ($null -eq $module) {
throw "Failed to import the main module."
}

& $module $ScriptBlock

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
} Export-ModuleMember -Function Invoke-PrivateContext

4 changes: 2 additions & 2 deletions Test/private/MockCall_GitHubOrgProjectWithFields.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function MockCall_GitHubOrgProjectWithFields{
function MockCall_GitHubOrgProjectWithFields {
Param(
[string]$Owner,
[string]$ProjectNumber,
Expand All @@ -23,7 +23,7 @@ function MockCall_GitHubOrgProjectWithFields{
MockCallJson -Command $cmd -Filename $FileName
}

function MockCall_GitHubOrgProjectWithFields_Null{
function MockCall_GitHubOrgProjectWithFields_Null {
Param(
[string]$Owner,
[string]$ProjectNumber
Expand Down
43 changes: 43 additions & 0 deletions Test/private/MockCall_GitHubUpdateItemValues.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function MockCall_GitHubUpdateItemValues {
[CmdletBinding()]
param(
[parameter(Mandatory)][string]$ProjectId,
[parameter(Mandatory)][string]$ItemId,
[parameter(Mandatory)][string]$FieldId,
[parameter(Mandatory)][string]$Value,
[parameter(Mandatory)][string]$Type,

Check warning

Code scanning / PSScriptAnalyzer

The parameter 'Type' has been declared but not used. Warning

The parameter 'Type' has been declared but not used.
[parameter()][switch]$Async
)

$resultFile = "invoke-GitHubUpdateItemValue-$ItemId-$FieldId.json"

$command = 'Invoke-GitHubUpdateItemValues -ProjectId {ProjectId} -ItemId {ItemId} -FieldId {FieldId} -Value "{Value}" -Type text'

if ($Async) {
$modulePath = $MODULE_PATH | split-path -Parent
$moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test'

$command = 'Import-Module {modulepath} ; ' + $command
$command = $command -replace '{modulepath}', $modulePath
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$command = $command -replace '{ProjectId}', $ProjectId
$command = $command -replace '{ItemId}', $ItemId
$command = $command -replace '{FieldId}', $FieldId
$command = $command -replace '{Value}', $Value

Set-InvokeCommandMock -Command "Import-Module $moduleTestPath ; Get-MockFileContentJson -filename $($ResultFile)" -Alias $command

}

function MockCall_GetItem{
[cmdletbinding()]
param(
[parameter(Mandatory)][string]$ItemId
)

$command = "Invoke-GetItem -ItemId $ItemId"
$resultFile = "invoke-getitem-$ItemId.json"

Set-InvokeCommandMock -Command "Get-MockFileContentJson -filename $($ResultFile)" -Alias $command
}
268 changes: 268 additions & 0 deletions Test/private/MockCall_Project.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
function Get-Mock_Project_625 {

$project = @{}

<#
Reset-InvokeCommandMock
Enable-InvokeCommandAliasModule

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$cmd = 'Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 625 -afterFields "" -afterItems ""'
save-invokeAsMockFile $cmd "invoke-GitHubOrgProjectWithFields-octodemo-625.json"
#>

$name = "invoke-GitHubOrgProjectWithFields-octodemo-625"
$project.projectFile = $name + ".json"
$project.projectFile_skipitems = $name + "-skipitems.json"

$content = Get-MockFileContentJson -FileName $project.projectFile
$p = $content.data.organization.projectV2

# Project info
$project.id = $p.id
$project.owner = $p.owner.login
$project.number = $p.number
$project.url = $p.url

# Add Items to mock
Add-ItemsToMock -project $project

#############################
# Update Status on DueDate #
#############################
<#
$prj = Get-Project -Owner octodemo -ProjectNumber 625
$prj.items.values | Select id,title,DueDate,Status,Comment | Sort-Object title | ft

id Title DueDate Status Comment
-- ----- ------- ------ -------
PVTI_lADOAlIw4c4A0Lf4zgYNTyM draft0 2025-03-01 Planned Change AR Past
PVTI_lADOAlIw4c4A0Lf4zgYVsJc draft1 9999-12-12 Planned Ignore as Future
PVTI_lADOAlIw4c4A0Lf4zgfNuvM draft2 9999-12-12 ActionRequired Change to P as AR+Future
PVTI_lADOAlIw4c4A0Lf4zgfNum4 draft3 2025-03-03 ActionRequired Ignore as Past and AR
PVTI_lADOAlIw4c4A0Lf4zgYNTxI draft4 2025-03-09 In Progress (ignore not P) | (Changed AR as Past)
PVTI_lADOAlIw4c4A0Lf4zgfN77A draft5 2025-03-15 Todo (ignore not P) | (Change AR as Today)
PVTI_lADOAlIw4c4A0Lf4zgfN-44 draft6 2025-03-15 Planned Change to AR as P and Today
PVTI_lADOAlIw4c4A0Lf4zgYNTc0 draft7 2025-03-05 Done Ignore as Done | (Change AR as Past)
PVTI_lADOAlIw4c4A0Lf4zgYNTwo draft8 9999-12-12 In Progress Ignore future
PVTI_lADOAlIw4c4A0Lf4zgfOmpo draft9 9999-12-12 Todo (Ignore not P)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
PVTI_lADOAlIw4c4A0Lf4zgfJYv4 Issue for development skip no DueDate
PVTI_lADOAlIw4c4A0Lf4zgfJYvk PullRequest for development skip no DueDate

#>
$statusFieldName = "Status"
$dateFieldName = "DueDate"
$statusAction = "ActionRequired"
$statusPlanned = "Planned"

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$sf = ($content.data.organization.projectV2.fields.nodes | Where-Object { $_.name -eq $statusFieldName })
$df = ($content.data.organization.projectV2.fields.nodes | Where-Object { $_.name -eq $dateFieldName })
$project.updateStatusOnDueDate = @{
statusAction = $statusAction
statusPlanned = $statusPlanned
statusDoneOther = "Todo"
fields = @{ status = $sf ; dueDate = $df }
staged = @{
"PVTI_lADOAlIw4c4A0Lf4zgYNTyM" = @{ $($sf.id) = $statusAction } # draft0
"PVTI_lADOAlIw4c4A0Lf4zgfN-44" = @{ $($sf.id) = $statusAction } # draft5
"PVTI_lADOAlIw4c4A0Lf4zgfNuvM" = @{ $($sf.id) = $statusPlanned } # draft2
}
anyStatus = @{
"PVTI_lADOAlIw4c4A0Lf4zgYNTxI" = @{ $($sf.id) = $statusAction } # draft4
"PVTI_lADOAlIw4c4A0Lf4zgfN77A" = @{ $($sf.id) = $statusAction } # draft9

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
}
includeDone = @{
"PVTI_lADOAlIw4c4A0Lf4zgYNTc0" = @{ $($df.id) = "" } # draft8

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
}
includeDoneOther = @{
"PVTI_lADOAlIw4c4A0Lf4zgfN77A" = @{ $($df.id) = "" } # draft5
"PVTI_lADOAlIw4c4A0Lf4zgfOmpo" = @{ $($df.id) = "" } # draft9
}
anyStatus_and_includeDoneOther = @{
"PVTI_lADOAlIw4c4A0Lf4zgYNTxI" = @{ $($sf.id) = $statusAction } # draft4
"PVTI_lADOAlIw4c4A0Lf4zgfN77A" = @{ $($df.id) = "" } # draft5
"PVTI_lADOAlIw4c4A0Lf4zgfOmpo" = @{ $($df.id) = "" } # draft9
}
}

#############################
# Update With Integration #
#############################

$project.updateWithIntegration = @{
fieldSlug = "sf_"
integrationField = "sfUrl"
fields = @("sf_Int2","sf_Text1")

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
integrationCommand = "Get-SfAccount"

mockdata1 = @{
command = 'Get-SfAccount "https://some.com/1234/viuew"'
data = @{
"Text1" = "value11"
"Text2" = "value12"
"Number1" = 11
"Int2" = 111
}
}

mockdata2 = @{
command = 'Get-SfAccount "https://some.com/4321/viuew"'
data = @{
"Text1" = "value21"
"Text2" = "value22"
"Number1" = 22
"Int2" = 222
}
}

staged =@{
PVTI_lADOAlIw4c4A0Lf4zgfJYv4 = @{
PVTF_lADOAlIw4c4A0Lf4zg15NKg = 222
PVTF_lADOAlIw4c4A0Lf4zg15NMg = "value21"
}
PVTI_lADOAlIw4c4A0Lf4zgfJYvk = @{
PVTF_lADOAlIw4c4A0Lf4zg15NKg = 111
PVTF_lADOAlIw4c4A0Lf4zg15NMg = "value11"
}

}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
}

#############################
# Update With Injection #
#############################

$project.updateWithInjection = @{
item1 = @{
id = "PVTI_lADOAlIw4c4A0Lf4zgYNTxI"
fieldName = "sf_Text1"
}
item2 = @{
id = "PVTI_lADOAlIw4c4A0Lf4zgYNTc0"
fieldName = "Text1"
}
field1 = @{
id = "PVTF_lADOAlIw4c4A0Lf4zg15NMg"
name = "sf_Text1"
}
field2 = @{
id = "PVTF_lADOAlIw4c4A0Lf4zgp6aFk"
name = "Text1"
}
}



return $project

}


function Get-Mock_Project_626 {

$project = @{}

$project.projectFile = "invoke-GitHubOrgProjectWithFields-octodemo-626.json"
$project.projectFile_skipitems = "invoke-GitHubOrgProjectWithFields-octodemo-626-skipitems.json"

$content = Get-MockFileContentJson -FileName $project.projectFile
$p = $content.data.organization.projectV2

# Project info
$project.id = $p.id
$project.owner = $p.owner.login
$project.number = $p.number
$project.url = $p.url

# Add Items to mock
Add-ItemsToMock -project $project

# Sync with 625

$project.syncBtwPrj_625 = @{}
$project.syncBtwPrj_625.staged = @{
PVTI_lADOAlIw4c4A0QAozgfJYqo = @{
PVTF_lADOAlIw4c4A0QAozgqofEM = 33
PVTF_lADOAlIw4c4A0QAozgqoeOo = "Issue Text1 Value"
}
PVTI_lADOAlIw4c4A0QAozgfJYqk = @{
PVTF_lADOAlIw4c4A0QAozgqofEM = 11
PVTF_lADOAlIw4c4A0QAozgqoeOo = "PR Text1 Value"
}
}


return $project
}

function MockCall_GetProject {
[CmdletBinding()]
param(
[parameter(Position = 0)][object]$MockProject,
[parameter()][switch]$SkipItems,
[parameter()][switch]$Cache
)

$p = $MockProject ; $owner = $p.owner ; $projectNumber = $p.number

if ( $SkipItems ) {
$filename = $p.projectFile_skipitems
}
else {
$filename = $p.projectFile
}

MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
if ($Cache) {
$null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems
}
}

function Add-ItemsToMock {
[CmdletBinding()]
param(
[parameter(Mandatory, Position = 0)][object] $project
)

# Items
$project.items = @{}
$project.items.totalCount = $pActual.items.totalcount
$project.items.doneCount = 6 # too complicated to read from structure

# Issues to find
$project.issueToFind = @{}
$project.issueToFind.Ids = ($pActual.items.nodes | Where-Object { $_.content.title -eq "Issue to find" }).Id

# Issue for developer
$issue = $pActual.items.nodes | Where-Object { $_.content.title -eq "Issue for development" }
$project.issue = @{
id = $issue.id
contentId = $issue.content.id
title = $issue.content.title
status = ($issue.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
fieldtext = ($issue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text
}

# PullRequest for developer
$pullRequest = $pActual.items.nodes | Where-Object { $_.content.title -eq "PullRequest for development" }
$project.pullrequest = @{
id = $pullRequest.id
contentId = $pullRequest.content.id
title = $pullRequest.content.title
status = ($pullRequest.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
fieldtext = ($pullRequest.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text
}

# DraftIssue for developer
$draftIssue = $pActual.items.nodes | Where-Object { $_.content.title -eq "DraftIssue for development" }
$project.draftissue = @{
id = $draftIssue.id
contentId = $draftIssue.content.id
title = $draftIssue.content.title
status = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
fieldtext = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
}
}
Loading