From b246a6c8b36c34e1f367ddedeb1ee54152d524f8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Oct 2026 17:44:23 +0000 Subject: [PATCH] Read news feed from main branch (#221) Release notes in docs/news.md and docs/assets/ are updated on main, so the app was showing only the placeholder when reading from v-next. Add a test that pins both URLs. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_0196uTHP3Q8Gegu4SCDXV2HW --- .../NewsFeedServiceTests.cs | 23 ++++++++++++++++++- .../Data/NewsFeedService.cs | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs b/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs index d204146..0f49239 100644 --- a/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs +++ b/src/NoteBookmark.MauiApp.Tests/NewsFeedServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Http; @@ -50,6 +51,24 @@ public async Task RefreshAsync_CachesMarkdownAndReferencedImagesForOfflineRender File.Exists(Path.Combine(_appDataDirectory, "docs", "assets", "logo.png")).Should().BeTrue(); } + [Fact] + public async Task RefreshAsync_DownloadsFeedAndAssetsFromMainBranch() + { + var requestedUrls = new List(); + var handler = CreateFeedHandler("# Updates\n\n![Logo](assets/logo.png)", "/docs/assets/logo.png"); + var service = CreateService(new StubHttpMessageHandler(request => + { + requestedUrls.Add(request.RequestUri!.AbsoluteUri); + return handler.Respond(request); + })); + + await service.RefreshAsync(); + + requestedUrls.Should().Equal( + "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/news.md", + "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/assets/logo.png"); + } + [Fact] public async Task GetHtmlAsync_WhenNoFeedIsCached_LoadsRemoteFeed() { @@ -180,6 +199,8 @@ private static StubHttpMessageHandler CreateFeedHandler(string markdown, params private sealed class StubHttpMessageHandler(Func responseFactory) : HttpMessageHandler { protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => - Task.FromResult(responseFactory(request)); + Task.FromResult(Respond(request)); + + public HttpResponseMessage Respond(HttpRequestMessage request) => responseFactory(request); } } diff --git a/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs b/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs index 99a1c73..4c0ec73 100644 --- a/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs +++ b/src/NoteBookmark.MauiApp/Data/NewsFeedService.cs @@ -15,8 +15,8 @@ namespace NoteBookmark.MauiApp.Data; public sealed class NewsFeedService : INewsFeedService { - private const string NewsFeedUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/v-next/docs/news.md"; - private const string NewsAssetsUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/v-next/docs/assets/"; + private const string NewsFeedUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/news.md"; + private const string NewsAssetsUrl = "https://raw.githubusercontent.com/fboucher/NoteBookmark/main/docs/assets/"; private const string FallbackHtml = "

Welcome to NoteBookmark! Check back here for product updates.

"; private static readonly Regex HtmlUrlAttributePattern = new( @"(?href|src)=""(?[^""]*)""",