refactor: CI optimization, logging improvements, and codebase formatting (#456)
* fix(db): remove unique constraint on folder to support multi-channel agents * ci: implement automated skill drift detection and self-healing PRs * fix: align registration logic with Gavriel's feedback and fix build/test issues from Daniel Mi * style: conform to prettier standards for CI validation * test: fix branch naming inconsistency in CI (master vs main) * fix(ci): robust module resolution by removing file extensions in scripts * refactor(ci): simplify skill validation by removing redundant combination tests * style: conform skills-engine to prettier, unify logging in index.ts and cleanup unused imports * refactor: extract multi-channel DB changes to separate branch Move channel column, folder suffix logic, and related migrations to feat/multi-channel-db-v2 for independent review. This PR now contains only CI/CD optimizations, Prettier formatting, and logging improvements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,9 +28,27 @@ describe('JID ownership patterns', () => {
|
||||
|
||||
describe('getAvailableGroups', () => {
|
||||
it('returns only groups, excludes DMs', () => {
|
||||
storeChatMetadata('group1@g.us', '2024-01-01T00:00:01.000Z', 'Group 1', 'whatsapp', true);
|
||||
storeChatMetadata('user@s.whatsapp.net', '2024-01-01T00:00:02.000Z', 'User DM', 'whatsapp', false);
|
||||
storeChatMetadata('group2@g.us', '2024-01-01T00:00:03.000Z', 'Group 2', 'whatsapp', true);
|
||||
storeChatMetadata(
|
||||
'group1@g.us',
|
||||
'2024-01-01T00:00:01.000Z',
|
||||
'Group 1',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
storeChatMetadata(
|
||||
'user@s.whatsapp.net',
|
||||
'2024-01-01T00:00:02.000Z',
|
||||
'User DM',
|
||||
'whatsapp',
|
||||
false,
|
||||
);
|
||||
storeChatMetadata(
|
||||
'group2@g.us',
|
||||
'2024-01-01T00:00:03.000Z',
|
||||
'Group 2',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
|
||||
const groups = getAvailableGroups();
|
||||
expect(groups).toHaveLength(2);
|
||||
@@ -41,7 +59,13 @@ describe('getAvailableGroups', () => {
|
||||
|
||||
it('excludes __group_sync__ sentinel', () => {
|
||||
storeChatMetadata('__group_sync__', '2024-01-01T00:00:00.000Z');
|
||||
storeChatMetadata('group@g.us', '2024-01-01T00:00:01.000Z', 'Group', 'whatsapp', true);
|
||||
storeChatMetadata(
|
||||
'group@g.us',
|
||||
'2024-01-01T00:00:01.000Z',
|
||||
'Group',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
|
||||
const groups = getAvailableGroups();
|
||||
expect(groups).toHaveLength(1);
|
||||
@@ -49,8 +73,20 @@ describe('getAvailableGroups', () => {
|
||||
});
|
||||
|
||||
it('marks registered groups correctly', () => {
|
||||
storeChatMetadata('reg@g.us', '2024-01-01T00:00:01.000Z', 'Registered', 'whatsapp', true);
|
||||
storeChatMetadata('unreg@g.us', '2024-01-01T00:00:02.000Z', 'Unregistered', 'whatsapp', true);
|
||||
storeChatMetadata(
|
||||
'reg@g.us',
|
||||
'2024-01-01T00:00:01.000Z',
|
||||
'Registered',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
storeChatMetadata(
|
||||
'unreg@g.us',
|
||||
'2024-01-01T00:00:02.000Z',
|
||||
'Unregistered',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
|
||||
_setRegisteredGroups({
|
||||
'reg@g.us': {
|
||||
@@ -70,9 +106,27 @@ describe('getAvailableGroups', () => {
|
||||
});
|
||||
|
||||
it('returns groups ordered by most recent activity', () => {
|
||||
storeChatMetadata('old@g.us', '2024-01-01T00:00:01.000Z', 'Old', 'whatsapp', true);
|
||||
storeChatMetadata('new@g.us', '2024-01-01T00:00:05.000Z', 'New', 'whatsapp', true);
|
||||
storeChatMetadata('mid@g.us', '2024-01-01T00:00:03.000Z', 'Mid', 'whatsapp', true);
|
||||
storeChatMetadata(
|
||||
'old@g.us',
|
||||
'2024-01-01T00:00:01.000Z',
|
||||
'Old',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
storeChatMetadata(
|
||||
'new@g.us',
|
||||
'2024-01-01T00:00:05.000Z',
|
||||
'New',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
storeChatMetadata(
|
||||
'mid@g.us',
|
||||
'2024-01-01T00:00:03.000Z',
|
||||
'Mid',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
|
||||
const groups = getAvailableGroups();
|
||||
expect(groups[0].jid).toBe('new@g.us');
|
||||
@@ -82,11 +136,27 @@ describe('getAvailableGroups', () => {
|
||||
|
||||
it('excludes non-group chats regardless of JID format', () => {
|
||||
// Unknown JID format stored without is_group should not appear
|
||||
storeChatMetadata('unknown-format-123', '2024-01-01T00:00:01.000Z', 'Unknown');
|
||||
storeChatMetadata(
|
||||
'unknown-format-123',
|
||||
'2024-01-01T00:00:01.000Z',
|
||||
'Unknown',
|
||||
);
|
||||
// Explicitly non-group with unusual JID
|
||||
storeChatMetadata('custom:abc', '2024-01-01T00:00:02.000Z', 'Custom DM', 'custom', false);
|
||||
storeChatMetadata(
|
||||
'custom:abc',
|
||||
'2024-01-01T00:00:02.000Z',
|
||||
'Custom DM',
|
||||
'custom',
|
||||
false,
|
||||
);
|
||||
// A real group for contrast
|
||||
storeChatMetadata('group@g.us', '2024-01-01T00:00:03.000Z', 'Group', 'whatsapp', true);
|
||||
storeChatMetadata(
|
||||
'group@g.us',
|
||||
'2024-01-01T00:00:03.000Z',
|
||||
'Group',
|
||||
'whatsapp',
|
||||
true,
|
||||
);
|
||||
|
||||
const groups = getAvailableGroups();
|
||||
expect(groups).toHaveLength(1);
|
||||
|
||||
Reference in New Issue
Block a user