Skip to content

Commit 17db356

Browse files
committed
test(plugin-approvals, plugin-security, service-messaging): run the companion step over the registered body instead of a second registry
Constructing a SchemaRegistry in a test makes check:registry-log-declared require an OS_REGISTRY_LOG declaration in each package's vitest config, outside this change's surface. The registry provisions the companion by running `provisionSearchCompanion` over the body it has designated, so the pin now runs that pure step over the engine's registered body, and asks `resolveSearchCompanionSources` for the sources: none. Claude-Session: https://claude.ai/code/session_01Evb5jFDZGKQE9KG4jbMfMF Co-authored-by: Claude <noreply@anthropic.com>
1 parent 796a557 commit 17db356

3 files changed

Lines changed: 43 additions & 27 deletions

File tree

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
*/
3131

3232
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
33-
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
33+
import {
34+
ObjectQL,
35+
SEARCH_COMPANION_FIELD,
36+
provisionSearchCompanion,
37+
resolveRecordTitle,
38+
resolveSearchCompanionSources,
39+
} from '@objectstack/objectql';
3440
import { SqlDriver } from '@objectstack/driver-sql';
3541
import { resolveDisplayField } from '@objectstack/spec/data';
3642
import { SysApprovalDelegation } from './sys-approval-delegation.object.js';
@@ -148,13 +154,12 @@ describe('[#20044] sys_approval_delegation resolves a real record title under AD
148154
});
149155

150156
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();
157+
// The companion (`__search`) is a real column fed by the title field. A
158+
// registry provisions it only where pinyin search is on, by running
159+
// `provisionSearchCompanion` over the body it has just designated, so run
160+
// that step over the registered body. A formula title is never a source.
161+
const registered = engine.registry.getObject(OBJECT) as any;
162+
expect(resolveSearchCompanionSources(registered)).toEqual([]);
163+
expect(provisionSearchCompanion(registered).fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
159164
});
160165
});

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@
3737
*/
3838

3939
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
40-
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
40+
import {
41+
ObjectQL,
42+
SEARCH_COMPANION_FIELD,
43+
provisionSearchCompanion,
44+
resolveRecordTitle,
45+
resolveSearchCompanionSources,
46+
} from '@objectstack/objectql';
4147
import { SqlDriver } from '@objectstack/driver-sql';
4248
import { resolveDisplayField } from '@objectstack/spec/data';
4349
import { SysPositionPermissionSet } from './sys-position-permission-set.object.js';
@@ -187,14 +193,14 @@ describe('[#20044] permission-assignment tables resolve a real record title unde
187193
});
188194

189195
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();
196+
// The companion (`__search`) is a real column fed by the title field. A
197+
// registry provisions it only where pinyin search is on, by running
198+
// `provisionSearchCompanion` over the body it has just designated, so
199+
// run that step over the registered body. A formula title is never a
200+
// source.
201+
const registered = engine.registry.getObject(object) as any;
202+
expect(resolveSearchCompanionSources(registered)).toEqual([]);
203+
expect(provisionSearchCompanion(registered).fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
198204
});
199205
}
200206
});

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@
3737
*/
3838

3939
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
40-
import { ObjectQL, SchemaRegistry, SEARCH_COMPANION_FIELD, resolveRecordTitle } from '@objectstack/objectql';
40+
import {
41+
ObjectQL,
42+
SEARCH_COMPANION_FIELD,
43+
provisionSearchCompanion,
44+
resolveRecordTitle,
45+
resolveSearchCompanionSources,
46+
} from '@objectstack/objectql';
4147
import { SqlDriver } from '@objectstack/driver-sql';
4248
import { resolveDisplayField } from '@objectstack/spec/data';
4349
import { NotificationDelivery } from './notification-delivery.object.js';
@@ -233,14 +239,13 @@ describe('[#20044] notification objects resolve a real record title under ADR-00
233239
});
234240

235241
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();
242+
// The companion (`__search`) is a real column fed by the title field. A
243+
// registry provisions it only where pinyin search is on, by running
244+
// `provisionSearchCompanion` over the body it has just designated, so
245+
// run that step over the registered body.
246+
const registered = engine.registry.getObject(object) as any;
247+
expect(resolveSearchCompanionSources(registered)).toEqual([]);
248+
expect(provisionSearchCompanion(registered).fields[SEARCH_COMPANION_FIELD]).toBeUndefined();
244249
});
245250
}
246251
});

0 commit comments

Comments
 (0)