Skip to content

test(mail): characterize production email contracts - #2526

Open
niemyjski wants to merge 3 commits into
mainfrom
feature/email-template-contract-tests
Open

test(mail): characterize production email contracts#2526
niemyjski wants to merge 3 commits into
mainfrom
feature/email-template-contract-tests

Conversation

@niemyjski

@niemyjski niemyjski commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • restructures mailer tests around Arrange, Act, Assert and three-part test names
  • characterizes all nine production email templates without changing production code or output
  • validates rendered content, every extracted href and JSON-LD action, and current application routes
  • asserts external links by host allowlist (not full URLs) so marketing/wiki URL changes do not break characterization

Verification

  • dotnet test tests/Exceptionless.Tests/Exceptionless.Tests.csproj -- --filter-class Exceptionless.Tests.Mail.MailerTests (26 passed)
  • git diff --check

Post-Deploy Monitoring & Validation

No additional operational monitoring is required because this PR changes tests only; production email code and rendered output are unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18157c9300

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +642 to +643
return Regex.Matches(decodedBody, "(?:href=|\\\"(?:target|url)\\\":\\s*)\\\"(?<url>[^\\\"]+)\\\"")
.Select(match => match.Groups["url"].Value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Assert CTA hrefs separately from JSON-LD URLs

GetUrls combines anchor destinations with JSON-LD target/url values, so the new assertions cannot prove that a visible link is clickable. For example, if the View Organization anchor loses its href, its dashboard URL remains in the template's JSON-LD; Assert.Contains/AssertContainsUrl and the route whitelist still pass. Extract and assert anchor hrefs separately from structured-data actions so these tests catch broken email CTAs.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d64336d454

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


if (!String.Equals(uri.Authority, baseUri.Authority, StringComparison.OrdinalIgnoreCase))
{
Assert.Contains(uri.Authority, _expectedExternalHosts);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate complete external destinations

When an external link's scheme, path, query, or fragment changes but its host remains allowlisted, this assertion still passes—for example, http://github.com/wrong-page is accepted. This means accidental breakage of the FAQ, social-profile, or product links is no longer detected despite these tests characterizing known email destinations; compare against the complete expected external URLs or validate each host's allowed paths and HTTPS scheme.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b6a0805ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

Assert.DoesNotContain("/next/", uri.PathAndQuery, StringComparison.OrdinalIgnoreCase);
Assert.Matches(@"^/(?:event/[^/?#]+|stack/[^/?#]+(?:/(?:mark-fixed|ignored|discarded))?|project/[^/]+/(?:configure|error/(?:timeline|frequent|new))|account/(?:manage|verify)|organization/[^/]+/(?:dashboard|upgrade|frequent|manage)|signup|reset-password/[^/?#]+)(?:[/?].*)?$", uri.PathAndQuery);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject trailing segments on fixed internal routes

When an internal destination accidentally gains a trailing segment, such as /organization/{id}/dashboard/typo, this pattern still accepts it through (?:[/?].*)?; the corresponding Assert.Contains checks also pass because the expected URL remains a prefix. Tighten the route patterns so only routes that intentionally accept additional path segments or queries do so, otherwise broken email links remain undetected.

Useful? React with 👍 / 👎.

Comment on lines +637 to +638
return Regex.Matches(decodedBody, "(?:href=|\\\"(?:target|url)\\\":\\s*)\\\"(?<url>[^\\\"]+)\\\"")
.Select(match => match.Groups["url"].Value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse JSON-LD before accepting its action URLs

When an email's JSON-LD is malformed—for example, by a missing brace or comma—this regex still extracts its target and url strings, so every new URL assertion can pass even though email clients cannot consume the action markup. Extract the JSON-LD script and deserialize it before validating its action fields so the tests also enforce valid structured data.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
Exceptionless.Insulation 37% 35% 286
Exceptionless.Core 76% 67% 10267
Exceptionless.Web 85% 69% 7974
Exceptionless.AppHost 38% 41% 147
Summary 78% (25378 / 32357) 67% (11944 / 17698) 18674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant