diff --git a/Test/public/project_item.test.ps1 b/Test/public/project_item.test.ps1 index c1e85dd..d44590c 100644 --- a/Test/public/project_item.test.ps1 +++ b/Test/public/project_item.test.ps1 @@ -74,6 +74,44 @@ function Test_GetProjectItem_Comments{ Assert-AreEqual -Expected $c.last.updatedAt -Presented $result.commentLast.updatedAt } +function Test_GetProjectItem_Staged_Title{ + Reset-InvokeCommandMock + Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number + $i = $p.issue + $itemId = $i.id + + MockCall_GetProject $p -Cache + + # Act - stage a change + $newTitle = "Staged title change" + Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId -FieldName "Title" -Value $newTitle + + # Act get item + $result = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $itemId + + Assert-AreEqual -Expected $newTitle -Presented $result.Title +} + +function Test_GetProjectItem_Staged_Body{ + Reset-InvokeCommandMock + Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number + $i = $p.issue + $itemId = $i.id + + MockCall_GetProject $p -Cache + + # Act - stage a change + $newBody = "Staged body change" + Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId -FieldName "Body" -Value $newBody + + # Act get item + $result = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $itemId + + Assert-AreEqual -Expected $newBody -Presented $result.Body +} + function Test_TestProjectItem_Success{ Reset-InvokeCommandMock diff --git a/Test/public/project_item_list.test.ps1 b/Test/public/project_item_list.test.ps1 index 601f677..caed1f2 100644 --- a/Test/public/project_item_list.test.ps1 +++ b/Test/public/project_item_list.test.ps1 @@ -17,7 +17,7 @@ function Test_GetProjetItemList_SUCCESS{ $randomItem = $result.$($i.Id) Assert-AreEqual -Presented $randomItem.Title -Expected "Issue for development" - Assert-AreEqual -Presented $randomItem.body -Expected "Body of issue for development" + Assert-AreEqual -Presented $randomItem.Body -Expected "Body of issue for development" Assert-AreEqual -Presented $randomItem.state -Expected "OPEN" Assert-AreEqual -Presented $randomItem.id -Expected "PVTI_lADOAlIw4c4BCe3Vzgeio4o" Assert-AreEqual -Presented $randomItem.type -Expected "Issue" diff --git a/private/item/convertItemToHash.ps1 b/private/item/convertItemToHash.ps1 index 4d8d79d..1cb0a7d 100644 --- a/private/item/convertItemToHash.ps1 +++ b/private/item/convertItemToHash.ps1 @@ -17,7 +17,7 @@ function Convert-NodeItemToHash { # Content $item.type = $NodeItem.content.__typename - $item.body = $NodeItem.content.body + $item.Body = $NodeItem.content.body $item.contentId = $NodeItem.content.id # Comments diff --git a/private/projectDatabase/project_database_Item.ps1 b/private/projectDatabase/project_database_Item.ps1 index ef9905c..922ef44 100644 --- a/private/projectDatabase/project_database_Item.ps1 +++ b/private/projectDatabase/project_database_Item.ps1 @@ -28,7 +28,6 @@ function Get-Item{ # Get fieldname $fieldname = $database.Staged.$ItemId.$fieldKey.Field.name - # Make type conversions to string $ret.$fieldname = $database.Staged.$ItemId.$fieldKey.Value } } diff --git a/private/projectDatabase/project_database_update.ps1 b/private/projectDatabase/project_database_update.ps1 index 42b5dc1..01fbbfb 100644 --- a/private/projectDatabase/project_database_update.ps1 +++ b/private/projectDatabase/project_database_update.ps1 @@ -300,75 +300,4 @@ function GetPullRequests{ $ret = $ret | ConvertTo-Json return $ret -} - -# function Convert-ItemFromResponse{ -# [CmdletBinding()] -# param( -# [Parameter(Position = 0)][object]$ProjectV2Item -# ) - -# $nodeItem = $ProjectV2Item - -# $item = New-Object System.Collections.Hashtable -# $item.id = $nodeItem.id - -# # Content -# $item.type = $nodeItem.content.__typename -# $item.body = $nodeItem.content.body -# # Title is stored in two places. in the content and as a field. -# # We will use the field value -# # $item.title = $nodeItem.content.title -# $item.number = $nodeItem.content.number -# $item.url = $nodeItem.content.url - -# # Populate content info based on item type -# switch ($item.type) { -# "Issue" { -# $item.url = $nodeItem.content.url -# } -# Default {} -# } - -# #Fields -# foreach($nodefield in $nodeItem.fieldValues.nodes){ -# switch($nodefield.__typename){ -# "ProjectV2ItemFieldTextValue" { -# $value = $nodefield.text -# } -# "ProjectV2ItemFieldSingleSelectValue" { -# $value = $nodefield.name -# } -# "ProjectV2ItemFieldNumberValue" { -# $value = $nodefield.number -# } -# "ProjectV2ItemFieldDateValue" { -# $value = $nodefield.date -# } -# "ProjectV2ItemFieldUserValue" { -# $value = GetUsers -FieldNode $nodefield -# } -# "ProjectV2ItemFieldRepositoryValue" { -# $value = $nodefield.repository.url -# } -# "ProjectV2ItemFieldLabelValue" { -# $value = GetLabels -FieldNode $nodefield -# } -# "ProjectV2ItemFieldMilestoneValue" { -# $value = $nodefield.milestone.title -# } -# "ProjectV2ItemFieldPullRequestValue" { -# $value = GetPullRequests -FieldNode $nodefield -# } -# Default { -# $value = $nodefield.text -# } -# } -# $item.$($nodefield.field.name) = $value - -# # $item.$($nodefield.field.name) = $nodefield.name -# } - -# return $item - -# } +} \ No newline at end of file diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index d1f6348..b00c67d 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -50,7 +50,7 @@ function Show-ProjectItem{ # Body addJumpLine ; "--- Body ---" | write Cyan ; addJumpLine - $item.body | write -Color Gray + $item.Body | write -Color Gray addJumpLine