A vote turned the other way replaces the first
Lemmy turns an upvote into a downvote with a Dislike alone (and back with a Like), so the like stayed counted next to the downvote. Now an account has one vote on a post: a Dislike takes its like away, a Like its downvote. The Lemmy scenario's relayed votes were never failing for that reason only: Lemmy 1.0 sends what it queued every 30 seconds, and the check gave up after 30. It waits a minute now, and both votes are plain checks: 22 pass, the moderator's removal stays an expected failure (P7). 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
325f7605f2
commit
bbeeda7268
5 files changed
+43
-13
No files matched your search
@@ -95,17 +95,43 @@ namespace PrivaPub.Tests.Federation
|
||||
["id"] = $"{Origin(carol)}/reactions/{Guid.NewGuid():N}", ["type"] = "EmojiReact", ["actor"] = carol.Id, ["object"] = post.ObjectURI,
|
||||
["content"] = "🔥"
|
||||
});
|
||||
Assert.Equal(1, (await DB.Default.Find<Post>().OneAsync(post.ID, token)).FavouritesCount);
|
||||
await _harness.Deliver(carol, "/human-centipede", new JsonObject
|
||||
{
|
||||
["id"] = $"{Origin(carol)}/dislikes/{Guid.NewGuid():N}", ["type"] = "Dislike", ["actor"] = carol.Id, ["object"] = post.ObjectURI
|
||||
});
|
||||
|
||||
// the downvote counts, and takes the place of carol's like (one vote each, as Lemmy votes)
|
||||
var stored = await DB.Default.Find<Post>().OneAsync(post.ID, token);
|
||||
Assert.Equal(1, stored.FavouritesCount);
|
||||
Assert.Equal(0, stored.FavouritesCount);
|
||||
Assert.Equal(1, stored.DownvotesCount);
|
||||
Assert.True(await DB.Default.Find<Reaction>().Match(r => r.PostId == post.ID && r.ActorURI == carol.Id && r.Emoji == "🔥").ExecuteAnyAsync(token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_vote_turned_the_other_way_replaces_the_first_as_lemmy_sends_it()
|
||||
{
|
||||
var token = TestContext.Current.CancellationToken;
|
||||
var (_, post) = await LocalPost();
|
||||
var voter = new RemoteActor(_harness.Peer, "voter");
|
||||
var other = new RemoteActor(_harness.Peer, "other");
|
||||
JsonObject Vote(RemoteActor actor, string type) => new()
|
||||
{
|
||||
["id"] = $"{Origin(actor)}/{type.ToLowerInvariant()}s/{Guid.NewGuid():N}", ["type"] = type, ["actor"] = actor.Id, ["object"] = post.ObjectURI
|
||||
};
|
||||
|
||||
await _harness.Deliver(other, "/human-centipede", Vote(other, "Like"));
|
||||
await _harness.Deliver(voter, "/human-centipede", Vote(voter, "Dislike"));
|
||||
await _harness.Deliver(voter, "/human-centipede", Vote(voter, "Like"));
|
||||
var up = await DB.Default.Find<Post>().OneAsync(post.ID, token);
|
||||
Assert.Equal((2, 0), (up.FavouritesCount, up.DownvotesCount));
|
||||
|
||||
await _harness.Deliver(voter, "/human-centipede", Vote(voter, "Dislike"));
|
||||
var down = await DB.Default.Find<Post>().OneAsync(post.ID, token);
|
||||
Assert.Equal((1, 1), (down.FavouritesCount, down.DownvotesCount));
|
||||
Assert.False(await DB.Default.Find<Favourite>().Match(f => f.PostId == post.ID && f.ActorURI == voter.Id).ExecuteAnyAsync(token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_circle_member_likes_a_circle_post_and_an_outsider_cannot()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user