Skip to content

refactor: remove redundant try/finally blocks in functional mail notification tests#449

Closed
Copilot wants to merge 2 commits intocodex/security-settings-email-notificationsfrom
copilot/sub-pr-448
Closed

refactor: remove redundant try/finally blocks in functional mail notification tests#449
Copilot wants to merge 2 commits intocodex/security-settings-email-notificationsfrom
copilot/sub-pr-448

Conversation

Copy link

Copilot AI commented Mar 16, 2026

The bootstrap already registers mail.fake() in test setup and mail.restore() in teardown for all functional/browser/e2e suites, making the explicit try/finally restore blocks in the notification tests redundant.

Changes

  • tests/functional/profile/totp.spec.ts — removed try/finally wrappers from the three notification assertion tests; mail.fake() call kept to obtain the fake reference
  • tests/functional/profile/webauthn.spec.ts — same cleanup; re-added explicit app.container.restore(WebauthnService) after assertions to match the existing pattern in the same file (previously it was inside the dropped finally block)

Before / After

// Before
test('destroy queues an email when TOTP is disabled', async ({ client }) => {
  const fakeMailer = mail.fake()
  try {
    // ... arrange + act + assert ...
  } finally {
    mail.restore() // redundant — bootstrap teardown already calls this
  }
})

// After
test('destroy queues an email when TOTP is disabled', async ({ client }) => {
  const fakeMailer = mail.fake()
  // ... arrange + act + assert ...
})

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: davideluque <10492210+davideluque@users.noreply.github.com>
Copilot AI changed the title [WIP] Add queued notification for security settings changes refactor: remove redundant try/finally blocks in functional mail notification tests Mar 16, 2026
Copilot AI requested a review from davideluque March 16, 2026 13:53
@davideluque
Copy link
Contributor

Closing as superseded by #448.

@davideluque
Copy link
Contributor

Superseded by changes already folded into #448. The current branch no longer uses the bootstrap-wide mail fake, and mail fakes are now scoped only to the notification-triggering flows instead (). Because of that, the cleanup in this draft is no longer the right change to merge separately.

@davideluque
Copy link
Contributor

Superseded by changes already folded into #448. The current branch no longer uses the bootstrap-wide mail fake, and mail fakes are now scoped only to the notification-triggering flows instead in commit 8646da0. Because of that, the try/finally cleanup in this draft is no longer the right change to merge separately.

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.

2 participants