Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(guides): add optional description field

Luis Ortiz634de9dccf63
diff --git a/src/core/guides/__tests__/service.test.ts b/src/core/guides/__tests__/service.test.ts
index 331afdf..17ae17b 100644
--- a/src/core/guides/__tests__/service.test.ts
+++ b/src/core/guides/__tests__/service.test.ts
@@ -38,6 +38,7 @@ import {
reorderSteps,
softDeleteGuide,
toggleStar,
+ updateGuideDescription,
} from '../service';
import type { Guide, Screenshot, Step } from '../types';
@@ -286,3 +287,22 @@ describe('getTrashedGuides', () => {
expect(guides.map((g) => g.id)).toEqual(['g3', 'g2']);
});
});
+
+describe('updateGuideDescription', () => {
+ it('stores the description, bumps updatedAt and broadcasts mutated', async () => {
+ await seedGuide('g-desc', { updatedAt: 100 });
+
+ await updateGuideDescription('g-desc', 'Reset a locked-out user password.');
+
+ const updated = await db.guides.get('g-desc');
+ expect(updated!.description).toBe('Reset a locked-out user password.');
+ expect(updated!.updatedAt).toBeGreaterThan(100);
+ expect(broadcastMessages).toContainEqual({ type: 'mutated' });
+ });
+
+ it('leaves description undefined on a freshly created guide', async () => {
+ await createGuide('g-fresh');
+ const stored = await db.guides.get('g-fresh');
+ expect(stored!.description).toBeUndefined();
+ });
+});
diff --git a/src/core/guides/service.ts b/src/core/guides/service.ts
index b62df84..9a63d8d 100644
--- a/src/core/guides/service.ts
+++ b/src/core/guides/service.ts
@@ -73,6 +73,11 @@ export async function updateGuideTitle(id: string, title: string): Promise<void>
notifyGuidesChanged({ type: 'mutated' });
}
+export async function updateGuideDescription(id: string, description: string): Promise<void> {
+ await db.guides.update(id, { description, updatedAt: Date.now() });
+ notifyGuidesChanged({ type: 'mutated' });
+}
+
export async function addStepToGuide(guideId: string, stepId: string): Promise<void> {
await db.transaction('rw', db.guides, async () => {
const guide = await db.guides.get(guideId);
diff --git a/src/core/guides/types.ts b/src/core/guides/types.ts
index 4f69bc0..e2c21b0 100644
--- a/src/core/guides/types.ts
+++ b/src/core/guides/types.ts
@@ -3,6 +3,7 @@ import type { ScreenshotEdits } from '@/core/screenshot/types';
export interface Guide {
id: string;
title: string;
+ description?: string;
createdAt: number;
updatedAt: number;
stepIds: string[];