Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Title Field Support to Activities - Frontend Implementation with Unit Test #1083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/store/__test__/activityStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,50 @@ describe('ActivityStore', () => {
expect(result).toBeNull();
expect(activityStore.error).toBe('Creation failed');
});

it('should create activity with title', async () => {
const newActivity: INewActivity = {
workspace: 'test',
content: 'New activity',
contentType: 'feature_creation',
featureUUID: 'feature1',
phaseUUID: 'phase1',
author: 'human',
authorRef: 'user1',
title: 'Test Title'
};

const mockResponseActivity = {
...mockActivity,
title: 'Test Title'
};

(mainStore.createActivity as jest.Mock).mockResolvedValue(mockResponseActivity);

const result = await activityStore.createActivity(newActivity);

expect(result).toEqual(mockResponseActivity);
expect(activityStore.activities.get('1')?.title).toBe('Test Title');
});

it('should create activity without title', async () => {
const newActivity: INewActivity = {
workspace: 'test',
content: 'New activity',
contentType: 'feature_creation',
featureUUID: 'feature1',
phaseUUID: 'phase1',
author: 'human',
authorRef: 'user1'
};

(mainStore.createActivity as jest.Mock).mockResolvedValue(mockActivity);

const result = await activityStore.createActivity(newActivity);

expect(result).toEqual(mockActivity);
expect(activityStore.activities.get('1')?.title).toBeUndefined();
});
});

describe('createThreadResponse', () => {
Expand Down Expand Up @@ -145,6 +189,37 @@ describe('ActivityStore', () => {
expect(result).toBe(false);
expect(activityStore.error).toBe('Update failed');
});

it('should update activity title', async () => {
activityStore.activities.set('1', mockActivity);
const updates = { title: 'Updated Title' };

(mainStore.updateActivity as jest.Mock).mockResolvedValue(true);

const result = await activityStore.updateActivity('1', updates);

expect(result).toBe(true);
expect(activityStore.activities.get('1')?.title).toBe('Updated Title');
});

it('should update activity without title', async () => {
const activityWithTitle = { ...mockActivity, title: 'Initial Title' };
activityStore.activities.set('1', activityWithTitle);

const updates = { content: 'Updated content' };

(mainStore.updateActivity as jest.Mock).mockResolvedValue(true);

const result = await activityStore.updateActivity('1', updates);

expect(result).toBe(true);
expect(activityStore.activities.get('1')).toEqual({
...activityWithTitle,
content: 'Updated content'
});

expect(activityStore.activities.get('1')?.title).toBe('Initial Title');
});
});

describe('deleteActivity', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/store/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ export interface IActivity {
sequence: number;
contentType: ContentType;
content: string;
title?: string;
workspace: string;
featureUUID: string;
phaseUUID: string;
Expand All @@ -638,4 +639,5 @@ export interface INewActivity {
author: AuthorType;
authorRef: string;
threadId?: string;
title?: string;
}
Loading