Skip to content

Commit f768b83

Browse files
committed
wip(tests): dogfood grant fixtures by name; junction rows keep their id; no new query-option casts
Claude-Session: https://claude.ai/code/session_01MZuVPXoYeF1Pa3G4ERmTPz Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5351a1a commit f768b83

13 files changed

Lines changed: 24 additions & 30 deletions

‎packages/plugins/plugin-security/src/grant-permission-set-name.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('the data door (a non-system writer)', () => {
170170
const [row] = await grantsOf(h, 'u_1');
171171
expect(row).toMatchObject({ permission_set: 'qa_alpha' });
172172
expect(row.permission_set_id ?? null).toBeNull();
173-
expect(await h.engine.find('sys_permission_set', { context: SYS } as any)).toEqual([]);
173+
expect(await h.engine.find('sys_permission_set', { context: SYS })).toEqual([]);
174174
});
175175

176176
it('NEGATIVE — a name the catalog does not hold is refused 400 VALIDATION_FAILED, reference_not_found at permission_set; nothing is stored', async () => {

‎packages/plugins/plugin-security/src/grant-permission-set-name.writers.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ describe('[ADR-0131 D4] the grant writers in plugin-security write the set by na
9494
expectNamedOnly(grants[0], 'admin_full_access');
9595

9696
// The holder is read by name: with every catalog row gone it still answers.
97-
await engine.delete('sys_permission_set', { where: {}, multi: true, context: SYS } as any);
98-
expect(await engine.find('sys_permission_set', { context: SYS } as any)).toEqual([]);
97+
await engine.delete('sys_permission_set', { where: {}, multi: true, context: SYS });
98+
expect(await engine.find('sys_permission_set', { context: SYS })).toEqual([]);
9999
expect(await findExistingPlatformAdmin(engine, defaultPermissionSets)).toBe('usr_first');
100100
});
101101

@@ -118,7 +118,7 @@ describe('[ADR-0131 D4] the grant writers in plugin-security write the set by na
118118
const grants = await grantsOf(engine, 'u_owner');
119119
expect(grants).toHaveLength(1);
120120
expectNamedOnly(grants[0], setName);
121-
expect(await engine.find('sys_permission_set', { context: SYS } as any)).toEqual([]);
121+
expect(await engine.find('sys_permission_set', { context: SYS })).toEqual([]);
122122
});
123123
}
124124
});

‎packages/qa/dogfood/test/activity-field-values.dogfood.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('[#21081] activity rows serve a parent field value only to a reader ser
179179
for (const name of sets) {
180180
const setId = await idOf('sys_permission_set', { name });
181181
expect(setId, `fixture permission set ${name} seeded`).toBeTruthy();
182-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
182+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: name }, SYS);
183183
}
184184
}
185185

‎packages/qa/dogfood/test/activity-label-display-field.dogfood.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('[#21878] an activity row names its record by the ADR-0079 title, with
144144
for (const name of PRINCIPALS[who]) {
145145
const setId = await idOf('sys_permission_set', { name });
146146
expect(setId, `fixture permission set ${name} seeded`).toBeTruthy();
147-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
147+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: name }, SYS);
148148
}
149149
}
150150

‎packages/qa/dogfood/test/activity-text-predicate.dogfood.test.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ describe('[#21154] a query over activity text or the approval snapshot, by a rea
258258
const adminId = await idOf('sys_user', { email: 'admin@objectos.ai' });
259259
expect(adminId, 'the harness admin is seeded').toBeTruthy();
260260
for (const name of READERS.control) {
261-
const setId = await idOf('sys_permission_set', { name });
262-
await ql.insert('sys_user_permission_set', { user_id: adminId, permission_set_id: setId }, SYS);
261+
await ql.insert('sys_user_permission_set', { user_id: adminId, permission_set: name }, SYS);
263262
}
264263

265264
for (const who of [...Object.keys(READERS), 'writer']) {
@@ -270,7 +269,7 @@ describe('[#21154] a query over activity text or the approval snapshot, by a rea
270269
for (const name of sets) {
271270
const setId = await idOf('sys_permission_set', { name });
272271
expect(setId, `fixture permission set ${name} seeded`).toBeTruthy();
273-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
272+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: name }, SYS);
274273
}
275274
if (who === 'control') {
276275
// Staff the position BEFORE the subject exists: the slate resolves at request creation.

‎packages/qa/dogfood/test/admin-ledger-decision-metadata.dogfood.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('the admin identity rows on the compliance ledger carry decisions, neve
266266
for (const name of READERS[who]) {
267267
const setId = await idOf('sys_permission_set', { name });
268268
expect(setId, `fixture permission set ${name} seeded`).toBeTruthy();
269-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
269+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: name }, SYS);
270270
}
271271
}
272272

‎packages/qa/dogfood/test/audit-log-field-values.dogfood.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('[#21155] the compliance ledger serves a parent field value only to a r
190190
for (const name of sets) {
191191
const setId = await idOf('sys_permission_set', { name });
192192
expect(setId, `fixture permission set ${name} seeded`).toBeTruthy();
193-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
193+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: name }, SYS);
194194
}
195195
}
196196

‎packages/qa/dogfood/test/me-apps-and-everyone-baseline.dogfood.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('ADR-0090 D5 closures: /me/apps + anchor-bindable baseline', () => {
121121
expect(hideSet.status, 'set authored through the data door').toBeLessThan(300);
122122
const hideSetId = (await ql.findOne('sys_permission_set', { where: { name: 'tab_probe_hide' }, context: SYS }))?.id;
123123
expect(hideSetId, 'hide set stored').toBeTruthy();
124-
await ql.insert('sys_user_permission_set', { user_id: tabUser.id, permission_set_id: hideSetId }, { context: SYS });
124+
await ql.insert('sys_user_permission_set', { user_id: tabUser.id, permission_set: 'tab_probe_hide' }, { context: SYS });
125125

126126
const hidden = await stack.apiAs(tabTok, 'GET', '/me/apps');
127127
const hiddenNames = (((await hidden.json()) as any)?.apps ?? []).map((a: any) => a?.name);
@@ -135,8 +135,7 @@ describe('ADR-0090 D5 closures: /me/apps + anchor-bindable baseline', () => {
135135
tab_permissions: JSON.stringify({ showcase_app: 'visible' }),
136136
});
137137
expect(showSet.status, 'set authored through the data door').toBeLessThan(300);
138-
const showSetId = (await ql.findOne('sys_permission_set', { where: { name: 'tab_probe_show' }, context: SYS }))?.id;
139-
await ql.insert('sys_user_permission_set', { user_id: tabUser.id, permission_set_id: showSetId }, { context: SYS });
138+
await ql.insert('sys_user_permission_set', { user_id: tabUser.id, permission_set: 'tab_probe_show' }, { context: SYS });
140139

141140
const merged = await stack.apiAs(tabTok, 'GET', '/me/apps');
142141
const mergedNames = (((await merged.json()) as any)?.apps ?? []).map((a: any) => a?.name);
@@ -187,7 +186,7 @@ describe('ADR-0090 D5 closures: /me/apps + anchor-bindable baseline', () => {
187186
expect(inquirySetId, 'probe set stored').toBeTruthy();
188187
await ql.insert(
189188
'sys_user_permission_set',
190-
{ user_id: memberUser.id, permission_set_id: inquirySetId },
189+
{ user_id: memberUser.id, permission_set: 'baseline_inquiry_probe' },
191190
{ context: SYS },
192191
);
193192

‎packages/qa/dogfood/test/permission-set-assignment-window.dogfood.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('a permission-set assignment grants only inside its validity window (AD
6060
let stack: VerifyStack;
6161
let ql: any;
6262
let adminTok: string;
63-
let setId: string;
6463
const tok: Record<string, string> = {};
6564
const uid: Record<string, string> = {};
6665

@@ -72,7 +71,7 @@ describe('a permission-set assignment grants only inside its validity window (AD
7271
expect(uid[who], `${who} signed up`).toBeTruthy();
7372
};
7473
const grant = async (who: string, window: { valid_from?: string; valid_until?: string } = {}) => {
75-
await ql.insert(GRANTS, { user_id: uid[who], permission_set_id: setId, ...window }, { context: SYS });
74+
await ql.insert(GRANTS, { user_id: uid[who], permission_set: SET, ...window }, { context: SYS });
7675
};
7776
const door = async (who: string) => (await stack.apiAs(tok[who], 'GET', `${DOOR}?$top=1`)).status;
7877

@@ -83,7 +82,6 @@ describe('a permission-set assignment grants only inside its validity window (AD
8382

8483
const set = await ql.findOne('sys_permission_set', { where: { name: SET }, context: SYS });
8584
expect(set?.id, `the showcase seeded ${SET}`).toBeTruthy();
86-
setId = String(set.id);
8785

8886
for (const who of ['bare', 'open', 'before', 'inside', 'after', 'edited', 'falls', 'rises']) await sign(who);
8987
const now = Date.now();
@@ -172,7 +170,7 @@ describe('a permission-set assignment grants only inside its validity window (AD
172170

173171
const at = Date.now() + DAY;
174172
const res = await stack.apiAs(adminTok, 'POST', `/data/${GRANTS}`, {
175-
user_id: uid.bare, permission_set_id: setId, valid_from: iso(at), valid_until: iso(at - HOUR),
173+
user_id: uid.bare, permission_set: SET, valid_from: iso(at), valid_until: iso(at - HOUR),
176174
});
177175
const body = (await res.json()) as any;
178176
expect([res.status, body?.code]).toEqual([400, 'VALIDATION_FAILED']);

‎packages/qa/dogfood/test/search-companion-field-scope.dogfood.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('dogfood: with the pinyin search companion on, a member searches only w
174174
const setId = await idOf('sys_permission_set', { name: memberSet.name });
175175
expect(userId, 'member user seeded').toBeTruthy();
176176
expect(setId, 'member permission set seeded').toBeTruthy();
177-
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set_id: setId }, SYS);
177+
await ql.insert('sys_user_permission_set', { user_id: userId, permission_set: memberSet.name }, SYS);
178178

179179
memberRowId = await create(memberToken, ROWS, { name: CJK_NAME });
180180
adminRowId = await create(adminToken, ROWS, { name: CJK_NAME });

0 commit comments

Comments
 (0)