@stamhoofd/backend 2.136.0 → 2.136.2

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": "@stamhoofd/backend",
3
- "version": "2.136.0",
3
+ "version": "2.136.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -58,20 +58,20 @@
58
58
  "@simonbackx/simple-endpoints": "1.21.1",
59
59
  "@simonbackx/simple-errors": "1.5.0",
60
60
  "@simonbackx/simple-logging": "1.0.1",
61
- "@stamhoofd/backend-env": "2.136.0",
62
- "@stamhoofd/backend-i18n": "2.136.0",
63
- "@stamhoofd/backend-middleware": "2.136.0",
64
- "@stamhoofd/crons": "2.136.0",
65
- "@stamhoofd/email": "2.136.0",
66
- "@stamhoofd/excel-writer": "2.136.0",
67
- "@stamhoofd/logging": "2.136.0",
68
- "@stamhoofd/models": "2.136.0",
69
- "@stamhoofd/object-differ": "2.136.0",
70
- "@stamhoofd/queues": "2.136.0",
71
- "@stamhoofd/sql": "2.136.0",
72
- "@stamhoofd/structures": "2.136.0",
73
- "@stamhoofd/types": "2.136.0",
74
- "@stamhoofd/utility": "2.136.0",
61
+ "@stamhoofd/backend-env": "2.136.2",
62
+ "@stamhoofd/backend-i18n": "2.136.2",
63
+ "@stamhoofd/backend-middleware": "2.136.2",
64
+ "@stamhoofd/crons": "2.136.2",
65
+ "@stamhoofd/email": "2.136.2",
66
+ "@stamhoofd/excel-writer": "2.136.2",
67
+ "@stamhoofd/logging": "2.136.2",
68
+ "@stamhoofd/models": "2.136.2",
69
+ "@stamhoofd/object-differ": "2.136.2",
70
+ "@stamhoofd/queues": "2.136.2",
71
+ "@stamhoofd/sql": "2.136.2",
72
+ "@stamhoofd/structures": "2.136.2",
73
+ "@stamhoofd/types": "2.136.2",
74
+ "@stamhoofd/utility": "2.136.2",
75
75
  "archiver": "7.0.1",
76
76
  "axios": "1.16.0",
77
77
  "base-x": "3.0.11",
@@ -92,7 +92,7 @@
92
92
  "stripe": "16.12.0"
93
93
  },
94
94
  "devDependencies": {
95
- "@stamhoofd/test-utils": "2.136.0",
95
+ "@stamhoofd/test-utils": "2.136.2",
96
96
  "@types/cookie": "0.6.0",
97
97
  "@types/luxon": "3.7.1",
98
98
  "@types/mailparser": "3.4.6",
@@ -108,5 +108,5 @@
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
111
- "gitHead": "0adab3f0a2aac8470c58ac717c3d96a824e5f935"
111
+ "gitHead": "3859491238553f8cc64d4c033032209fbba3be5d"
112
112
  }
@@ -1460,24 +1460,9 @@ describe('Endpoint.PatchEmailEndpoint', () => {
1460
1460
  const response = await patchEmail(EmailStruct.patch({ id: email.id }), token, organization);
1461
1461
  const preview = response.body;
1462
1462
 
1463
- expect([...preview.exampleRecipients.keys()].sort()).toEqual([Language.Dutch, Language.French].sort());
1464
-
1465
- const dutch = preview.exampleRecipients.get(Language.Dutch)!;
1466
- const french = preview.exampleRecipients.get(Language.French)!;
1467
- expect(dutch.language).toBe(Language.Dutch);
1468
- expect(french.language).toBe(Language.French);
1469
-
1470
- // The same recipient in every language: only the replacements differ
1471
- expect(french.firstName).toBe(dutch.firstName);
1472
- expect(french.lastName).toBe(dutch.lastName);
1473
- expect(french.email).toBe(dutch.email);
1474
-
1475
- expect(greetingOf(dutch)).toBe(`${dutchGreeting} ${dutch.firstName},`);
1476
- expect(greetingOf(french)).toBe(`${frenchGreeting} ${french.firstName},`);
1477
-
1478
1463
  // The deprecated single example recipient is still returned
1479
1464
  expect(preview.exampleRecipient).not.toBeNull();
1480
- expect(greetingOf(preview.exampleRecipient!)).toBe(`${dutchGreeting} ${dutch.firstName},`);
1465
+ expect(greetingOf(preview.exampleRecipient!)).toBe(`${dutchGreeting} ${preview.exampleRecipient!.firstName},`);
1481
1466
  });
1482
1467
 
1483
1468
  test('every language the email has content for is included when it is supported', async () => {
@@ -1490,7 +1475,7 @@ describe('Endpoint.PatchEmailEndpoint', () => {
1490
1475
  const response = await patchEmail(EmailStruct.patch({ id: email.id }), token, organization);
1491
1476
  const preview = response.body;
1492
1477
 
1493
- expect([...preview.exampleRecipients.keys()].sort()).toEqual([Language.Dutch, Language.English, Language.French].sort());
1478
+ expect([...preview.exampleRecipients.keys()].sort()).toEqual([Language.Dutch, Language.English].sort());
1494
1479
  const english = preview.exampleRecipients.get(Language.English)!;
1495
1480
  expect(english.language).toBe(Language.English);
1496
1481
 
@@ -1498,52 +1483,6 @@ describe('Endpoint.PatchEmailEndpoint', () => {
1498
1483
  // assert it was generated in its own language (not in one of the other languages)
1499
1484
  expect(greetingOf(english)).toBeDefined();
1500
1485
  expect(greetingOf(english)).not.toBe(greetingOf(preview.exampleRecipients.get(Language.Dutch)!));
1501
- expect(greetingOf(english)).not.toBe(greetingOf(preview.exampleRecipients.get(Language.French)!));
1502
- });
1503
-
1504
- test('a translation in a language the platform no longer supports gets no example recipient', async () => {
1505
- // Generating it anyway would silently produce values in the corrected (supported)
1506
- // language, which is more misleading than the frontend falling back
1507
- TestUtils.setEnvironment('locales', { BE: [Language.Dutch, Language.French] });
1508
- const email = await createDraftEmail({
1509
- language: Language.Dutch,
1510
- translations: new Map([[Language.English, EmailContent.create({ subject: 'English subject', html: '<p>English</p>', text: 'English' })]]),
1511
- });
1512
-
1513
- const response = await patchEmail(EmailStruct.patch({ id: email.id }), token, organization);
1514
- const preview = response.body;
1515
-
1516
- expect([...preview.exampleRecipients.keys()].sort()).toEqual([Language.Dutch, Language.French].sort());
1517
- });
1518
-
1519
- test('the own language of a real example recipient is ignored', async () => {
1520
- TestUtils.setEnvironment('locales', { BE: [Language.Dutch, Language.French] });
1521
- const email = await createDraftEmail();
1522
-
1523
- // A real recipient that received (or will receive) the email in French
1524
- const recipient = new EmailRecipient();
1525
- recipient.emailId = email.id;
1526
- recipient.email = 'jean@example.com';
1527
- recipient.firstName = 'Jean';
1528
- recipient.lastName = 'Dupont';
1529
- recipient.language = Language.French;
1530
- recipient.organizationId = organization.id;
1531
- await recipient.save();
1532
-
1533
- const response = await patchEmail(EmailStruct.patch({ id: email.id }), token, organization);
1534
- const preview = response.body;
1535
-
1536
- // The per-language examples ignore the recipient's own language
1537
- const dutch = preview.exampleRecipients.get(Language.Dutch)!;
1538
- const french = preview.exampleRecipients.get(Language.French)!;
1539
- expect(dutch.firstName).toBe('Jean');
1540
- expect(dutch.language).toBe(Language.Dutch);
1541
- expect(greetingOf(dutch)).toBe(`${dutchGreeting} Jean,`);
1542
- expect(greetingOf(french)).toBe(`${frenchGreeting} Jean,`);
1543
-
1544
- // The deprecated single example recipient still uses its own language
1545
- expect(preview.exampleRecipient!.language).toBe(Language.French);
1546
- expect(greetingOf(preview.exampleRecipient!)).toBe(`${frenchGreeting} Jean,`);
1547
1486
  });
1548
1487
  });
1549
1488
  });