Skip to content

Commit 1960b45

Browse files
committed
test(service-messaging): drive the channel-path pin with a stored-row store instead of a new engine double
Claude-Session: https://claude.ai/code/session_011TdZ8GjixNZFLz1xJD9zzK Co-authored-by: Claude <noreply@anthropic.com>
1 parent 73f7bf8 commit 1960b45

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

‎packages/services/service-messaging/src/text-field-html-outlets.pin.test.ts‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ import { fileURLToPath } from 'node:url';
4646

4747
import ts from 'typescript';
4848
import { describe, it, expect } from 'vitest';
49-
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
50-
import type { IDataEngine } from '@objectstack/spec/contracts';
5149

52-
import { renderNotification, NotificationTemplateStore } from './template-renderer.js';
50+
import { renderNotification, NotificationTemplateStore, type NotificationTemplateRow } from './template-renderer.js';
5351
import { createEmailChannel } from './email-channel.js';
5452
import type { Delivery } from './channel.js';
5553

@@ -203,27 +201,23 @@ function pinTemplateRenderer(): void {
203201
});
204202

205203
it('through the email channel: a stored html row sends the text field escaped in the html, as typed in the subject', async () => {
206-
const row = {
207-
organization_id: 'org_1', topic: 'collab.mention', channel: 'email', locale: 'en', is_active: true,
204+
const row: NotificationTemplateRow = {
208205
subject: '{{ actorName }} mentioned you', body: '<p><b>{{ actorName }}</b></p>', format: 'html',
209206
};
210-
const engine = {
211-
async findOne(object: string, query: any) {
212-
assertEngineFindOnePredicate(object, query);
213-
const w = query?.where ?? {};
214-
return object === 'sys_notification_template'
215-
&& w.organization_id === row.organization_id && w.topic === row.topic
216-
&& w.channel === row.channel && w.locale === row.locale
217-
? row
218-
: null;
219-
},
220-
} as unknown as IDataEngine;
207+
// The stored row, handed straight to the channel: the store's own
208+
// organization-keyed read is pinned in template-renderer.test.ts, and
209+
// this pin is about what the channel sends once the row is in hand.
210+
class StoredRow extends NotificationTemplateStore {
211+
override async load(): Promise<NotificationTemplateRow | null> {
212+
return row;
213+
}
214+
}
221215
const sent: any[] = [];
222216
const email = { async send(input: any) { sent.push(input); return { id: 'email_1' }; } };
223217
const channel = createEmailChannel({
224218
getEmail: () => email,
225-
getData: () => engine,
226-
store: new NotificationTemplateStore({ getData: () => engine }),
219+
getData: () => undefined,
220+
store: new StoredRow({ getData: () => undefined }),
227221
});
228222
const delivery: Delivery = {
229223
channel: 'email',

0 commit comments

Comments
 (0)