fix(ci): repair Journey route registration and shared client behavior

Register the public view route, align generated entities and test fixtures, and share the scoped reads and access switches. Keep gallery and notification writes in order, and submit the email subscription from the dialog footer.
This commit is contained in:
Maurice
2026-11-30 17:32:50 +01:00
parent 6d14eb6677
commit 0c08a6dcb9
50 changed files with 531 additions and 417 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"src": {
"@typescript-eslint/no-explicit-any": 81,
"@typescript-eslint/no-non-null-assertion": 263,
"@typescript-eslint/no-non-null-assertion": 257,
"@typescript-eslint/no-require-imports": 18,
"@typescript-eslint/no-unsafe-function-type": 1,
"@typescript-eslint/no-unused-vars": 34,
@@ -21,9 +21,9 @@ export const JourneyShareSubscribersSchema = defineEntity({
class: JourneyShareSubscribers,
repository: () => JourneyShareSubscribersRepository,
uniques: [
{ properties: ['confirm_token'] },
{ properties: ['unsubscribe_token'] },
{ properties: ['shareToken', 'email'] },
{ properties: ['unsubscribe_token'] },
{ properties: ['confirm_token'] },
],
properties: {
id: p.integer().primary(),
@@ -133,6 +133,7 @@ export const PUBLIC_ROUTE_ALLOW_LIST: string[] = [
'JourneyPublicController.mapLayers',
'JourneyPublicController.photo',
'JourneyPublicController.unlock',
'JourneyPublicController.view',
// Share-token validated too: the comments and following a shared journey by email (#1702, #1669).
'JourneyPublicSocialController.addComment',
'JourneyPublicSocialController.listComments',
@@ -8,6 +8,7 @@ import type { JourneyShareSubscribersRepository } from '../../db/repositories/Jo
import type { JourneyShareTokensRepository } from '../../db/repositories/JourneyShareTokens.repository';
import type { JourneysRepository } from '../../db/repositories/Journeys.repository';
import { dbNow } from '../../db/types';
import { forEachInOrder } from '../../utils/for-each-in-order';
import { AddonsService } from '../addons/addons.service';
import { logError } from '../audit/audit-log.logger';
import { MailerService } from '../notifications/mailer/mailer.service';
@@ -80,7 +81,8 @@ export class JourneyDigestService {
const forgetBefore = dbNow(new Date(now.getTime() - UNCONFIRMED_KEEP_MS));
result.purged = await this.subscribersRepo.purgeUnconfirmed(forgetBefore);
const canMail = await this.mailer.isSmtpConfigured();
for (const journeyId of await this.entriesRepo.listJourneysToAnnounce()) {
const journeyIds = await this.entriesRepo.listJourneysToAnnounce();
await forEachInOrder(journeyIds, async (journeyId) => {
try {
const done = await this.announce(journeyId, now, canMail);
result.journeys += 1;
@@ -89,7 +91,7 @@ export class JourneyDigestService {
} catch (err) {
logError(`[journey-digest] journey ${journeyId}: ${message(err)}`);
}
}
});
return result;
}
@@ -107,8 +109,9 @@ export class JourneyDigestService {
/** Everyone on the journey, unless every new entry is their own. */
private async notifyPeople(journeyId: number, title: string, entries: JourneyEntryToAnnounce[]): Promise<number> {
let notified = 0;
for (const userId of await this.journeysRepo.listRecipientUserIds(journeyId)) {
if (!entries.some((e) => e.author_id !== userId)) continue;
const recipients = await this.journeysRepo.listRecipientUserIds(journeyId);
await forEachInOrder(recipients, async (userId) => {
if (!entries.some((e) => e.author_id !== userId)) return;
try {
await this.notifications.send({
event: 'journey_entry_published',
@@ -121,7 +124,7 @@ export class JourneyDigestService {
} catch (err) {
logError(`[journey-digest] notifying user ${userId}: ${message(err)}`);
}
}
});
return notified;
}
@@ -144,7 +147,7 @@ export class JourneyDigestService {
// what the password guards. They only hear that there is something new.
const named = link.password_hash ? [] : entries;
const mailed: number[] = [];
for (const follower of due) {
await forEachInOrder(due, async (follower) => {
const mail = digestMail(follower.locale, title, named, {
link: link.token,
unsubscribe: follower.unsubscribe_token,
@@ -152,7 +155,7 @@ export class JourneyDigestService {
if (await this.mailer.sendStandaloneEmail(follower.email, mail, unsubscribeUrl(follower.unsubscribe_token))) {
mailed.push(follower.id);
}
}
});
await this.subscribersRepo.markNotified(mailed, dbNow(now));
return mailed.length;
}
@@ -3,6 +3,7 @@ import { JourneyPhotos } from '../../db/entities/JourneyPhotos.entity';
import type { JourneyEntryPhotosRepository } from '../../db/repositories/JourneyEntryPhotos.repository';
import type { JourneyPhotoOffEntryRow, JourneyPhotosRepository } from '../../db/repositories/JourneyPhotos.repository';
import { getCountryFromCoords } from '../../utils/country-borders';
import { forEachInOrder } from '../../utils/for-each-in-order';
import { forbidden, notFound } from '../common/domain-error';
import { UnitOfWork } from '../database/unit-of-work';
import { MapsService } from '../maps/maps.service';
@@ -178,10 +179,10 @@ export class JourneyEntriesFromPhotosService {
const byPoint = new Map<string, string | null>();
const names: (string | null)[] = [];
let asked = 0;
for (const summary of summaries) {
await forEachInOrder(summaries, async (summary) => {
if (summary.lat === null || summary.lng === null) {
names.push(null);
continue;
return;
}
// About a kilometre: two groups of the same town share one lookup.
const key = `${summary.lat.toFixed(2)},${summary.lng.toFixed(2)}`;
@@ -196,7 +197,7 @@ export class JourneyEntriesFromPhotosService {
byPoint.set(key, found);
}
names.push(byPoint.get(key) ?? null);
}
});
return names;
}
@@ -232,7 +233,7 @@ export class JourneyEntriesFromPhotosService {
const claimed = new Set<number>();
const skipped: number[] = [];
const written: Array<{ entry: CreatedEntry; photoCount: number }> = [];
for (const group of request.groups) {
await forEachInOrder(request.groups, async (group) => {
const photos: LocalCapture[] = [];
for (const id of group.photoIds) {
const capture = captures.get(id);
@@ -243,7 +244,7 @@ export class JourneyEntriesFromPhotosService {
claimed.add(id);
photos.push(capture);
}
if (!photos.length) continue;
if (!photos.length) return;
const summary = summarizeCluster(photos);
const countryCode = countryOf(summary.lat, summary.lng);
const entry = await this.journeys.createEntry(
@@ -265,22 +266,22 @@ export class JourneyEntriesFromPhotosService {
);
if (!entry) throw forbidden('Not allowed');
const now = Date.now();
for (const [index, photoId] of summary.photoIds.entries()) {
await forEachInOrder(summary.photoIds, async (photoId, index) => {
await this.entryPhotosRepo.insertIgnore(entry.id, photoId, index, now);
}
});
written.push({ entry, photoCount: summary.photoIds.length });
}
});
return { written, skipped };
});
for (const { entry } of done.written) {
await forEachInOrder(done.written, async ({ entry }) => {
try {
await this.journeys.broadcastJourneyEvent(journeyId, 'journey:entry:created', { entry }, socketId);
} catch (err) {
// The drafts are committed. A failed notification cannot undo the write.
this.logger.warn(`draft entry event failed: ${err instanceof Error ? err.message : String(err)}`);
}
}
});
return {
entries: done.written.map(({ entry, photoCount }) => ({
id: entry.id,
+10
View File
@@ -0,0 +1,10 @@
/**
* Run one operation at a time, in input order. Used for writes sharing a
* transaction and external services that should not receive a burst.
*/
export function forEachInOrder<T>(
values: readonly T[],
visit: (value: T, index: number) => Promise<void>,
): Promise<void> {
return values.reduce((pending, value, index) => pending.then(() => visit(value, index)), Promise.resolve());
}
@@ -20,6 +20,7 @@ import { TrekPhotos } from '../../src/db/entities/TrekPhotos.entity';
import { createLocalMcpServer, McpRegistryService } from '../../src/nest-mcp';
import { withRequestContext } from '../../src/nest/database/request-context';
import { MapsService } from '../../src/nest/maps/maps.service';
import { forEachInOrder } from '../../src/utils/for-each-in-order';
import { addJourneyContributor, makeJourney } from '../helpers/factories/journeys';
import { countRows, findRows, insertRow } from '../helpers/factories/rows';
import { setAddonEnabled } from '../helpers/factories/settings';
@@ -221,10 +222,11 @@ describe('journey entries from photos e2e', () => {
expect(strangerRes.status).toBe(404);
expect(strangerRes.body).toMatchObject({ error: 'Journey not found' });
for (const bad of [{}, { groups: [] }, { groups: [{ photoIds: ['1'] }] }, { groups: [{ photoIds: [1] }], x: 1 }]) {
const invalid = [{}, { groups: [] }, { groups: [{ photoIds: ['1'] }] }, { groups: [{ photoIds: [1] }], x: 1 }];
await forEachInOrder(invalid, async (bad) => {
const res = await request(app.getHttpServer()).post(base(s.journey.id)).set(as(s.owner.id)).send(bad);
expect(res.status, JSON.stringify(bad)).toBe(400);
}
});
const badZone = await request(app.getHttpServer())
.post(`${base(s.journey.id)}/preview`)
.set(as(s.owner.id))
@@ -12,6 +12,7 @@ import { buildApp } from '../../src/bootstrap';
import { JourneyShareTokens } from '../../src/db/entities/JourneyShareTokens.entity';
import { Notifications } from '../../src/db/entities/Notifications.entity';
import { NotificationsService } from '../../src/nest/notifications/notifications.service';
import { forEachInOrder } from '../../src/utils/for-each-in-order';
import { makeJourney } from '../helpers/factories/journeys';
import { countRows, findRow } from '../helpers/factories/rows';
import { setAddonEnabled } from '../helpers/factories/settings';
@@ -77,11 +78,11 @@ describe('a journey link with a password', () => {
expect(JSON.stringify(read.body)).not.toContain('$2');
const locked = { error: 'Password required', code: 'JOURNEY_PASSWORD_REQUIRED' };
for (const path of ['', '/map-layers', '/photos/1/thumbnail', '/photo/local/a.jpg/1/original']) {
await forEachInOrder(['', '/map-layers', '/photos/1/thumbnail', '/photo/local/a.jpg/1/original'], async (path) => {
const res = await request(server).get(`/api/public/journey/${token}${path}`);
expect(res.status, path).toBe(401);
expect(res.body, path).toEqual(locked);
}
});
const wrong = await request(server).post(`/api/public/journey/${token}/unlock`).send({ password: 'nope' });
expect(wrong.status).toBe(401);
@@ -122,12 +123,15 @@ describe('a journey link with a password', () => {
it('JPUBLINK-E2E-003: wrong passwords count per address and link, a right one does not', async () => {
const { token } = await sharedJourney({ password: 'secret1' });
for (let i = 0; i < 10; i++) {
const res = await request(server)
.post(`/api/public/journey/${token}/unlock`)
.send({ password: `nope${i}` });
expect(res.status).toBe(401);
}
await forEachInOrder(
Array.from({ length: 10 }, (_, i) => i),
async (i) => {
const res = await request(server)
.post(`/api/public/journey/${token}/unlock`)
.send({ password: `nope${i}` });
expect(res.status).toBe(401);
},
);
const limited = await request(server).post(`/api/public/journey/${token}/unlock`).send({ password: 'secret1' });
expect(limited.status).toBe(429);
@@ -164,11 +168,11 @@ describe('a journey link with an expiry', () => {
.send({ expires_at: '2020-01-01T00:00:00Z' });
const gone = { error: 'This link has expired', code: 'JOURNEY_LINK_EXPIRED' };
for (const path of ['', '/map-layers', '/photos/1/thumbnail']) {
await forEachInOrder(['', '/map-layers', '/photos/1/thumbnail'], async (path) => {
const res = await request(server).get(`/api/public/journey/${token}${path}`);
expect(res.status, path).toBe(410);
expect(res.body, path).toEqual(gone);
}
});
const unlock = await request(server).post(`/api/public/journey/${token}/unlock`).send({ password: 'x' });
expect(unlock.status).toBe(410);
});
+16 -7
View File
@@ -14,6 +14,7 @@ import { Notifications } from '../../src/db/entities/Notifications.entity';
import { JourneyDigestService } from '../../src/nest/journey/journey-digest.service';
import { MailerService } from '../../src/nest/notifications/mailer/mailer.service';
import { NotificationsService } from '../../src/nest/notifications/notifications.service';
import { forEachInOrder } from '../../src/utils/for-each-in-order';
import { addJourneyContributor, makeJourney, makeJourneyEntry } from '../helpers/factories/journeys';
import { countRows, deleteRows, findRow, findRows } from '../helpers/factories/rows';
import { setAddonEnabled } from '../helpers/factories/settings';
@@ -270,7 +271,12 @@ describe('comments through the share link', () => {
expect((await post(entry.id, { name: 'Bot', body: 'Hi', website: 'http://spam.example' })).status).toBe(200);
expect(await countRows(orm, JourneyEntryComments, { journey: journey.id })).toBe(0);
for (let i = 0; i < 8; i++) expect((await post(entry.id, { name: 'Ana', body: `Hi ${i}` })).status).toBe(200);
await forEachInOrder(
Array.from({ length: 8 }, (_, i) => i),
async (i) => {
expect((await post(entry.id, { name: 'Ana', body: `Hi ${i}` })).status).toBe(200);
},
);
expect((await post(entry.id, { name: 'Ana', body: 'One more' })).status).toBe(429);
});
@@ -385,12 +391,15 @@ describe('following a link by email', () => {
mailWorks();
const { owner, journey } = await journeyWithPeople();
const token = await share(journey.id, owner.id, { allow_subscriptions: true });
for (let i = 0; i < 5; i++) {
const res = await request(server)
.post(`/api/public/journey/${token}/subscribe`)
.send({ email: `r${i}@example.com` });
expect(res.status).toBe(200);
}
await forEachInOrder(
Array.from({ length: 5 }, (_, i) => i),
async (i) => {
const res = await request(server)
.post(`/api/public/journey/${token}/subscribe`)
.send({ email: `r${i}@example.com` });
expect(res.status).toBe(200);
},
);
const sixth = await request(server)
.post(`/api/public/journey/${token}/subscribe`)
.send({ email: 'r6@example.com' });
+4 -2
View File
@@ -20,6 +20,7 @@ import { JourneyModule } from '../../src/nest/journey/journey.module';
import { ImmichService } from '../../src/nest/memories/immich.service';
import { PhotoCaptureBackfillService } from '../../src/nest/memories/photo-capture-backfill.service';
import { StorageService } from '../../src/nest/storage/storage.service';
import { forEachInOrder } from '../../src/utils/for-each-in-order';
import { createTestMikroOrmModule } from '../helpers/test-orm';
import { TestUnitOfWorkModule } from '../helpers/test-uow';
import { seedUser, sessionCookie } from './harness';
@@ -111,6 +112,7 @@ const { jsvc } = vi.hoisted(() => ({
listEntries: vi.fn(),
linkPhotoToEntry: vi.fn(),
unlinkPhotoFromEntry: vi.fn(),
canAccessJourney: vi.fn().mockResolvedValue(journeyRow(9)),
addContributor: vi.fn(),
updateContributorRole: vi.fn(),
},
@@ -902,7 +904,7 @@ describe('Journey e2e (real auth guard + temp SQLite)', () => {
});
it('JOURNEY-E2E-040: 400 for the owner role or an unknown one on add and on update; the service is never asked', async () => {
for (const role of ['owner', 'admin']) {
await forEachInOrder(['owner', 'admin'], async (role) => {
const add = await request(server)
.post('/api/journeys/9/contributors')
.set('Cookie', sessionCookie(1))
@@ -913,7 +915,7 @@ describe('Journey e2e (real auth guard + temp SQLite)', () => {
.set('Cookie', sessionCookie(1))
.send({ role });
expect(update.status, role).toBe(400);
}
});
const none = await request(server)
.patch('/api/journeys/9/contributors/2')
.set('Cookie', sessionCookie(1))
@@ -8,6 +8,7 @@ import { JourneyEntries } from '../../../../src/db/entities/JourneyEntries.entit
import { JourneyEntryComments } from '../../../../src/db/entities/JourneyEntryComments.entity';
import { Users } from '../../../../src/db/entities/Users.entity';
import type { JourneyEntryCommentsRepository } from '../../../../src/db/repositories/JourneyEntryComments.repository';
import { forEachInOrder } from '../../../../src/utils/for-each-in-order';
import { createSnapshotTestDb } from '../../../helpers/db-mock';
import { makeJourneyComment } from '../../../helpers/factories/journey-social';
import { makeJourney, makeJourneyEntry } from '../../../helpers/factories/journeys';
@@ -89,9 +90,9 @@ describe('JourneyEntryCommentsRepository', () => {
const dismissed = await makeJourneyEntry(t, journey.id, user.id, { dismissed: 1 });
const shown = await makeJourneyComment(t, { id: entry.id, journey_id: journey.id }, null);
await makeJourneyComment(t, { id: entry.id, journey_id: journey.id }, user.id, { hidden: 1 });
for (const e of [draft, skeleton, dismissed]) {
await forEachInOrder([draft, skeleton, dismissed], async (e) => {
await makeJourneyComment(t, { id: e.id, journey_id: journey.id }, user.id);
}
});
expect((await comments.listPublicForJourney(journey.id)).map((r) => r.id)).toEqual([shown.id]);
});
+6 -4
View File
@@ -10,6 +10,7 @@ import { JourneyEntryPhotos } from '../../../src/db/entities/JourneyEntryPhotos.
import { JourneyPhotos } from '../../../src/db/entities/JourneyPhotos.entity';
import { Journeys } from '../../../src/db/entities/Journeys.entity';
import { TrekPhotos } from '../../../src/db/entities/TrekPhotos.entity';
import { forEachInOrder } from '../../../src/utils/for-each-in-order';
import { addJourneyContributor } from '../../helpers/factories/journeys';
import { countRows, createRow, findRow, insertRow } from '../../helpers/factories/rows';
import { setAddonEnabled } from '../../helpers/factories/settings';
@@ -1257,7 +1258,8 @@ describe('journey entry fields', () => {
await withHarness(user.id, async (h) => {
const journey = await seedJourney(h);
const entry = await seedEntry(h, journey.id);
for (const bad of [{ visibility: 'friends' }, { location_lng: 181 }, { type: 'note' }]) {
const invalid = [{ visibility: 'friends' }, { location_lng: 181 }, { type: 'note' }];
await forEachInOrder(invalid, async (bad) => {
expect(
(
await h.client.callTool({
@@ -1266,7 +1268,7 @@ describe('journey entry fields', () => {
})
).isError,
).toBe(true);
}
});
// And none of the refusals touched the row.
const row = await entryRow(entry.id);
expect(row.visibility).toBe('private');
@@ -1612,7 +1614,7 @@ describe('Resource: trek://journeys/{journeyId}/entries', () => {
});
const data = parseResourceResult(
await h.client.readResource({ uri: `trek://journeys/${journey.id}/entries` }),
) as any[];
) as { title: string; tags: string[] }[];
expect(data).toHaveLength(1);
expect(data[0].title).toBe('Day 1');
expect(Array.isArray(data[0].tags)).toBe(true);
@@ -1627,7 +1629,7 @@ describe('Resource: trek://journeys/{journeyId}/contributors', () => {
const journey = await createJourney(h);
const data = parseResourceResult(
await h.client.readResource({ uri: `trek://journeys/${journey.id}/contributors` }),
) as any[];
) as { user_id?: number; id: number }[];
expect(Array.isArray(data)).toBe(true);
expect(data.map((c) => c.user_id ?? c.id)).toContain(user.id);
});
@@ -1220,6 +1220,12 @@ describe('parity — JourneyShareTokensRepository reads match the legacy stateme
newest_first,
share_plan: false,
share_recordings: false,
has_password: false,
expires_at: null,
view_count: 0,
last_viewed_at: null,
allow_comments: false,
allow_subscriptions: false,
});
}
}
@@ -1403,13 +1409,14 @@ describe('a protected share link', () => {
body: { error: 'Wrong password', code: 'JOURNEY_PASSWORD_INVALID' },
});
const unlocked = await svc.unlockPublicLink(token, 'open sesame');
if (!unlocked) throw new Error('Expected a proof for the protected link');
expect(unlocked).toEqual({ proof: unlockProof(token, 1), expiresAt: null });
expect((await svc.assertPublicAccess(token, unlocked!.proof)).journey_id).toBe(journey.id);
expect((await svc.assertPublicAccess(token, unlocked.proof)).journey_id).toBe(journey.id);
// A proof is only good for its own link.
const other = await svc.createOrUpdateJourneyShareLink(createJourney(testDb, user.id).id, user.id, {
password: 'open sesame',
});
expect(await refusal(() => svc.assertPublicAccess(other.token, unlocked!.proof))).toMatchObject({ status: 401 });
expect(await refusal(() => svc.assertPublicAccess(other.token, unlocked.proof))).toMatchObject({ status: 401 });
});
it('JOURNEY-SHARE-PW-004: changing or removing the password signs every unlocked reader out again', async () => {
@@ -14,6 +14,7 @@ import type { JourneyService } from '../../../src/nest/journey/journey.service';
import { RenditionPendingError, type PublicMediaService } from '../../../src/nest/memories/public-media.service';
import type { StorageService } from '../../../src/nest/storage/storage.service';
import type { User } from '../../../src/types';
import { forEachInOrder } from '../../../src/utils/for-each-in-order';
import { HttpException } from '@nestjs/common';
import type { Request, Response } from 'express';
@@ -759,11 +760,11 @@ describe('JourneyController', () => {
});
it('DELETE gallery photo: the journey of the path goes along, a refusal or nothing deleted is a 404', async () => {
for (const answer of [null, []]) {
await forEachInOrder([null, []], async (answer) => {
const refusing = ctl(svc(), {}, {}, { deleteFromGallery: vi.fn().mockResolvedValue(answer) });
const refusal = await thrownAsync(() => refusing.deleteGalleryPhoto(user, 3, 7));
expect(refusal).toEqual({ status: 404, body: { error: 'Photo not found or not allowed' } });
}
});
(storageStub.delete as ReturnType<typeof vi.fn>).mockClear();
const deleteFromGallery = vi.fn().mockResolvedValue([10]);
expect(await ctl(svc(), {}, {}, { deleteFromGallery }).deleteGalleryPhoto(user, 3, 10, 'sock-1')).toBeUndefined();
@@ -25,6 +25,7 @@ import {
JourneyEntriesFromPhotosService,
} from '../../../../src/nest/journey/journey-entries-from-photos.service';
import { MapsService } from '../../../../src/nest/maps/maps.service';
import { forEachInOrder } from '../../../../src/utils/for-each-in-order';
import { createSnapshotTestDb } from '../../../helpers/db-mock';
import { addJourneyContributor, makeJourney, makeJourneyEntry } from '../../../helpers/factories/journeys';
import { countRows, findRow, findRows, insertRow } from '../../../helpers/factories/rows';
@@ -212,10 +213,11 @@ describe('JourneyEntriesFromPhotosService.preview', () => {
it('JRNPHOTOS-SVC-003: asks the geocoder about a bounded number of points and names the rest by country', async () => {
const { owner, journey } = await fixture();
// One group per day, each a few kilometres further east.
for (let day = 0; day < FROM_PHOTOS_MAX_GEOCODED + 2; day++) {
const offsets = Array.from({ length: FROM_PHOTOS_MAX_GEOCODED + 2 }, (_, offset) => offset);
await forEachInOrder(offsets, async (day) => {
const date = new Date(Date.UTC(2026, 4, 1 + day, 7)).toISOString();
await galleryPhoto(journey.id, owner.id, date, { lat: 45.0, lng: 9 + day * 0.05 });
}
});
const preview = await svc.preview(owner.id, journey.id, {});
expect(reverseGeocode).toHaveBeenCalledTimes(FROM_PHOTOS_MAX_GEOCODED);
expect(preview.clusters.filter((c) => c.titleSource === 'place')).toHaveLength(FROM_PHOTOS_MAX_GEOCODED);
@@ -157,14 +157,20 @@ describe('getPreferencesMatrix', () => {
// +1 for plugin_notification: users can mute host-mediated plugin notifications.
// +1 for wanderer_source_hint: the hints of the user's own wanderer watch (WAN-02).
// +3 for flight_departed, flight_delayed and flight_landed (live flight status, on by default).
expect(event_types.length).toBe(16);
expect(event_types).toEqual(
expect.arrayContaining(['journey_invite', 'journey_comment', 'journey_entry_published']),
);
expect(event_types).toHaveLength(19);
});
it('NPREF-005 — user scope excludes version_available for everyone including admins', async () => {
const { user } = createAdmin(testDb);
const { event_types } = await getPreferencesMatrix(user.id, 'admin', 'user');
expect(event_types).not.toContain('version_available');
expect(event_types.length).toBe(16);
expect(event_types).toEqual(
expect.arrayContaining(['journey_invite', 'journey_comment', 'journey_entry_published']),
);
expect(event_types).toHaveLength(19);
});
it('NPREF-005b — admin scope returns the admin-scoped events', async () => {