@things-factory/notification 10.1.245 → 10.1.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/notification",
3
- "version": "10.1.245",
3
+ "version": "10.1.247",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -30,17 +30,17 @@
30
30
  "@material/web": "^2.0.0",
31
31
  "@operato/layout": "^10.0.0",
32
32
  "@operato/styles": "^10.0.0",
33
- "@things-factory/auth-base": "^10.1.245",
34
- "@things-factory/email-base": "^10.1.245",
35
- "@things-factory/i18n-base": "^10.1.245",
36
- "@things-factory/organization": "^10.1.245",
37
- "@things-factory/setting-base": "^10.1.245",
38
- "@things-factory/shell": "^10.1.245",
33
+ "@things-factory/auth-base": "^10.1.247",
34
+ "@things-factory/email-base": "^10.1.247",
35
+ "@things-factory/i18n-base": "^10.1.247",
36
+ "@things-factory/organization": "^10.1.247",
37
+ "@things-factory/setting-base": "^10.1.247",
38
+ "@things-factory/shell": "^10.1.247",
39
39
  "clipboard": "^2.0.6",
40
40
  "firebase": "^9.14.0",
41
41
  "firebase-admin": "^11.3.0",
42
42
  "google": "^2.1.0",
43
43
  "marked": "^15.0.0"
44
44
  },
45
- "gitHead": "f7479631094a1c70b486485b556885b069025f88"
45
+ "gitHead": "3c672029b2ef4a09f3370d37e5d225392856a602"
46
46
  }
@@ -7,6 +7,7 @@
7
7
  import { deliverNotice, type Notice, type NoticeChannelFunctions } from '../server/controllers/notice/deliver-notice'
8
8
  import { languageOf, noticeChannels, NOTICE_EMAIL, NOTICE_TEAMS_CHANNEL, teamsMessage } from '../server/controllers/notice/notice-channels'
9
9
  import { escapeHtml, noticeEmailForm, renderNoticeMarkdown, safeNoticeHref } from '../server/controllers/notice/notice-email'
10
+ import { brandOf, DEFAULT_BRAND, textColorOn } from '../server/controllers/notice/app-brand'
10
11
 
11
12
  type Calls = { push: any[]; mail: any[]; teams: { url: string; body: any }[]; reports: string[] }
12
13
 
@@ -326,3 +327,51 @@ describe('a notice to everyone in the domain (broadcast)', () => {
326
327
  expect((await deliverNotice(notice({ broadcast: true }), thrown.channels)).teams).toEqual({ sent: 0, failed: 1 })
327
328
  })
328
329
  })
330
+
331
+ describe('whose mail it is', () => {
332
+ const words = { subject: '[공지] 점검', body: '본문', action: '열기', note: '알림함에서 확인' }
333
+
334
+ test('the brand is the manifest\'s name, tagline and brand colour; the theme colour stands in for a missing brand colour', () => {
335
+ expect(brandOf({ name: 'operato office', tagline: 'Reimagining Business.', brand_color: '#059669', theme_color: '#262e38' })).toEqual({
336
+ name: 'operato office',
337
+ tagline: 'Reimagining Business.',
338
+ color: '#059669'
339
+ })
340
+ expect(brandOf({ name: 'Operato Plant', theme_color: '#0E8A56' })).toEqual({ name: 'Operato Plant', tagline: undefined, color: '#0e8a56' })
341
+ expect(brandOf({ name: ' ', brand_color: 'green', theme_color: '#abc' })).toEqual({ name: DEFAULT_BRAND.name, tagline: undefined, color: '#aabbcc' })
342
+ expect(brandOf(undefined)).toEqual({ name: DEFAULT_BRAND.name, tagline: undefined, color: DEFAULT_BRAND.color })
343
+ })
344
+
345
+ test('the text on the brand colour is white while it keeps 3:1, black below', () => {
346
+ expect(textColorOn('#059669')).toBe('#ffffff')
347
+ expect(textColorOn('#262e38')).toBe('#ffffff')
348
+ expect(textColorOn('#34d399')).toBe('#000000')
349
+ expect(textColorOn('#ffffff')).toBe('#000000')
350
+ })
351
+
352
+ test('the mail names the application and its tagline, and its band and button are the brand colour - no logo image', () => {
353
+ const brand = { name: 'operato <office>', tagline: 'Reimagining Business.', color: '#059669' }
354
+ const html = noticeEmailForm({ lang: 'ko', words, link: 'https://x.example/a', brand })
355
+
356
+ expect(html).toContain('operato &lt;office&gt;')
357
+ expect(html).toContain('Reimagining Business.')
358
+ expect(html).not.toContain('<img')
359
+ expect(html).not.toContain('#22a6a7')
360
+ expect(html.match(/background-color:#059669/g)).toHaveLength(2)
361
+ expect(html).toContain('border-top:2px solid #059669')
362
+
363
+ const plain = noticeEmailForm({ lang: 'ko', words })
364
+ expect(plain).toContain(`>${DEFAULT_BRAND.name}<`)
365
+ expect(plain).toContain(`background-color:${DEFAULT_BRAND.color}`)
366
+ })
367
+
368
+ test('the real channels carry the brand to the mail', async () => {
369
+ const { channels, calls } = fakeChannels({ [NOTICE_EMAIL]: 'on' }, { brand: { name: 'Brand X', tagline: 'Tag Y', color: '#1d4ed8' } })
370
+ await deliverNotice(notice(), channels)
371
+
372
+ expect(calls.mail.length).toBeGreaterThan(0)
373
+ expect(calls.mail[0].content).toContain('Brand X')
374
+ expect(calls.mail[0].content).toContain('Tag Y')
375
+ expect(calls.mail[0].content).toContain('background-color:#1d4ed8')
376
+ })
377
+ })