Files
james.maesandCodex GPT-6 38dd5c1488 feat: implement Windows MarkdownViewr (#35)
This replaces the blocked history in PR #3 with one properly attributed,
signed/DCO commit. The owner personally reviewed and approved PR #3 in
the release session.

**No file changes from the approved candidate:** both
baee14f492 and
e605df62c4 have exact Git tree
a85912cbad. Original PR #3 and its commits
are preserved for review history. Historical commits were locally signed
but GitHub reported no_user; protected merge checks those introduced
commits even for squash merging. This commit resolves attribution
without bypassing or weakening signature rules.

The reader, Settings, themes, source highlighting/split, live reload,
file associations, Print/PDF, About credits, toolbar/footer/editor
fixes, user-first README/screenshots and developer guides are exactly
the approved implementation. Stable/dev separation and protected Azure
signing caller are unchanged.

Evidence:
- Approved tree baee14f / CI38285775463 passes all checks. Downloaded
focused29/29, published111/111, stable110/110 and dev110/110 TRXs have
zero failures/skips. Core coverage100% lines/98.86% branches; actual
update/restart/coexistence/default-preservation receipts verify.
- New single-commit hooks, online workflow security, signing and DCO
pass. GitHub must rerun all required checks on this commit; results are
not copied across SHAs.
- Live repository setup validates18 Actions-bound checks, with only
fuzzing added and all prior protections preserved.
- OpenSSF project15417 is now owner-reviewed and saved at70% under
owner-confirmed CDLA-Permissive2.0. This is an in-progress assessment,
not a passing badge.
- Production CI OIDC and signed1.0/dev publication remain required;
local representative signing is not CI proof.

Substantial AI assistance: Codex (GPT-6). Supersedes PR #3. Release work
remains tracked in #33.

Closes #4, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18,
#19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #32, #34.
Refs #1, #5, #30, #31, #33.

Signed-off-by: James Maes <james@kof22.com>
Co-authored-by: Codex GPT-6 <noreply@openai.com>
2026-10-12 14:01:42 -05:00

117 lines
4.1 KiB
C#

/*
* Copyright (c) 2026 James Maes
* SPDX-License-Identifier: MIT
*/
using MarkdownViewr.Windows.Core.Documents;
namespace MarkdownViewr.Windows.Core.Tests;
/// <summary>Covers picker/save races without filesystem timing or a desktop.</summary>
public sealed class DocumentLoadSchedulerTests
{
/// <summary>An idle document request starts immediately and leaves no queued work.</summary>
[Fact]
public void TryBegin_Idle_StartsImmediately()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("first.md", reload: false));
Assert.Null(queue.Complete("first.md"));
}
/// <summary>A file selected while a save reload is active is preserved for the next load.</summary>
[Fact]
public void TryBegin_PickerDuringReload_QueuesTheSelection()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("old.md", reload: true));
Assert.False(queue.TryBegin("new.md", reload: false));
Assert.Equal(("new.md", false), queue.Complete("old.md"));
}
/// <summary>Repeated save events consume one pending refresh rather than an unbounded queue.</summary>
[Fact]
public void TryBegin_RepeatedReloads_Coalesces()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("document.md", reload: true));
Assert.False(queue.TryBegin("document.md", reload: true));
Assert.False(queue.TryBegin("document.md", reload: true));
Assert.Equal(("document.md", true), queue.Complete("document.md"));
Assert.True(queue.TryBegin("document.md", reload: true));
Assert.Null(queue.Complete("document.md"));
}
/// <summary>An explicit picker selection takes priority over notifications from the previous document.</summary>
[Fact]
public void Complete_OpenAndReloadPending_PrioritizesOpen()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("old.md", reload: true));
Assert.False(queue.TryBegin("new.md", reload: false));
Assert.False(queue.TryBegin("old.md", reload: true));
Assert.Equal(("new.md", false), queue.Complete("old.md"));
Assert.True(queue.TryBegin("new.md", reload: false));
Assert.Null(queue.Complete("new.md"));
}
/// <summary>The user's most recent pending explicit selection wins.</summary>
[Fact]
public void Complete_MultipleSelections_UsesTheLatest()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("first.md", reload: false));
Assert.False(queue.TryBegin("second.md", reload: false));
Assert.False(queue.TryBegin("third.md", reload: false));
Assert.Equal(("third.md", false), queue.Complete("first.md"));
}
/// <summary>Reloading needs an established current document, even if the first open failed.</summary>
[Fact]
public void Complete_NoCurrentDocument_DiscardsPendingReload()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("missing.md", reload: false));
Assert.False(queue.TryBegin("missing.md", reload: true));
Assert.Null(queue.Complete(null));
}
/// <summary>If a selected file fails to open, a pending save of the retained document is still processed.</summary>
[Fact]
public void Complete_FailedSelection_RetainsThePreviousDocumentRefresh()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("old.md", reload: true));
Assert.False(queue.TryBegin("missing.md", reload: false));
Assert.False(queue.TryBegin("old.md", reload: true));
Assert.Equal(("missing.md", false), queue.Complete("old.md"));
Assert.True(queue.TryBegin("missing.md", reload: false));
Assert.Equal(("old.md", true), queue.Complete("old.md"));
}
/// <summary>The loader returns to idle after a failed or completed request.</summary>
[Fact]
public void Complete_AfterFailure_AllowsAnotherOpen()
{
var queue = new DocumentLoadScheduler();
Assert.True(queue.TryBegin("missing.md", reload: false));
Assert.Null(queue.Complete(null));
Assert.True(queue.TryBegin("existing.md", reload: false));
}
}