Skip to content

Commit 796a557

Browse files
committed
test(plugin-approvals, plugin-security, service-messaging): ask a pinyin-enabled registry about the search companion
The engine the tests boot builds its registry with the companion switched off (it follows OS_SEARCH_PINYIN_ENABLED), so "no __search column" could never fail there. The pin now registers each object in a registry built with `searchCompanion: true` and asserts no companion field is provisioned. Claude-Session: https://claude.ai/code/session_01Evb5jFDZGKQE9KG4jbMfMF Co-authored-by: Claude <noreply@anthropic.com>
1 parent d040485 commit 796a557

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

‎packages/plugins/plugin-approvals/src/sys-approval-delegation-display-title.test.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
* here every title column is required);
2525
* 4. the formula reads exactly the columns `titleFormat` names, on this row
2626
* only, each required and none withheld from a reader of the row;
27-
* 5. the formula adds no stored column.
27+
* 5. the formula adds no stored column, and no search companion column
28+
* either — not even where pinyin search provisions one (a formula is
29+
* never a companion source).
2830
*/
2931

3032
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
31-
import { ObjectQL, resolveRecordTitle } from '@objectstack/objectql';
33+
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
3234
import { SqlDriver } from '@objectstack/driver-sql';
3335
import { resolveDisplayField } from '@objectstack/spec/data';
3436
import { SysApprovalDelegation } from './sys-approval-delegation.object.js';
@@ -139,10 +141,20 @@ describe('[#20044] sys_approval_delegation resolves a real record title under AD
139141
}
140142
});
141143

142-
it('adds no stored column: the formula is computed on read, and no search companion appears', async () => {
144+
it('adds no stored column: the formula is computed on read', async () => {
143145
const columns = Object.keys(await driver.getKnex()(OBJECT).columnInfo());
144146
expect(columns).toContain('delegator_id');
145147
expect(columns).not.toContain('display_title');
146-
expect(columns).not.toContain('__search');
148+
});
149+
150+
it('provisions no search companion column, even where pinyin search is on', () => {
151+
// The companion (`__search`) is a real column fed by the title field; a
152+
// registry only provisions it when pinyin search is enabled, so ask one
153+
// that is. A formula title is never a companion source.
154+
const companionRegistry = new SchemaRegistry({ searchCompanion: true });
155+
companionRegistry.registerObject(SysApprovalDelegation as any, 'com.objectstack.test.20044');
156+
const registered = companionRegistry.getObject(OBJECT) as any;
157+
expect(registered.nameField).toBe('display_title');
158+
expect(registered.fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
147159
});
148160
});

‎packages/plugins/plugin-security/src/objects/sys-security-assignment-display-title.test.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
* server-side accessor (`resolveRecordTitle`) agrees;
2424
* 3. a row missing a title column is refused by the write path, so the
2525
* formula never sees a NULL part;
26-
* 4. the formula adds no stored column.
26+
* 4. the formula adds no stored column, and no search companion column
27+
* either — not even where pinyin search provisions one (a formula is
28+
* never a companion source).
2729
*
2830
* And, because these are permission-assignment tables, the property the new
2931
* field must not break: the formula reads exactly the columns `titleFormat`
@@ -35,7 +37,7 @@
3537
*/
3638

3739
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
38-
import { ObjectQL, resolveRecordTitle } from '@objectstack/objectql';
40+
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
3941
import { SqlDriver } from '@objectstack/driver-sql';
4042
import { resolveDisplayField } from '@objectstack/spec/data';
4143
import { SysPositionPermissionSet } from './sys-position-permission-set.object.js';
@@ -178,11 +180,21 @@ describe('[#20044] permission-assignment tables resolve a real record title unde
178180
}
179181
});
180182

181-
it(`${object}: adds no stored column — the formula is computed on read, and no search companion appears`, async () => {
183+
it(`${object}: adds no stored column — the formula is computed on read`, async () => {
182184
const columns = Object.keys(await driver.getKnex()(object).columnInfo());
183185
expect(columns).toContain(Object.keys(data)[0]);
184186
expect(columns).not.toContain('display_title');
185-
expect(columns).not.toContain('__search');
187+
});
188+
189+
it(`${object}: provisions no search companion column, even where pinyin search is on`, () => {
190+
// The companion (`__search`) is a real column fed by the title field; a
191+
// registry only provisions it when pinyin search is enabled, so ask one
192+
// that is. A formula title is never a companion source.
193+
const companionRegistry = new SchemaRegistry({ searchCompanion: true });
194+
companionRegistry.registerObject(schema, 'com.objectstack.test.20044');
195+
const registered = companionRegistry.getObject(object) as any;
196+
expect(registered.nameField).toBe('display_title');
197+
expect(registered.fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
186198
});
187199
}
188200
});

‎packages/services/service-messaging/src/objects/notification-display-title.test.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
* write path refuses it, or fills the column's declared default;
3232
* 4. the formula reads exactly the columns `titleFormat` names, on this row
3333
* only, each required and none withheld from a reader of the row;
34-
* 5. nothing adds a stored column — no formula column, no search companion.
34+
* 5. nothing adds a stored column: no formula column, and no search
35+
* companion column even where pinyin search provisions one (a formula is
36+
* never a companion source, and a `select` is not title text).
3537
*/
3638

3739
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
38-
import { ObjectQL, resolveRecordTitle } from '@objectstack/objectql';
40+
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
3941
import { SqlDriver } from '@objectstack/driver-sql';
4042
import { resolveDisplayField } from '@objectstack/spec/data';
4143
import { NotificationDelivery } from './notification-delivery.object.js';
@@ -224,11 +226,21 @@ describe('[#20044] notification objects resolve a real record title under ADR-00
224226
}
225227
});
226228

227-
it(`${object}: adds no stored column — no formula column and no search companion`, async () => {
229+
it(`${object}: adds no stored column for the title`, async () => {
228230
const columns = Object.keys(await driver.getKnex()(object).columnInfo());
229231
expect(columns).toContain(titleFormatColumns(c.schema)[0]);
230232
expect(columns).not.toContain('display_title');
231-
expect(columns).not.toContain('__search');
233+
});
234+
235+
it(`${object}: provisions no search companion column, even where pinyin search is on`, () => {
236+
// The companion (`__search`) is a real column fed by the title field; a
237+
// registry only provisions it when pinyin search is enabled, so ask one
238+
// that is.
239+
const companionRegistry = new SchemaRegistry({ searchCompanion: true });
240+
companionRegistry.registerObject(c.schema, 'com.objectstack.test.20044');
241+
const registered = companionRegistry.getObject(object) as any;
242+
expect(registered.nameField).toBe(c.pointer);
243+
expect(registered.fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
232244
});
233245
}
234246
});

0 commit comments

Comments
 (0)