更新UI
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using YMhut.Box.Core.Updates;
|
||||
|
||||
namespace YMhut.Box.Tests;
|
||||
|
||||
[TestClass]
|
||||
public sealed class UpdateNoticeDocumentTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void ReleaseNotesMarkdownBuildsReadableSections()
|
||||
{
|
||||
using var json = JsonDocument.Parse("""
|
||||
{
|
||||
"app_version": "2.0.7",
|
||||
"build": "10",
|
||||
"channel": "stable",
|
||||
"title": "YMhut Box 2.0.7.10",
|
||||
"release_notes_md": "## 新增能力\n\n- 新增结构化更新日志。\n- 支持分类和历史版本。\n\n## 修复优化\n\n- 修复长文本挤在一起的问题。"
|
||||
}
|
||||
""");
|
||||
|
||||
var document = UpdateNoticeDocumentBuilder.FromJson(json.RootElement, json.RootElement);
|
||||
|
||||
Assert.AreEqual("2.0.7", document.Version);
|
||||
Assert.HasCount(2, document.Sections);
|
||||
Assert.AreEqual("新增能力", document.Sections[0].Title);
|
||||
Assert.HasCount(2, document.Sections[0].Items);
|
||||
Assert.AreEqual("修复优化", document.Sections[1].Title);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateNotesAndCategoriesProduceStructuredCards()
|
||||
{
|
||||
using var json = JsonDocument.Parse("""
|
||||
{
|
||||
"app_version": "2.0.7",
|
||||
"category_list": [
|
||||
{ "id": "shell", "name": "壳层体验", "icon": "monitor" },
|
||||
{ "id": "stability", "name": "稳定性", "icon": "shield" }
|
||||
],
|
||||
"update_notes": {
|
||||
"壳层体验": "更新日志改为结构化卡片。",
|
||||
"稳定性": "修复公告弹窗拥挤。"
|
||||
},
|
||||
"last_update_notes": {
|
||||
"v2.0.6": "上一版优化工具结果展示。"
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
var document = UpdateNoticeDocumentBuilder.FromJson(json.RootElement, json.RootElement);
|
||||
|
||||
Assert.HasCount(2, document.Categories);
|
||||
Assert.HasCount(2, document.Sections);
|
||||
Assert.HasCount(1, document.History);
|
||||
Assert.AreEqual("壳层体验", document.Sections[0].Title);
|
||||
Assert.AreEqual("稳定性", document.Sections[1].Title);
|
||||
Assert.AreEqual("历史版本", document.History[0].Title);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PlainReleaseNotesSplitIntoMultipleItems()
|
||||
{
|
||||
using var json = JsonDocument.Parse("""
|
||||
{
|
||||
"app_version": "2.0.7",
|
||||
"release_notes": "修复更新日志过于拥挤;新增卡片式展示;优化弹窗滚动。"
|
||||
}
|
||||
""");
|
||||
|
||||
var document = UpdateNoticeDocumentBuilder.FromJson(json.RootElement, json.RootElement);
|
||||
|
||||
Assert.HasCount(1, document.Sections);
|
||||
Assert.IsGreaterThanOrEqualTo(document.Sections[0].Items.Count, 3);
|
||||
Assert.IsTrue(document.Sections[0].Items.Any(item => item.Kind == "fix"));
|
||||
Assert.IsTrue(document.Sections[0].Items.Any(item => item.Kind == "new"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user