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

mozilla / blurts-server / 62239fd6-a80b-4d20-a005-d59c2c76d752

pending completion
62239fd6-a80b-4d20-a005-d59c2c76d752

Pull #2763

circleci

Robert Helmer
frontend work for v2 settings MNTOR-983
Pull Request #2763: Mntor 983 settings v2 frontend

282 of 1180 branches covered (23.9%)

Branch coverage included in aggregate %.

93 of 93 new or added lines in 3 files covered. (100.0%)

959 of 3141 relevant lines covered (30.53%)

4.92 hits per line

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

0.0
/src/client/js/settings.js
1
const settingsUpdateCommOption = document.getElementsByClassName(
×
2
  'radio-comm-option'
3
)
4
if (settingsUpdateCommOption.length) {
×
5
  console.log('settings update comm option')
×
6
  for (const el of settingsUpdateCommOption) {
×
7
    el.addEventListener('click', async (event) => {
×
8
      try {
×
9
        const communicationOption = event.target.getAttribute('data-comm-option')
×
10
        const csrfToken = document
×
11
          .getElementById('settings')
12
          .getAttribute('data-csrf-token')
13

14
        const response = await fetch('/api/v1/user/update-comm-option', {
×
15
          headers: {
16
            'Content-Type': 'application/json',
17
            'x-csrf-token': csrfToken
18
          },
19
          mode: 'same-origin',
20
          method: 'POST',
21
          body: JSON.stringify({ communicationOption })
22
        })
23

24
        if (response && response.redirected === true) {
×
25
          throw response.error
×
26
        }
27
      } catch (err) {
28
        throw new Error(`Updating communication option failed: ${err}`)
×
29
      }
30
      event.preventDefault()
×
31
      return false
×
32
    })
33
  }
34
}
35

36
const settingsAddEmail = document.getElementById('settings-add-email')
×
37
if (settingsAddEmail) {
×
38
  console.log('settings add email')
×
39
  settingsAddEmail.addEventListener('click', async (_) => {
×
40
    try {
×
41
      const addEmailDialog = document.getElementById('add-email-modal')
×
42
      addEmailDialog.showModal()
×
43
    } catch (err) {
44
      console.error(`Error: ${err}`)
×
45
    }
46
  })
47
}
48

49
const settingsClose = document.getElementById('settings-close')
×
50
if (settingsClose) {
×
51
  console.log('settings close')
×
52
  settingsAddEmail.addEventListener('click', async (_) => {
×
53
    try {
×
54
      const addEmailDialog = document.getElementById('add-email-modal')
×
55
      addEmailDialog.close()
×
56
    } catch (err) {
57
      console.error(`Error: ${err}`)
×
58
    }
59
  })
60
}
61

62
const settingsAddVerification = document.getElementById('send-verification')
×
63
if (settingsAddVerification) {
×
64
  console.log('settings send verification email')
×
65
  settingsAddVerification.addEventListener('click', async (_) => {
×
66
    const email = document.getElementById('email').value
×
67
    const csrfToken = document
×
68
      .getElementById('settings')
69
      .getAttribute('data-csrf-token')
70

71
    const response = await fetch('/api/v1/user/email', {
×
72
      headers: {
73
        'Content-Type': 'application/json',
74
        'x-csrf-token': csrfToken
75
      },
76
      mode: 'same-origin',
77
      method: 'POST',
78
      body: JSON.stringify({ email })
79
    })
80

81
    if (!response || !response.ok) {
×
82
      throw new Error(`sending verification email failed: ${response.error}`)
×
83
    }
84

85
    const addEmailDialogContent = document.getElementById('add-email-modal-content')
×
86
    addEmailDialogContent.textContent = `Verify the link sent to ${email} to add it to Firefox Monitor. Manage all email addresses in Settings.`
×
87

88
    const addEmailDialogControls = document.getElementById('add-email-modal-controls')
×
89
    addEmailDialogControls.hidden = true
×
90

91
    const addEmailDialog = document.getElementById('add-email-modal')
×
92
    addEmailDialog.addEventListener('close', _ => {
×
93
      addEmailDialogControls.hidden = false
×
94
      return window.location.reload(true)
×
95
    }, { once: true })
96
  })
97
}
98

99
const settingsRemoveEmail = document.getElementsByClassName('remove-email')
×
100
if (settingsRemoveEmail.length) {
×
101
  console.log('settings remove email')
×
102
  for (const el of settingsRemoveEmail) {
×
103
    el.addEventListener('click', async (event) => {
×
104
      try {
×
105
        const subscriberId = event.target.getAttribute('data-subscriber-id')
×
106
        const emailId = event.target.getAttribute('data-email-id')
×
107
        const csrfToken = document
×
108
          .getElementById('settings')
109
          .getAttribute('data-csrf-token')
110

111
        const response = await fetch('/api/v1/user/remove-email', {
×
112
          headers: {
113
            'Content-Type': 'application/json',
114
            'x-csrf-token': csrfToken
115
          },
116
          mode: 'same-origin',
117
          method: 'POST',
118
          body: JSON.stringify({ emailId, subscriberId })
119
        })
120

121
        if (response && response.redirected === true) {
×
122
          return window.location.reload(true)
×
123
        }
124
      } catch (err) {
125
        console.error(`Error: ${err}`)
×
126
      }
127
    })
128
  }
129
}
130

131
const settingsResendEmail = document.getElementsByClassName(
×
132
  'settings-resend-email'
133
)
134
if (settingsResendEmail.length) {
×
135
  console.log('settings resend email')
×
136
  for (const el of settingsResendEmail) {
×
137
    el.addEventListener('click', async (event) => {
×
138
      try {
×
139
        const emailId = event.target.getAttribute('data-email-id')
×
140
        const csrfToken = document
×
141
          .getElementById('settings')
142
          .getAttribute('data-csrf-token')
143

144
        const response = await fetch('/api/v1/user/resend-email', {
×
145
          headers: {
146
            'Content-Type': 'application/json',
147
            'x-csrf-token': csrfToken
148
          },
149
          mode: 'same-origin',
150
          method: 'POST',
151
          body: JSON.stringify({ emailId })
152
        })
153

154
        if (response && response.redirected === true) {
×
155
          throw response.error
×
156
        }
157
      } catch (err) {
158
        throw new Error(`re-sending verification email failed: ${err}`)
×
159
      }
160
      event.preventDefault()
×
161
      return false
×
162
    })
163
  }
164
}
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

© 2026 Coveralls, Inc