mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
test: Restore dropped github.spec tenant-context tests
The previous commit's github.spec.ts edit did not apply (anchor mismatch), so the getTenantId import remained unused and failed eslint --max-warnings=0. Add the two tenant tests that use it: a tenant-scoped run stamps tenantId and executes inside the tenant ALS context, and a no-tenant run stays ambient.
This commit is contained in:
parent
4485914374
commit
2ccc3bbf8e
1 changed files with 54 additions and 0 deletions
|
|
@ -251,6 +251,60 @@ describe('createGitHubSkillSyncRunner', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('runs a tenant-scoped source inside its tenant context and stamps the skill tenantId', async () => {
|
||||
let observedTenantId: string | undefined = 'unset';
|
||||
const deps = createDeps({
|
||||
getConfig: () => ({
|
||||
github: {
|
||||
enabled: true,
|
||||
intervalMinutes: 60,
|
||||
runOnStartup: false,
|
||||
sources: [
|
||||
{
|
||||
id: 'librechat-skills',
|
||||
owner: 'LibreChat',
|
||||
repo: 'skills',
|
||||
ref: 'main',
|
||||
paths: ['skills'],
|
||||
credentialKey: 'github-skills-prod',
|
||||
tenantId: 'tenant-a',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
createSkill: jest.fn(async (input: CreateSkillInput): Promise<CreateSkillResult> => {
|
||||
observedTenantId = getTenantId();
|
||||
return { skill: makeSkill(input), warnings: [] };
|
||||
}),
|
||||
});
|
||||
const runner = createGitHubSkillSyncRunner(deps);
|
||||
const result = await runner.runOnce();
|
||||
|
||||
expect(result.status).toBe('completed');
|
||||
expect(observedTenantId).toBe('tenant-a');
|
||||
expect(deps.createSkill).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ name: 'research', tenantId: 'tenant-a' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('runs in the ambient context when a source has no configured tenantId', async () => {
|
||||
let observedTenantId: string | undefined = 'unset';
|
||||
const deps = createDeps({
|
||||
createSkill: jest.fn(async (input: CreateSkillInput): Promise<CreateSkillResult> => {
|
||||
observedTenantId = getTenantId();
|
||||
return { skill: makeSkill(input), warnings: [] };
|
||||
}),
|
||||
});
|
||||
const runner = createGitHubSkillSyncRunner(deps);
|
||||
const result = await runner.runOnce();
|
||||
|
||||
expect(result.status).toBe('completed');
|
||||
expect(observedTenantId).toBeUndefined();
|
||||
expect(deps.createSkill).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ name: 'research', tenantId: undefined }),
|
||||
);
|
||||
});
|
||||
|
||||
it('uses distinct synthetic authors so same-named skills can sync from different sources', async () => {
|
||||
const seenNamesByAuthor = new Set<string>();
|
||||
const deps = createDeps({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue