Skip to content

test(onboarding): add mailsac-code email verification strategy#3080

Merged
ygrishajev merged 1 commit intomainfrom
test/onboarding-mailsac-code-strategy
Apr 20, 2026
Merged

test(onboarding): add mailsac-code email verification strategy#3080
ygrishajev merged 1 commit intomainfrom
test/onboarding-mailsac-code-strategy

Conversation

@ygrishajev
Copy link
Copy Markdown
Contributor

@ygrishajev ygrishajev commented Apr 20, 2026

Why

Part of CON-152

Prepares E2E test infrastructure for the upcoming code-based email verification flow (PR #3052). The current strategies only support link-based verification.

What

  • Add MailsacCodeVerificationStrategy — polls Mailsac for the verification code email, extracts the 6-digit code from the plain text body via /text/ API endpoint, and enters it in the UI via page.keyboard.type()
  • Register mailsac-code option in the strategy factory and env config schema
  • Activated via EMAIL_VERIFICATION_STRATEGY=mailsac-code env var; existing strategies unchanged

Summary by CodeRabbit

  • New Features
    • Added a new "mailsac-code" email verification option — tests can now generate a mailsac-based alias, poll for verification messages, extract a 6-digit code, and enter it into the verification UI, alongside existing "mailsac" and "auth0-ticket" methods.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

Added a new email verification strategy "mailsac-code", extended the environment enum to accept it, implemented a Mailsac polling strategy that extracts 6-digit codes and types them into Playwright pages, and wired the strategy into the factory function. (≤50 words)

Changes

Cohort / File(s) Summary
Email Verification Configuration
apps/deploy-web/tests/ui/fixture/test-env.config.ts
Widened EMAIL_VERIFICATION_STRATEGY z.enum to include "mailsac-code" (default remains "mailsac").
Email Verification Service
apps/deploy-web/tests/ui/services/email-verification/index.ts
Factory createEmailVerificationStrategy() now returns MailsacCodeVerificationStrategy when strategy is "mailsac-code"; existing branches unchanged.
Mailsac Code Strategy Implementation
apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts
Added MailsacCodeVerificationStrategy class: deterministic email generation, polling Mailsac (30 attempts, 2s interval), extracts first standalone 6-digit code via regex, aggregates errors on timeout, and injects code into Playwright page input fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/onboarding-mailsac-code-strategy

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.05%. Comparing base (cc99165) to head (dde9013).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3080      +/-   ##
==========================================
- Coverage   60.93%   60.05%   -0.89%     
==========================================
  Files        1023      983      -40     
  Lines       24491    23488    -1003     
  Branches     6060     5891     -169     
==========================================
- Hits        14924    14105     -819     
+ Misses       8355     8184     -171     
+ Partials     1212     1199      -13     
Flag Coverage Δ *Carryforward flag
api 82.63% <ø> (ø) Carriedforward from cc99165
deploy-web 44.85% <ø> (+0.02%) ⬆️
log-collector ?
notifications 86.06% <ø> (ø) Carriedforward from cc99165
provider-console 81.48% <ø> (ø) Carriedforward from cc99165
provider-proxy 85.21% <ø> (ø) Carriedforward from cc99165
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.
see 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts`:
- Around line 16-20: The code assumes input.context.pages()[0] exists which can
crash when no pages or wrong tab is active; change the page selection to guard
for empty/multiple pages by checking input.context.pages().length > 0 and
selecting an appropriate page (e.g., the first non-null page or input.page)
before using it, and if no page found throw or return a clear error; update the
usage sites (page variable, firstDigitInput via getByLabel("Verification code
digit 1"), and subsequent page.keyboard.type(code)) so they only run after the
null/empty check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5341274e-3608-4bf7-bf37-259741004ca0

📥 Commits

Reviewing files that changed from the base of the PR and between cc99165 and d5d3901.

📒 Files selected for processing (3)
  • apps/deploy-web/tests/ui/fixture/test-env.config.ts
  • apps/deploy-web/tests/ui/services/email-verification/index.ts
  • apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts

Comment thread apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts Outdated
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Auto-approved: all changes are related to tests.

Add a new email verification strategy for the upcoming code-based
verification flow. Polls Mailsac for the verification code email,
extracts the 6-digit code from the body, and enters it in the UI.

Activated via EMAIL_VERIFICATION_STRATEGY=mailsac-code env var.
@ygrishajev ygrishajev force-pushed the test/onboarding-mailsac-code-strategy branch from d5d3901 to dde9013 Compare April 20, 2026 09:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts (1)

48-49: Avoid sleeping after the final polling attempt.

Line 48 currently adds an extra 2s delay even after the last attempt fails.

Proposed fix
-      await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
+      if (attempt < maxAttempts - 1) {
+        await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts`
around lines 48 - 49, The loop currently always awaits "await new
Promise(resolve => setTimeout(resolve, pollIntervalMs));" even after the final
polling attempt, causing an unnecessary delay; change the logic in the polling
function (the loop that uses pollIntervalMs and maxAttempts) to only sleep
between attempts by conditioning the await on not being the last iteration
(e.g., only await when currentAttempt < maxAttempts - 1) or move the sleep to
the start of the next iteration so no sleep occurs after the final attempt.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts`:
- Around line 48-49: The loop currently always awaits "await new Promise(resolve
=> setTimeout(resolve, pollIntervalMs));" even after the final polling attempt,
causing an unnecessary delay; change the logic in the polling function (the loop
that uses pollIntervalMs and maxAttempts) to only sleep between attempts by
conditioning the await on not being the last iteration (e.g., only await when
currentAttempt < maxAttempts - 1) or move the sleep to the start of the next
iteration so no sleep occurs after the final attempt.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6d45d3d5-e7e7-46aa-aa70-1332d6b75504

📥 Commits

Reviewing files that changed from the base of the PR and between d5d3901 and dde9013.

📒 Files selected for processing (3)
  • apps/deploy-web/tests/ui/fixture/test-env.config.ts
  • apps/deploy-web/tests/ui/services/email-verification/index.ts
  • apps/deploy-web/tests/ui/services/email-verification/mailsac-code.strategy.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/deploy-web/tests/ui/fixture/test-env.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/deploy-web/tests/ui/services/email-verification/index.ts

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Auto-approved: all changes are related to tests.

@ygrishajev ygrishajev added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit abeb3db Apr 20, 2026
54 checks passed
@ygrishajev ygrishajev deleted the test/onboarding-mailsac-code-strategy branch April 20, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant