Simplify release notes workflow
Some checks failed
deploy-socialize / image (push) Successful in 1m9s
deploy-socialize / deploy (push) Has been cancelled

This commit is contained in:
2026-05-08 00:37:14 -04:00
parent 2eb54b9228
commit dcfdce1ec6
47 changed files with 12370 additions and 1974 deletions

View File

@@ -6,64 +6,16 @@ namespace Socialize.Tests.ReleaseCommunications;
public class ReleaseUpdateRulesTests
{
[Theory]
[InlineData("Feature", ReleaseUpdateCategory.Feature)]
[InlineData("improvement", ReleaseUpdateCategory.Improvement)]
[InlineData("Breaking Change", ReleaseUpdateCategory.BreakingChange)]
[InlineData("BreakingChange", ReleaseUpdateCategory.BreakingChange)]
internal void TryParseCategory_accepts_supported_categories(string value, ReleaseUpdateCategory expected)
{
bool parsed = ReleaseUpdateRules.TryParseCategory(value, out ReleaseUpdateCategory category);
Assert.True(parsed);
Assert.Equal(expected, category);
}
[Theory]
[InlineData("")]
[InlineData("Security")]
[InlineData("Maintenance")]
public void TryParseCategory_rejects_unsupported_categories(string value)
{
bool parsed = ReleaseUpdateRules.TryParseCategory(value, out _);
Assert.False(parsed);
}
[Theory]
[InlineData("Normal", ReleaseUpdateImportance.Normal)]
[InlineData("important", ReleaseUpdateImportance.Important)]
internal void TryParseImportance_accepts_supported_importance(string value, ReleaseUpdateImportance expected)
{
bool parsed = ReleaseUpdateRules.TryParseImportance(value, out ReleaseUpdateImportance importance);
Assert.True(parsed);
Assert.Equal(expected, importance);
}
[Theory]
[InlineData("Everyone", ReleaseUpdateAudience.Everyone)]
[InlineData("Organization Owners", ReleaseUpdateAudience.OrganizationOwners)]
[InlineData("developers", ReleaseUpdateAudience.Developers)]
internal void TryParseAudience_accepts_supported_audiences(string value, ReleaseUpdateAudience expected)
{
bool parsed = ReleaseUpdateRules.TryParseAudience(value, out ReleaseUpdateAudience audience);
Assert.True(parsed);
Assert.Equal(expected, audience);
}
[Fact]
public void ToDto_formats_breaking_change_category_for_display()
public void ToDto_maps_summary_to_description()
{
ReleaseUpdate update = new()
{
Id = Guid.NewGuid(),
Title = "API change",
Summary = "A workflow API changed.",
Category = ReleaseUpdateCategory.BreakingChange,
Importance = ReleaseUpdateImportance.Important,
Audience = ReleaseUpdateAudience.Developers,
TitleFr = "Changement API",
SummaryFr = "Une API du flux de travail a change.",
Status = ReleaseUpdateStatus.Published,
CreatedAt = DateTimeOffset.UtcNow,
UpdatedAt = DateTimeOffset.UtcNow,
@@ -73,18 +25,22 @@ public class ReleaseUpdateRulesTests
ReleaseUpdateDto dto = update.ToDto(isRead: true);
Assert.Equal("Breaking Change", dto.Category);
Assert.Equal("A workflow API changed.", dto.Description);
Assert.Equal("API change", dto.TitleEn);
Assert.Equal("A workflow API changed.", dto.DescriptionEn);
Assert.Equal("Changement API", dto.TitleFr);
Assert.Equal("Une API du flux de travail a change.", dto.DescriptionFr);
Assert.True(dto.IsRead);
}
[Fact]
public void VisibleTo_returns_everyone_updates_for_any_authenticated_user()
public void VisibleToUsers_returns_published_updates()
{
ReleaseUpdate update = NewPublishedUpdate(ReleaseUpdateAudience.Everyone);
ReleaseUpdate update = NewPublishedUpdate();
List<ReleaseUpdate> visibleUpdates = new[] { update }
.AsQueryable()
.VisibleTo(new ReleaseUpdateAudienceContext(IsDeveloper: false, IsOrganizationOwner: false))
.VisibleToUsers()
.ToList();
Assert.Same(update, Assert.Single(visibleUpdates));
@@ -93,37 +49,17 @@ public class ReleaseUpdateRulesTests
[Fact]
public void VisibleTo_rejects_unpublished_updates()
{
ReleaseUpdate update = NewPublishedUpdate(ReleaseUpdateAudience.Everyone);
ReleaseUpdate update = NewPublishedUpdate();
update.Status = ReleaseUpdateStatus.Draft;
List<ReleaseUpdate> visibleUpdates = new[] { update }
.AsQueryable()
.VisibleTo(new ReleaseUpdateAudienceContext(IsDeveloper: true, IsOrganizationOwner: true))
.VisibleToUsers()
.ToList();
Assert.Empty(visibleUpdates);
}
[Fact]
public void VisibleTo_requires_matching_restricted_audience()
{
ReleaseUpdate ownerUpdate = NewPublishedUpdate(ReleaseUpdateAudience.OrganizationOwners);
ReleaseUpdate developerUpdate = NewPublishedUpdate(ReleaseUpdateAudience.Developers);
List<ReleaseUpdate> ownerVisibleUpdates = new[] { ownerUpdate, developerUpdate }
.AsQueryable()
.VisibleTo(new ReleaseUpdateAudienceContext(IsDeveloper: false, IsOrganizationOwner: true))
.ToList();
List<ReleaseUpdate> developerVisibleUpdates = new[] { ownerUpdate, developerUpdate }
.AsQueryable()
.VisibleTo(new ReleaseUpdateAudienceContext(IsDeveloper: true, IsOrganizationOwner: false))
.ToList();
Assert.Same(ownerUpdate, Assert.Single(ownerVisibleUpdates));
Assert.Same(developerUpdate, Assert.Single(developerVisibleUpdates));
}
[Fact]
public void CreateMissingReadReceipts_creates_receipts_only_for_unread_visible_updates()
{
@@ -172,16 +108,15 @@ public class ReleaseUpdateRulesTests
Assert.False(ReleaseUpdateEmailRules.CanSendDigest(lastSentBefore.AddMinutes(1), lastSentBefore));
}
private static ReleaseUpdate NewPublishedUpdate(ReleaseUpdateAudience audience)
private static ReleaseUpdate NewPublishedUpdate()
{
return new ReleaseUpdate
{
Id = Guid.NewGuid(),
Title = "Update",
Summary = "Something changed.",
Category = ReleaseUpdateCategory.Improvement,
Importance = ReleaseUpdateImportance.Normal,
Audience = audience,
TitleFr = "Mise a jour",
SummaryFr = "Quelque chose a change.",
Status = ReleaseUpdateStatus.Published,
CreatedAt = DateTimeOffset.UtcNow,
UpdatedAt = DateTimeOffset.UtcNow,