Skip to content

Commit

Permalink
Merge branch 'main' into gizdatullin/improvements
Browse files Browse the repository at this point in the history
# Conflicts:
#	Mindbox.YandexTracker/Extensions/ResponseExtensions.cs
  • Loading branch information
gizdatullin committed Oct 25, 2024
2 parents 64c57e9 + 059c455 commit 91816d9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ public async Task GetFieldCategoriesAsync_ResponseIsNotNullAndContainsSomeCatego
Assert.IsTrue(categories.Any());
}

[TestMethod]
public async Task CreateIssueAsync_CustomFields_ShouldCreatedIssueWithCustomFields()
{
var firstCategory = (await YandexTrackerClient.GetFieldCategoriesAsync()).ToList().FirstOrDefault()!;

var customField = await YandexTrackerClient.CreateLocalFieldInQueueAsync(TestQueueKey, new QueueLocalField
{
Id = "customFields",
CategoryId = firstCategory.Id,
FieldName = new QueueLocalFieldName
{
En = "customFields",
Ru = "Кастомное поле"
},
FieldType = QueueLocalFieldType.StringFieldType
});

var issue = await YandexTrackerClient.CreateIssueAsync(new Issue
{
QueueKey = TestQueueKey,
Summary = GetUniqueName(),
CustomFields = new()
{
{ customField.Id, "field1" }
}
});

var response = await YandexTrackerClient.GetIssueAsync(issue.Key);

Assert.IsNotNull(response);
Assert.IsTrue(response.CustomFields.ContainsKey(customField.Id));
}

[TestMethod]
public async Task CreateLocalFieldInQueueAsync_ValidRequest_ShouldCreatedLocalField()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Mindbox.YandexTracker;

Expand Down Expand Up @@ -72,4 +74,7 @@ internal sealed record CreateIssueResponse

[DataMember(Name = "favorite")]
public bool IsFavorite { get; init; }

[JsonExtensionData]
public Dictionary<string, object?> CustomFields { get; init; } = [];
}
4 changes: 2 additions & 2 deletions Mindbox.YandexTracker/Dtos/Responses/Read/GetIssueResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Newtonsoft.Json;

namespace Mindbox.YandexTracker;

Expand Down Expand Up @@ -82,5 +82,5 @@ internal sealed record GetIssueResponse
public IReadOnlyCollection<string> Tags { get; init; } = [];

[JsonExtensionData]
public Dictionary<string, object> Fields { get; init; } = [];
public Dictionary<string, object?> Fields { get; init; } = [];
}
6 changes: 4 additions & 2 deletions Mindbox.YandexTracker/Extensions/ResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public static Issue ToIssue(
PreviousStatus = value.PreviousStatus?.ToIssueStatus(issueStatusInfos),
IsFavorite = value.IsFavorite,
Start = value.Start,
Tags = value.Tags
Tags = value.Tags,
CustomFields = value.Fields
};
}

Expand Down Expand Up @@ -185,7 +186,8 @@ public static Issue ToIssue(
UpdatedAt = value.UpdatedAt,
Status = value.Status.ToIssueStatus(issueStatusInfos),
PreviousStatus = value.PreviousStatus?.ToIssueStatus(issueStatusInfos),
IsFavorite = value.IsFavorite
IsFavorite = value.IsFavorite,
CustomFields = value.CustomFields
};
}

Expand Down

0 comments on commit 91816d9

Please sign in to comment.