Coming back to the feed shows it as it was left
Leaving the feed keeps it in Services/FeedMemory.cs (posts, waiting posts, cursors and scroll; ten minutes, for the same feed of the same persona), so coming back from a thread or a profile shows it again at once, older pages included, instead of reading it anew; newer posts come behind the "new" button and through the stream as before. tests/e2e FeedMemoryTests goes to a thread and back without a new read of the home timeline; the whole suite passes (123, 5 skipped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
5a7e1804a9
commit
23dbc68fb4
6 files changed
+164
-1
No files matched your search
@@ -0,0 +1,47 @@
|
||||
using decePubClient.E2E.Support;
|
||||
|
||||
using Microsoft.Playwright;
|
||||
|
||||
namespace decePubClient.E2E.Actions
|
||||
{
|
||||
// Coming back to the feed from a thread shows it as it was left, with its older pages, without reading it again
|
||||
// (Services/FeedMemory.cs).
|
||||
public sealed class FeedMemoryTests(Browser browser)
|
||||
{
|
||||
[Fact]
|
||||
public async Task The_feed_comes_back_from_a_thread_as_it_was_left()
|
||||
{
|
||||
var persona = Pasture.Personas().First();
|
||||
await using var session = await SignIn.As(browser, persona);
|
||||
var page = session.Page;
|
||||
await Results.Cell("client.action.feed-memory", "privapub", persona.UserName, async () =>
|
||||
{
|
||||
await page.GotoAsync($"{Pasture.Site}/");
|
||||
await page.EvaluateAsync("() => localStorage.removeItem('FeedFilter')");
|
||||
await page.GotoAsync($"{Pasture.Site}/");
|
||||
var feed = page.Locator("[data-feed-count]");
|
||||
await page.Locator("article[data-uri]").First.WaitForAsync(new() { Timeout = 30000 });
|
||||
// an older page too when there is one, so there is more to keep than the first
|
||||
await page.EvalOnSelectorAsync("#feed-scroll", "root => root.scrollTop = root.scrollHeight");
|
||||
await Pasture.Eventually(async () => int.Parse(await feed.GetAttributeAsync("data-feed-count") ?? "0") > 20, 10);
|
||||
var count = int.Parse(await feed.GetAttributeAsync("data-feed-count") ?? "0");
|
||||
|
||||
var homeReads = 0;
|
||||
page.Request += (_, request) =>
|
||||
{
|
||||
if (request.Url.Contains("/api/v1/timelines/home") && !request.Url.Contains("min_id"))
|
||||
homeReads++;
|
||||
};
|
||||
await page.EvalOnSelectorAsync("#feed-scroll", "root => root.scrollTop = 0");
|
||||
await page.Locator("article[data-uri] footer a[href^='expand/']").First.ClickAsync();
|
||||
await page.WaitForURLAsync("**/expand/**");
|
||||
await page.GoBackAsync();
|
||||
await page.Locator("article[data-uri]").First.WaitForAsync(new() { Timeout = 10000 });
|
||||
|
||||
Assert.True(int.Parse(await feed.GetAttributeAsync("data-feed-count") ?? "0") >= count, "the feed came back shorter than it was left");
|
||||
Assert.Equal(0, homeReads);
|
||||
await session.AssertGuards();
|
||||
}, page);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user