feat(app): library, jobs, settings, server, welcome and about screens
Local-mode composition root (SQLite index, one JobEngine fed by a single handler registration list), keyset-paged library with thumbnail cache and hover scrub, live job list with throttled updates and the shell job bar, settings with live template validation and encoder self-test, server connection with trust-on-first-use and DPAPI token, first-run welcome, About with update check, and --capture screenshots with synthetic data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
94 files changed
+10130
-374
No files matched your search
@@ -0,0 +1,74 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Titano.App.About;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.App.Tests.About;
|
||||
|
||||
public sealed class UpdateCheckTests
|
||||
{
|
||||
[Theory]
|
||||
[Case("v1.2.3", "1.2.3")]
|
||||
[Case("1.2", "1.2.0")]
|
||||
[Case("V0.10.0-beta.2", "0.10.0")]
|
||||
[Case("v2.0.1+abc", "2.0.1")]
|
||||
public void TagsParseToVersions(string tag, string expected) =>
|
||||
Assert.Equal(Version.Parse(expected), UpdateCheck.ParseVersion(tag));
|
||||
|
||||
[Theory]
|
||||
[Case(null)]
|
||||
[Case("")]
|
||||
[Case("latest")]
|
||||
[Case("v-one")]
|
||||
public void OtherTagsAreIgnored(string? tag) => Assert.Null(UpdateCheck.ParseVersion(tag));
|
||||
|
||||
[Test]
|
||||
public void TheLatestReleaseIsComparedWithTheRunningVersion()
|
||||
{
|
||||
var release = UpdateCheck.Parse("""{ "tag_name": "v0.2.0", "html_url": "https://github.com/o/r/releases/tag/v0.2.0", "draft": false, "prerelease": false }""");
|
||||
Assert.NotNull(release);
|
||||
Assert.Equal(new Version(0, 2, 0), release!.Version);
|
||||
Assert.True(UpdateCheck.IsNewer(release, UpdateCheck.RunningVersion("0.1.0")));
|
||||
Assert.False(UpdateCheck.IsNewer(release, UpdateCheck.RunningVersion("0.2.0+local")));
|
||||
Assert.False(UpdateCheck.IsNewer(release, new Version(0, 2, 0, 0)));
|
||||
Assert.False(UpdateCheck.IsNewer(release, UpdateCheck.RunningVersion("1.0.0")));
|
||||
Assert.Equal("0.2.0", UpdateCheck.Display(release.Version));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DraftsPrereleasesAndOddLinksAreIgnored()
|
||||
{
|
||||
Assert.Null(UpdateCheck.Parse("""{ "tag_name": "v9.0.0", "html_url": "https://x", "prerelease": true }"""));
|
||||
Assert.Null(UpdateCheck.Parse("""{ "tag_name": "v9.0.0", "html_url": "https://x", "draft": true }"""));
|
||||
Assert.Null(UpdateCheck.Parse("""{ "tag_name": "v9.0.0", "html_url": "javascript:alert(1)" }"""));
|
||||
Assert.Null(UpdateCheck.Parse("""{ "html_url": "https://x" }"""));
|
||||
Assert.Null(UpdateCheck.Parse("[]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FetchReadsTheApiAndToleratesMissingReleases()
|
||||
{
|
||||
using var ok = new HttpClient(new Reply(HttpStatusCode.OK, """{ "tag_name": "v1.0.0", "html_url": "https://github.com/o/r/releases/tag/v1.0.0" }"""));
|
||||
var release = await UpdateCheck.FetchAsync(ok, "https://api.github.com/repos/o/r/releases/latest", "0.1.0", CancellationToken.None);
|
||||
Assert.Equal(new Version(1, 0, 0), release!.Version);
|
||||
|
||||
using var none = new HttpClient(new Reply(HttpStatusCode.NotFound, "{}"));
|
||||
Assert.Null(await UpdateCheck.FetchAsync(none, "https://api.github.com/repos/o/r/releases/latest", "0.1.0", CancellationToken.None));
|
||||
|
||||
using var garbage = new HttpClient(new Reply(HttpStatusCode.OK, "<html>"));
|
||||
Assert.Null(await UpdateCheck.FetchAsync(garbage, "https://api.github.com/repos/o/r/releases/latest", "0.1.0", CancellationToken.None));
|
||||
|
||||
using var broken = new HttpClient(new Reply(HttpStatusCode.InternalServerError, "{}"));
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => UpdateCheck.FetchAsync(broken, "https://api.github.com/repos/o/r/releases/latest", "0.1.0", CancellationToken.None));
|
||||
}
|
||||
|
||||
private sealed class Reply(HttpStatusCode status, string body) : HttpMessageHandler
|
||||
{
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
Assert.True(request.Headers.UserAgent.ToString().StartsWith("Titano/", StringComparison.Ordinal), "GitHub requires a User-Agent");
|
||||
return Task.FromResult(new HttpResponseMessage(status) { Content = new StringContent(body, Encoding.UTF8, "application/json") });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user