• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12299

pending completion
#12299

push

circleci

web-flow
Merge pull request #2790 from mozilla/MNTOR-1056-Migrate-breach-alert-email

Adds email preview for email verification and breach notification

282 of 1375 branches covered (20.51%)

Branch coverage included in aggregate %.

174 of 174 new or added lines in 17 files covered. (100.0%)

959 of 3709 relevant lines covered (25.86%)

2.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/views/partials/email-preview.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
function getPreviewOptions (currentTemplateKey, data) {
6
  const optionsElements = Object.keys(data).map(templateKey => (`
×
7
    <option
8
      value='${templateKey}'
9
      ${currentTemplateKey === templateKey ? 'selected' : ''}
×
10
    >
11
      ${data[templateKey].label}
12
    </option>
13
  `)).join('')
14

15
  return optionsElements
×
16
}
17

18
function getRecipientInputs (recipients) {
19
  const recipientInputElements = recipients.map((recipient, index) => (`
×
20
    <label>
21
      <input
22
        name="email-recipient-option"
23
        type="radio"
24
        value="${recipient}"
25
        ${index === 0 ? 'checked' : ''}
×
26
      >
27
      ${recipient}
28
    </label>
29
  `)).join('')
30

31
  return `
×
32
    <fieldset>
33
      ${recipientInputElements}
34
    </fieldset>
35
  `
36
}
37

38
export const emailPreview = data => {
×
39
  const {
40
    template: currentTemplateKey,
41
    data: emailTemplates,
42
    recipients
43
  } = data.email
×
44
  const selectedPreviewTemplate = emailTemplates[currentTemplateKey]?.template
×
45

46
  return `
×
47
    <script src="/js/partials/email-preview.js" type="module"></script>
48
    <section class='email-preview js-email' data-csrf-token=${data.csrfToken}>
49
      <h1>Email preview</h1>
50
      <div class='email-preview-controls'>
51
        <custom-select name='email-template'>
52
          ${getPreviewOptions(currentTemplateKey, emailTemplates)}
53
        </custom-select>
54

55
        <form class='js-email-preview-form email-preview-form'>
56
          ${getRecipientInputs(recipients)}
57

58
          <button class='primary' type='submit'>
59
            Send test email
60
          </button>
61
        </form>
62
      </div>
63
      <hr class='monitor-gradient'>
64
      ${selectedPreviewTemplate}
65
    </section>
66
  `
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc