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

mozilla / blurts-server / #12498

pending completion
#12498

push

circleci

web-flow
Merge pull request #2850 from mozilla/MNTOR-1106-Email-preview-non-auth

MNTOR-1106: Add non-auth email preview

282 of 1381 branches covered (20.42%)

Branch coverage included in aggregate %.

27 of 27 new or added lines in 6 files covered. (100.0%)

959 of 3745 relevant lines covered (25.61%)

2.08 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 { isAdminPreview = false } = data
×
40
  const {
41
    template: currentTemplateKey,
42
    data: emailTemplates,
43
    recipients
44
  } = data.email
×
45
  const selectedPreviewTemplate = emailTemplates[currentTemplateKey]?.template
×
46

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

56
        ${
57
          isAdminPreview
×
58
            ? `
59
                <form class='js-email-preview-form email-preview-form'>
60
                  ${getRecipientInputs(recipients)}
61

62
                  <button class='primary' type='submit'>
63
                    Send test email
64
                  </button>
65
                </form>
66
              `
67
            : ''
68
        }
69
      </div>
70
      <hr class='monitor-gradient'>
71
      ${selectedPreviewTemplate}
72
    </section>
73
  `
74
}
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