e115934061
Publish `@librechat/data-schemas` to NPM / pack (push) Failing after 8s
Publish `@librechat/client` to NPM / pack (push) Failing after 0s
GitNexus Index / index (push) Failing after 1s
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been skipped
Sync Helm Chart Tags / Sync chart tags (push) Failing after 2s
Publish `librechat-data-provider` to NPM / pack (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Failing after 0s
Sync Helm Chart Tags / Ignore non-main push (push) Has been skipped
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Failing after 1s
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
Publish `librechat-data-provider` to NPM / publish-npm (push) Has been cancelled
GitNexus Index / post-index (push) Has been cancelled
Publish `@librechat/data-schemas` to NPM / publish-npm (push) Has been cancelled
56 lines
2.0 KiB
JavaScript
56 lines
2.0 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { ResourceType } = require('librechat-data-provider');
|
|
|
|
/**
|
|
* Maps each ResourceType to the cleanup function name that must appear in
|
|
* deleteUserController's source to prove it is handled during user deletion.
|
|
*
|
|
* When a new ResourceType is added, this test will fail until a corresponding
|
|
* entry is added here (or to NO_USER_CLEANUP_NEEDED) AND the actual cleanup
|
|
* logic is implemented.
|
|
*/
|
|
const HANDLED_RESOURCE_TYPES = {
|
|
[ResourceType.AGENT]: 'deleteUserAgents',
|
|
[ResourceType.REMOTE_AGENT]: 'deleteUserAgents',
|
|
[ResourceType.PROMPTGROUP]: 'deleteUserPrompts',
|
|
[ResourceType.MCPSERVER]: 'deleteUserMcpServers',
|
|
[ResourceType.SKILL]: 'deleteUserSkills',
|
|
[ResourceType.SHARED_LINK]: 'deleteAllSharedLinksWithCleanup',
|
|
};
|
|
|
|
/**
|
|
* ResourceTypes that are ACL-tracked but have no per-user deletion semantics
|
|
* (e.g., system resources, public-only). Must be explicitly listed here with
|
|
* a justification to prevent silent omissions.
|
|
*/
|
|
const NO_USER_CLEANUP_NEEDED = new Set([
|
|
// Example: ResourceType.SYSTEM_TEMPLATE — public/system; not user-owned
|
|
]);
|
|
|
|
describe('deleteUserController - resource type coverage guard', () => {
|
|
let controllerSource;
|
|
|
|
beforeAll(() => {
|
|
controllerSource = fs.readFileSync(path.resolve(__dirname, '../UserController.js'), 'utf-8');
|
|
});
|
|
|
|
test('every ResourceType must have a documented cleanup handler or explicit exclusion', () => {
|
|
const allTypes = Object.values(ResourceType);
|
|
const handledTypes = Object.keys(HANDLED_RESOURCE_TYPES);
|
|
const unhandledTypes = allTypes.filter(
|
|
(t) => !handledTypes.includes(t) && !NO_USER_CLEANUP_NEEDED.has(t),
|
|
);
|
|
|
|
expect(unhandledTypes).toEqual([]);
|
|
});
|
|
|
|
test('every cleanup handler referenced in HANDLED_RESOURCE_TYPES must appear in the controller source', () => {
|
|
const uniqueHandlers = [...new Set(Object.values(HANDLED_RESOURCE_TYPES))];
|
|
|
|
for (const handler of uniqueHandlers) {
|
|
expect(controllerSource).toContain(handler);
|
|
}
|
|
});
|
|
});
|