Add flock exports, sharing invitations, and improved flock switching
Deploy / deploy-prod (push) Skipped
Deploy / deploy-dev (push) Successful in 3m53s

This commit is contained in:
Corey Blais committed 2026-10-08 11:19:50 -04:00
1 parent ff177dbaed
commit 55353e4d46
12 files changed
+557 -100

No files matched your search

@@ -0,0 +1,29 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { buildWorkspaceInviteEmail } from './workspaceInviteEmail.js';
const input = { name: '<Pat>', email: 'pat@example.test', inviterName: 'Alex & Sam', flockName: '<Rescue>', role: 'caregiver' as const, frontendUrl: 'https://flockpal.test/' };
test('invitation uses branded layout, escaped copy, and email-specific sign-in instructions', async () => {
const mail = await buildWorkspaceInviteEmail(input);
assert.match(String(mail.html), /&lt;Pat&gt;/);
assert.match(String(mail.html), /Alex &amp; Sam/);
assert.match(String(mail.html), /&lt;Rescue&gt;/);
assert.match(String(mail.html), /cid:flockpal-logo/);
assert.equal(mail.attachments?.length, 1);
assert.match(mail.text, /Sign in to FlockPal using pat@example.test/);
assert.match(mail.text, /cannot remove birds/);
assert.match(mail.text, /flock switcher/);
assert.match(String(mail.html), /href="https:\/\/flockpal.test\/"/);
});
test('invitation describes each assigned role and prevents multiline subjects', async () => {
for (const role of ['viewer', 'caregiver', 'assistant', 'owner'] as const) {
const mail = await buildWorkspaceInviteEmail({ ...input, role, flockName: 'Rescue\r\nFlock' });
assert.doesNotMatch(mail.subject, /[\r\n]/);
assert.ok(mail.text.includes(role.charAt(0).toUpperCase() + role.slice(1)));
if (role === 'viewer') assert.match(mail.text, /cannot edit records/);
if (role === 'assistant') assert.match(mail.text, /remove and transfer birds/);
if (role === 'owner') assert.match(mail.text, /does not change the billing owner/);
}
});