business-as-code 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/dist/canvas/activities.d.ts +19 -0
- package/dist/canvas/activities.d.ts.map +1 -0
- package/dist/canvas/activities.js +20 -0
- package/dist/canvas/activities.js.map +1 -0
- package/dist/canvas/channels.d.ts +20 -0
- package/dist/canvas/channels.d.ts.map +1 -0
- package/dist/canvas/channels.js +21 -0
- package/dist/canvas/channels.js.map +1 -0
- package/dist/canvas/relationships.d.ts +20 -0
- package/dist/canvas/relationships.d.ts.map +1 -0
- package/dist/canvas/relationships.js +21 -0
- package/dist/canvas/relationships.js.map +1 -0
- package/dist/canvas/resources.d.ts +20 -0
- package/dist/canvas/resources.d.ts.map +1 -0
- package/dist/canvas/resources.js +30 -0
- package/dist/canvas/resources.js.map +1 -0
- package/dist/canvas/revenue.d.ts +22 -0
- package/dist/canvas/revenue.d.ts.map +1 -0
- package/dist/canvas/revenue.js +30 -0
- package/dist/canvas/revenue.js.map +1 -0
- package/dist/canvas/segments.d.ts +20 -0
- package/dist/canvas/segments.d.ts.map +1 -0
- package/dist/canvas/segments.js +28 -0
- package/dist/canvas/segments.js.map +1 -0
- package/dist/canvas/types.d.ts +232 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/canvas/types.js +8 -0
- package/dist/canvas/types.js.map +1 -0
- package/dist/canvas/value.d.ts +20 -0
- package/dist/canvas/value.d.ts.map +1 -0
- package/dist/canvas/value.js +21 -0
- package/dist/canvas/value.js.map +1 -0
- package/dist/entities/planning.d.ts +0 -87
- package/package.json +13 -13
- package/src/canvas/activities.ts +32 -0
- package/src/canvas/canvas.ts +482 -0
- package/src/canvas/channels.ts +34 -0
- package/src/canvas/costs.ts +43 -0
- package/src/canvas/economics.ts +99 -0
- package/src/canvas/index.ts +206 -0
- package/src/canvas/partnerships.ts +34 -0
- package/src/canvas/projections.ts +141 -0
- package/src/canvas/relationships.ts +34 -0
- package/src/canvas/resources.ts +43 -0
- package/src/canvas/revenue.ts +56 -0
- package/src/canvas/segments.ts +42 -0
- package/src/canvas/types.ts +363 -0
- package/src/canvas/value.ts +34 -0
- package/tests/canvas.test.ts +842 -0
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business Model Canvas Tests
|
|
3
|
+
*
|
|
4
|
+
* Phase 1: RED - All tests should FAIL initially
|
|
5
|
+
*
|
|
6
|
+
* Tests cover the 9 building blocks of the Business Model Canvas:
|
|
7
|
+
* 1. Customer Segments
|
|
8
|
+
* 2. Value Propositions
|
|
9
|
+
* 3. Channels
|
|
10
|
+
* 4. Customer Relationships
|
|
11
|
+
* 5. Revenue Streams
|
|
12
|
+
* 6. Key Resources
|
|
13
|
+
* 7. Key Activities
|
|
14
|
+
* 8. Key Partnerships
|
|
15
|
+
* 9. Cost Structure
|
|
16
|
+
*
|
|
17
|
+
* Plus: Canvas generation, unit economics, and AI analysis
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, it, expect } from 'vitest'
|
|
21
|
+
|
|
22
|
+
// Import from the canvas module (doesn't exist yet - will fail)
|
|
23
|
+
import {
|
|
24
|
+
// Core Canvas
|
|
25
|
+
BusinessModelCanvas,
|
|
26
|
+
createCanvas,
|
|
27
|
+
validateCanvas,
|
|
28
|
+
|
|
29
|
+
// Customer Segments
|
|
30
|
+
CustomerSegment,
|
|
31
|
+
createCustomerSegment,
|
|
32
|
+
|
|
33
|
+
// Value Propositions
|
|
34
|
+
ValueProposition,
|
|
35
|
+
createValueProposition,
|
|
36
|
+
|
|
37
|
+
// Channels
|
|
38
|
+
Channel,
|
|
39
|
+
createChannel,
|
|
40
|
+
|
|
41
|
+
// Customer Relationships
|
|
42
|
+
CustomerRelationship,
|
|
43
|
+
createCustomerRelationship,
|
|
44
|
+
|
|
45
|
+
// Revenue Streams
|
|
46
|
+
RevenueStream,
|
|
47
|
+
createRevenueStream,
|
|
48
|
+
|
|
49
|
+
// Key Resources
|
|
50
|
+
KeyResource,
|
|
51
|
+
createKeyResource,
|
|
52
|
+
|
|
53
|
+
// Key Activities
|
|
54
|
+
KeyActivity,
|
|
55
|
+
createKeyActivity,
|
|
56
|
+
|
|
57
|
+
// Key Partnerships
|
|
58
|
+
KeyPartnership,
|
|
59
|
+
createKeyPartnership,
|
|
60
|
+
|
|
61
|
+
// Cost Structure
|
|
62
|
+
CostItem,
|
|
63
|
+
createCostItem,
|
|
64
|
+
|
|
65
|
+
// Unit Economics
|
|
66
|
+
UnitEconomics,
|
|
67
|
+
calculateUnitEconomics,
|
|
68
|
+
calculateLTV,
|
|
69
|
+
calculateCAC,
|
|
70
|
+
calculateMargins,
|
|
71
|
+
|
|
72
|
+
// Financial Projections
|
|
73
|
+
FinancialProjection,
|
|
74
|
+
createProjection,
|
|
75
|
+
projectRevenue,
|
|
76
|
+
projectCosts,
|
|
77
|
+
projectProfitability,
|
|
78
|
+
|
|
79
|
+
// Canvas Generation & Analysis
|
|
80
|
+
generateCanvasSummary,
|
|
81
|
+
analyzeCanvasStrength,
|
|
82
|
+
identifyCanvasGaps,
|
|
83
|
+
} from '../src/canvas/index.js'
|
|
84
|
+
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// CUSTOMER SEGMENTS (3 tests)
|
|
87
|
+
// =============================================================================
|
|
88
|
+
|
|
89
|
+
describe('Customer Segments', () => {
|
|
90
|
+
it('should create a customer segment with required fields', () => {
|
|
91
|
+
const segment = createCustomerSegment({
|
|
92
|
+
name: 'Enterprise',
|
|
93
|
+
description: 'Large enterprises with 1000+ employees',
|
|
94
|
+
type: 'mass-market',
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
expect(segment.name).toBe('Enterprise')
|
|
98
|
+
expect(segment.description).toBe('Large enterprises with 1000+ employees')
|
|
99
|
+
expect(segment.type).toBe('mass-market')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should support different segment types', () => {
|
|
103
|
+
const niche = createCustomerSegment({
|
|
104
|
+
name: 'Crypto Startups',
|
|
105
|
+
type: 'niche',
|
|
106
|
+
characteristics: ['high-growth', 'tech-savvy', 'risk-tolerant'],
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const segmented = createCustomerSegment({
|
|
110
|
+
name: 'SMB',
|
|
111
|
+
type: 'segmented',
|
|
112
|
+
size: 50000,
|
|
113
|
+
revenuePerCustomer: 500,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
expect(niche.type).toBe('niche')
|
|
117
|
+
expect(niche.characteristics).toContain('high-growth')
|
|
118
|
+
expect(segmented.size).toBe(50000)
|
|
119
|
+
expect(segmented.revenuePerCustomer).toBe(500)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('should calculate segment potential', () => {
|
|
123
|
+
const segment = createCustomerSegment({
|
|
124
|
+
name: 'Enterprise',
|
|
125
|
+
size: 10000,
|
|
126
|
+
revenuePerCustomer: 50000,
|
|
127
|
+
expectedPenetration: 0.05,
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// 10000 * 50000 * 0.05 = 25,000,000
|
|
131
|
+
expect(segment.potential).toBe(25000000)
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
// =============================================================================
|
|
136
|
+
// VALUE PROPOSITIONS (3 tests)
|
|
137
|
+
// =============================================================================
|
|
138
|
+
|
|
139
|
+
describe('Value Propositions', () => {
|
|
140
|
+
it('should create a value proposition', () => {
|
|
141
|
+
const prop = createValueProposition({
|
|
142
|
+
name: 'AI-Powered Automation',
|
|
143
|
+
description: 'Reduce manual work by 80% with AI',
|
|
144
|
+
benefits: ['Time savings', 'Cost reduction', 'Error elimination'],
|
|
145
|
+
targetSegments: ['Enterprise', 'SMB'],
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
expect(prop.name).toBe('AI-Powered Automation')
|
|
149
|
+
expect(prop.benefits).toHaveLength(3)
|
|
150
|
+
expect(prop.targetSegments).toContain('Enterprise')
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('should support different value types', () => {
|
|
154
|
+
const newness = createValueProposition({
|
|
155
|
+
name: 'Revolutionary Tech',
|
|
156
|
+
valueType: 'newness',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const performance = createValueProposition({
|
|
160
|
+
name: '10x Faster',
|
|
161
|
+
valueType: 'performance',
|
|
162
|
+
quantifiedValue: '10x speed improvement',
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const costReduction = createValueProposition({
|
|
166
|
+
name: 'Save 50%',
|
|
167
|
+
valueType: 'cost-reduction',
|
|
168
|
+
quantifiedValue: '50% cost savings',
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
expect(newness.valueType).toBe('newness')
|
|
172
|
+
expect(performance.valueType).toBe('performance')
|
|
173
|
+
expect(costReduction.quantifiedValue).toBe('50% cost savings')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('should link value propositions to segments', () => {
|
|
177
|
+
const prop = createValueProposition({
|
|
178
|
+
name: 'Enterprise Security',
|
|
179
|
+
targetSegments: ['Enterprise'],
|
|
180
|
+
segmentFit: {
|
|
181
|
+
'Enterprise': 0.95,
|
|
182
|
+
'SMB': 0.6,
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
expect(prop.segmentFit?.['Enterprise']).toBe(0.95)
|
|
187
|
+
expect(prop.segmentFit?.['SMB']).toBe(0.6)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
// =============================================================================
|
|
192
|
+
// CHANNELS (2 tests)
|
|
193
|
+
// =============================================================================
|
|
194
|
+
|
|
195
|
+
describe('Channels', () => {
|
|
196
|
+
it('should create channels with phases', () => {
|
|
197
|
+
const channel = createChannel({
|
|
198
|
+
name: 'Direct Sales',
|
|
199
|
+
type: 'direct',
|
|
200
|
+
phases: ['awareness', 'evaluation', 'purchase', 'delivery', 'support'],
|
|
201
|
+
costPerAcquisition: 5000,
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
expect(channel.name).toBe('Direct Sales')
|
|
205
|
+
expect(channel.type).toBe('direct')
|
|
206
|
+
expect(channel.phases).toContain('purchase')
|
|
207
|
+
expect(channel.costPerAcquisition).toBe(5000)
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('should support different channel types', () => {
|
|
211
|
+
const partner = createChannel({
|
|
212
|
+
name: 'Partner Network',
|
|
213
|
+
type: 'partner',
|
|
214
|
+
partnerType: 'reseller',
|
|
215
|
+
revenueShare: 0.2,
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
const digital = createChannel({
|
|
219
|
+
name: 'Self-Serve',
|
|
220
|
+
type: 'digital',
|
|
221
|
+
conversionRate: 0.03,
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
expect(partner.type).toBe('partner')
|
|
225
|
+
expect(partner.revenueShare).toBe(0.2)
|
|
226
|
+
expect(digital.conversionRate).toBe(0.03)
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// =============================================================================
|
|
231
|
+
// CUSTOMER RELATIONSHIPS (2 tests)
|
|
232
|
+
// =============================================================================
|
|
233
|
+
|
|
234
|
+
describe('Customer Relationships', () => {
|
|
235
|
+
it('should create relationship types', () => {
|
|
236
|
+
const relationship = createCustomerRelationship({
|
|
237
|
+
name: 'Dedicated Account Management',
|
|
238
|
+
type: 'dedicated-assistance',
|
|
239
|
+
segment: 'Enterprise',
|
|
240
|
+
touchFrequency: 'weekly',
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
expect(relationship.name).toBe('Dedicated Account Management')
|
|
244
|
+
expect(relationship.type).toBe('dedicated-assistance')
|
|
245
|
+
expect(relationship.segment).toBe('Enterprise')
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('should support automated relationships', () => {
|
|
249
|
+
const automated = createCustomerRelationship({
|
|
250
|
+
name: 'Self-Service Portal',
|
|
251
|
+
type: 'automated',
|
|
252
|
+
automationLevel: 0.9,
|
|
253
|
+
supportChannels: ['chat', 'email', 'docs'],
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
const community = createCustomerRelationship({
|
|
257
|
+
name: 'User Community',
|
|
258
|
+
type: 'community',
|
|
259
|
+
platforms: ['discord', 'forum'],
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
expect(automated.automationLevel).toBe(0.9)
|
|
263
|
+
expect(community.type).toBe('community')
|
|
264
|
+
expect(community.platforms).toContain('discord')
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
// =============================================================================
|
|
269
|
+
// REVENUE STREAMS (3 tests)
|
|
270
|
+
// =============================================================================
|
|
271
|
+
|
|
272
|
+
describe('Revenue Streams', () => {
|
|
273
|
+
it('should create revenue streams', () => {
|
|
274
|
+
const subscription = createRevenueStream({
|
|
275
|
+
name: 'SaaS Subscription',
|
|
276
|
+
type: 'recurring',
|
|
277
|
+
pricingModel: 'subscription',
|
|
278
|
+
price: 99,
|
|
279
|
+
billingCycle: 'monthly',
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
expect(subscription.name).toBe('SaaS Subscription')
|
|
283
|
+
expect(subscription.type).toBe('recurring')
|
|
284
|
+
expect(subscription.price).toBe(99)
|
|
285
|
+
expect(subscription.billingCycle).toBe('monthly')
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('should support different pricing mechanisms', () => {
|
|
289
|
+
const usageBased = createRevenueStream({
|
|
290
|
+
name: 'API Calls',
|
|
291
|
+
type: 'recurring',
|
|
292
|
+
pricingModel: 'usage-based',
|
|
293
|
+
pricePerUnit: 0.001,
|
|
294
|
+
unitName: 'API call',
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
const tiered = createRevenueStream({
|
|
298
|
+
name: 'Plans',
|
|
299
|
+
type: 'recurring',
|
|
300
|
+
pricingModel: 'tiered',
|
|
301
|
+
tiers: [
|
|
302
|
+
{ name: 'Starter', price: 29 },
|
|
303
|
+
{ name: 'Pro', price: 99 },
|
|
304
|
+
{ name: 'Enterprise', price: 499 },
|
|
305
|
+
],
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
expect(usageBased.pricePerUnit).toBe(0.001)
|
|
309
|
+
expect(tiered.tiers).toHaveLength(3)
|
|
310
|
+
expect(tiered.tiers?.[1]?.price).toBe(99)
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('should calculate annual revenue', () => {
|
|
314
|
+
const stream = createRevenueStream({
|
|
315
|
+
name: 'SaaS',
|
|
316
|
+
type: 'recurring',
|
|
317
|
+
pricingModel: 'subscription',
|
|
318
|
+
price: 100,
|
|
319
|
+
billingCycle: 'monthly',
|
|
320
|
+
activeCustomers: 1000,
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
// 100 * 12 * 1000 = 1,200,000
|
|
324
|
+
expect(stream.annualRevenue).toBe(1200000)
|
|
325
|
+
})
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
// =============================================================================
|
|
329
|
+
// KEY RESOURCES (2 tests)
|
|
330
|
+
// =============================================================================
|
|
331
|
+
|
|
332
|
+
describe('Key Resources', () => {
|
|
333
|
+
it('should create different resource types', () => {
|
|
334
|
+
const physical = createKeyResource({
|
|
335
|
+
name: 'Data Centers',
|
|
336
|
+
type: 'physical',
|
|
337
|
+
cost: 500000,
|
|
338
|
+
depreciation: 'monthly',
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
const intellectual = createKeyResource({
|
|
342
|
+
name: 'AI Models',
|
|
343
|
+
type: 'intellectual',
|
|
344
|
+
protectionType: 'trade-secret',
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
const human = createKeyResource({
|
|
348
|
+
name: 'Engineering Team',
|
|
349
|
+
type: 'human',
|
|
350
|
+
headcount: 50,
|
|
351
|
+
averageCost: 150000,
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
expect(physical.type).toBe('physical')
|
|
355
|
+
expect(intellectual.protectionType).toBe('trade-secret')
|
|
356
|
+
expect(human.headcount).toBe(50)
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('should calculate total resource cost', () => {
|
|
360
|
+
const resource = createKeyResource({
|
|
361
|
+
name: 'Engineering Team',
|
|
362
|
+
type: 'human',
|
|
363
|
+
headcount: 10,
|
|
364
|
+
averageCost: 200000,
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
// 10 * 200000 = 2,000,000
|
|
368
|
+
expect(resource.totalCost).toBe(2000000)
|
|
369
|
+
})
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
// =============================================================================
|
|
373
|
+
// KEY ACTIVITIES (2 tests)
|
|
374
|
+
// =============================================================================
|
|
375
|
+
|
|
376
|
+
describe('Key Activities', () => {
|
|
377
|
+
it('should create key activities', () => {
|
|
378
|
+
const activity = createKeyActivity({
|
|
379
|
+
name: 'Product Development',
|
|
380
|
+
category: 'production',
|
|
381
|
+
description: 'Building and improving the core product',
|
|
382
|
+
resources: ['Engineering Team', 'AI Models'],
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
expect(activity.name).toBe('Product Development')
|
|
386
|
+
expect(activity.category).toBe('production')
|
|
387
|
+
expect(activity.resources).toContain('Engineering Team')
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
it('should support different activity categories', () => {
|
|
391
|
+
const problemSolving = createKeyActivity({
|
|
392
|
+
name: 'Customer Success',
|
|
393
|
+
category: 'problem-solving',
|
|
394
|
+
metrics: ['NPS', 'CSAT', 'Churn Rate'],
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
const platform = createKeyActivity({
|
|
398
|
+
name: 'Platform Operations',
|
|
399
|
+
category: 'platform',
|
|
400
|
+
uptime: 0.999,
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
expect(problemSolving.category).toBe('problem-solving')
|
|
404
|
+
expect(problemSolving.metrics).toContain('NPS')
|
|
405
|
+
expect(platform.uptime).toBe(0.999)
|
|
406
|
+
})
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
// =============================================================================
|
|
410
|
+
// KEY PARTNERSHIPS (2 tests)
|
|
411
|
+
// =============================================================================
|
|
412
|
+
|
|
413
|
+
describe('Key Partnerships', () => {
|
|
414
|
+
it('should create partnerships', () => {
|
|
415
|
+
const partnership = createKeyPartnership({
|
|
416
|
+
name: 'AWS',
|
|
417
|
+
type: 'strategic-alliance',
|
|
418
|
+
purpose: 'Cloud infrastructure and marketplace distribution',
|
|
419
|
+
benefits: ['Infrastructure', 'Distribution', 'Credibility'],
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
expect(partnership.name).toBe('AWS')
|
|
423
|
+
expect(partnership.type).toBe('strategic-alliance')
|
|
424
|
+
expect(partnership.benefits).toContain('Distribution')
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
it('should support different partnership types', () => {
|
|
428
|
+
const supplier = createKeyPartnership({
|
|
429
|
+
name: 'Data Provider',
|
|
430
|
+
type: 'buyer-supplier',
|
|
431
|
+
contractValue: 100000,
|
|
432
|
+
contractTerm: 12,
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
const coopetition = createKeyPartnership({
|
|
436
|
+
name: 'Industry Competitor',
|
|
437
|
+
type: 'coopetition',
|
|
438
|
+
sharedActivities: ['Standards', 'Lobbying'],
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
expect(supplier.type).toBe('buyer-supplier')
|
|
442
|
+
expect(supplier.contractValue).toBe(100000)
|
|
443
|
+
expect(coopetition.sharedActivities).toContain('Standards')
|
|
444
|
+
})
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
// =============================================================================
|
|
448
|
+
// COST STRUCTURE (3 tests)
|
|
449
|
+
// =============================================================================
|
|
450
|
+
|
|
451
|
+
describe('Cost Structure', () => {
|
|
452
|
+
it('should create cost items', () => {
|
|
453
|
+
const cost = createCostItem({
|
|
454
|
+
name: 'Engineering Salaries',
|
|
455
|
+
category: 'fixed',
|
|
456
|
+
amount: 2000000,
|
|
457
|
+
period: 'annual',
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
expect(cost.name).toBe('Engineering Salaries')
|
|
461
|
+
expect(cost.category).toBe('fixed')
|
|
462
|
+
expect(cost.amount).toBe(2000000)
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
it('should support variable costs', () => {
|
|
466
|
+
const hosting = createCostItem({
|
|
467
|
+
name: 'Cloud Hosting',
|
|
468
|
+
category: 'variable',
|
|
469
|
+
unitCost: 0.10,
|
|
470
|
+
unitName: 'active user',
|
|
471
|
+
volumeEstimate: 100000,
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
// 0.10 * 100000 = 10,000
|
|
475
|
+
expect(hosting.estimatedTotal).toBe(10000)
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
it('should categorize costs by type', () => {
|
|
479
|
+
const costs = [
|
|
480
|
+
createCostItem({ name: 'Salaries', category: 'fixed', amount: 1000000 }),
|
|
481
|
+
createCostItem({ name: 'Marketing', category: 'fixed', amount: 200000 }),
|
|
482
|
+
createCostItem({ name: 'Hosting', category: 'variable', unitCost: 0.1, volumeEstimate: 100000 }),
|
|
483
|
+
]
|
|
484
|
+
|
|
485
|
+
const fixed = costs.filter(c => c.category === 'fixed')
|
|
486
|
+
const variable = costs.filter(c => c.category === 'variable')
|
|
487
|
+
|
|
488
|
+
expect(fixed).toHaveLength(2)
|
|
489
|
+
expect(variable).toHaveLength(1)
|
|
490
|
+
})
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
// =============================================================================
|
|
494
|
+
// UNIT ECONOMICS (3 tests)
|
|
495
|
+
// =============================================================================
|
|
496
|
+
|
|
497
|
+
describe('Unit Economics', () => {
|
|
498
|
+
it('should calculate LTV', () => {
|
|
499
|
+
const ltv = calculateLTV({
|
|
500
|
+
averageRevenuePerUser: 100,
|
|
501
|
+
grossMargin: 0.7,
|
|
502
|
+
churnRate: 0.05,
|
|
503
|
+
})
|
|
504
|
+
|
|
505
|
+
// LTV = ARPU * Gross Margin / Churn Rate
|
|
506
|
+
// 100 * 0.7 / 0.05 = 1400
|
|
507
|
+
expect(ltv).toBe(1400)
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
it('should calculate CAC', () => {
|
|
511
|
+
const cac = calculateCAC({
|
|
512
|
+
marketingSpend: 50000,
|
|
513
|
+
salesSpend: 100000,
|
|
514
|
+
newCustomers: 500,
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
// (50000 + 100000) / 500 = 300
|
|
518
|
+
expect(cac).toBe(300)
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it('should calculate comprehensive unit economics', () => {
|
|
522
|
+
const economics = calculateUnitEconomics({
|
|
523
|
+
averageRevenuePerUser: 100,
|
|
524
|
+
grossMargin: 0.7,
|
|
525
|
+
churnRate: 0.05,
|
|
526
|
+
marketingSpend: 50000,
|
|
527
|
+
salesSpend: 100000,
|
|
528
|
+
newCustomers: 500,
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
expect(economics.ltv).toBe(1400)
|
|
532
|
+
expect(economics.cac).toBe(300)
|
|
533
|
+
expect(economics.ltvCacRatio).toBeCloseTo(4.67, 1)
|
|
534
|
+
expect(economics.paybackMonths).toBeCloseTo(4.29, 1) // CAC / (ARPU * Gross Margin)
|
|
535
|
+
})
|
|
536
|
+
})
|
|
537
|
+
|
|
538
|
+
// =============================================================================
|
|
539
|
+
// MARGINS (2 tests)
|
|
540
|
+
// =============================================================================
|
|
541
|
+
|
|
542
|
+
describe('Margins', () => {
|
|
543
|
+
it('should calculate gross margin', () => {
|
|
544
|
+
const margins = calculateMargins({
|
|
545
|
+
revenue: 1000000,
|
|
546
|
+
cogs: 300000,
|
|
547
|
+
operatingExpenses: 500000,
|
|
548
|
+
})
|
|
549
|
+
|
|
550
|
+
expect(margins.grossMargin).toBe(0.7) // (1000000 - 300000) / 1000000
|
|
551
|
+
expect(margins.grossProfit).toBe(700000)
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
it('should calculate operating and net margins', () => {
|
|
555
|
+
const margins = calculateMargins({
|
|
556
|
+
revenue: 1000000,
|
|
557
|
+
cogs: 300000,
|
|
558
|
+
operatingExpenses: 500000,
|
|
559
|
+
taxes: 40000,
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
expect(margins.operatingMargin).toBe(0.2) // (1000000 - 300000 - 500000) / 1000000
|
|
563
|
+
expect(margins.operatingIncome).toBe(200000)
|
|
564
|
+
expect(margins.netMargin).toBe(0.16) // (200000 - 40000) / 1000000
|
|
565
|
+
expect(margins.netIncome).toBe(160000)
|
|
566
|
+
})
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
// =============================================================================
|
|
570
|
+
// FINANCIAL PROJECTIONS (3 tests)
|
|
571
|
+
// =============================================================================
|
|
572
|
+
|
|
573
|
+
describe('Financial Projections', () => {
|
|
574
|
+
it('should project revenue growth', () => {
|
|
575
|
+
const projection = projectRevenue({
|
|
576
|
+
startingMRR: 100000,
|
|
577
|
+
monthlyGrowthRate: 0.1,
|
|
578
|
+
months: 12,
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
expect(projection.months).toHaveLength(12)
|
|
582
|
+
expect(projection.months[0]?.mrr).toBe(100000)
|
|
583
|
+
expect(projection.months[11]?.mrr).toBeCloseTo(285311, -2) // 100000 * 1.1^11
|
|
584
|
+
expect(projection.endingARR).toBeCloseTo(3423733, -2) // 285311 * 12
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
it('should project costs', () => {
|
|
588
|
+
const projection = projectCosts({
|
|
589
|
+
fixedCosts: 500000,
|
|
590
|
+
variableCostPerUser: 10,
|
|
591
|
+
startingUsers: 1000,
|
|
592
|
+
monthlyUserGrowth: 0.1,
|
|
593
|
+
months: 12,
|
|
594
|
+
})
|
|
595
|
+
|
|
596
|
+
expect(projection.months).toHaveLength(12)
|
|
597
|
+
expect(projection.months[0]?.totalCost).toBeCloseTo(510000) // 500000 + 1000*10
|
|
598
|
+
expect(projection.months[11]?.totalCost).toBeCloseTo(528531, -2) // 500000 + 2853*10
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
it('should project profitability', () => {
|
|
602
|
+
const projection = projectProfitability({
|
|
603
|
+
startingMRR: 100000,
|
|
604
|
+
monthlyGrowthRate: 0.1,
|
|
605
|
+
fixedCosts: 80000,
|
|
606
|
+
grossMargin: 0.7,
|
|
607
|
+
months: 24,
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
expect(projection.months).toHaveLength(24)
|
|
611
|
+
expect(projection.breakEvenMonth).toBeDefined()
|
|
612
|
+
expect(projection.totalProfit).toBeGreaterThan(0)
|
|
613
|
+
})
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
// =============================================================================
|
|
617
|
+
// CANVAS GENERATION (3 tests)
|
|
618
|
+
// =============================================================================
|
|
619
|
+
|
|
620
|
+
describe('Business Model Canvas', () => {
|
|
621
|
+
it('should create a complete canvas', () => {
|
|
622
|
+
const canvas = createCanvas({
|
|
623
|
+
name: 'SaaS Startup',
|
|
624
|
+
customerSegments: [
|
|
625
|
+
createCustomerSegment({ name: 'Enterprise', type: 'segmented' }),
|
|
626
|
+
createCustomerSegment({ name: 'SMB', type: 'mass-market' }),
|
|
627
|
+
],
|
|
628
|
+
valuePropositions: [
|
|
629
|
+
createValueProposition({ name: 'AI Automation', valueType: 'performance' }),
|
|
630
|
+
],
|
|
631
|
+
channels: [
|
|
632
|
+
createChannel({ name: 'Direct Sales', type: 'direct' }),
|
|
633
|
+
createChannel({ name: 'Self-Serve', type: 'digital' }),
|
|
634
|
+
],
|
|
635
|
+
customerRelationships: [
|
|
636
|
+
createCustomerRelationship({ name: 'Account Management', type: 'dedicated-assistance' }),
|
|
637
|
+
],
|
|
638
|
+
revenueStreams: [
|
|
639
|
+
createRevenueStream({ name: 'Subscription', type: 'recurring', pricingModel: 'subscription' }),
|
|
640
|
+
],
|
|
641
|
+
keyResources: [
|
|
642
|
+
createKeyResource({ name: 'AI Models', type: 'intellectual' }),
|
|
643
|
+
createKeyResource({ name: 'Engineering', type: 'human' }),
|
|
644
|
+
],
|
|
645
|
+
keyActivities: [
|
|
646
|
+
createKeyActivity({ name: 'Product Dev', category: 'production' }),
|
|
647
|
+
],
|
|
648
|
+
keyPartnerships: [
|
|
649
|
+
createKeyPartnership({ name: 'AWS', type: 'strategic-alliance' }),
|
|
650
|
+
],
|
|
651
|
+
costStructure: [
|
|
652
|
+
createCostItem({ name: 'Engineering', category: 'fixed', amount: 2000000 }),
|
|
653
|
+
],
|
|
654
|
+
})
|
|
655
|
+
|
|
656
|
+
expect(canvas.name).toBe('SaaS Startup')
|
|
657
|
+
expect(canvas.customerSegments).toHaveLength(2)
|
|
658
|
+
expect(canvas.valuePropositions).toHaveLength(1)
|
|
659
|
+
expect(canvas.channels).toHaveLength(2)
|
|
660
|
+
expect(canvas.revenueStreams).toHaveLength(1)
|
|
661
|
+
expect(canvas.keyResources).toHaveLength(2)
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
it('should validate canvas completeness', () => {
|
|
665
|
+
const incomplete = createCanvas({
|
|
666
|
+
name: 'Incomplete',
|
|
667
|
+
customerSegments: [],
|
|
668
|
+
valuePropositions: [],
|
|
669
|
+
channels: [],
|
|
670
|
+
customerRelationships: [],
|
|
671
|
+
revenueStreams: [],
|
|
672
|
+
keyResources: [],
|
|
673
|
+
keyActivities: [],
|
|
674
|
+
keyPartnerships: [],
|
|
675
|
+
costStructure: [],
|
|
676
|
+
})
|
|
677
|
+
|
|
678
|
+
const validation = validateCanvas(incomplete)
|
|
679
|
+
|
|
680
|
+
expect(validation.isComplete).toBe(false)
|
|
681
|
+
expect(validation.missingBlocks).toContain('customerSegments')
|
|
682
|
+
expect(validation.missingBlocks).toContain('valuePropositions')
|
|
683
|
+
expect(validation.missingBlocks).toContain('revenueStreams')
|
|
684
|
+
})
|
|
685
|
+
|
|
686
|
+
it('should generate canvas summary', () => {
|
|
687
|
+
const canvas = createCanvas({
|
|
688
|
+
name: 'Test Business',
|
|
689
|
+
customerSegments: [
|
|
690
|
+
createCustomerSegment({ name: 'Enterprise', size: 10000, revenuePerCustomer: 10000 }),
|
|
691
|
+
],
|
|
692
|
+
valuePropositions: [
|
|
693
|
+
createValueProposition({ name: 'Value', benefits: ['Speed', 'Cost'] }),
|
|
694
|
+
],
|
|
695
|
+
channels: [createChannel({ name: 'Direct', type: 'direct' })],
|
|
696
|
+
customerRelationships: [createCustomerRelationship({ name: 'Support', type: 'automated' })],
|
|
697
|
+
revenueStreams: [
|
|
698
|
+
createRevenueStream({ name: 'Sub', type: 'recurring', pricingModel: 'subscription', price: 100, activeCustomers: 1000 }),
|
|
699
|
+
],
|
|
700
|
+
keyResources: [createKeyResource({ name: 'Tech', type: 'intellectual' })],
|
|
701
|
+
keyActivities: [createKeyActivity({ name: 'Dev', category: 'production' })],
|
|
702
|
+
keyPartnerships: [createKeyPartnership({ name: 'Partner', type: 'strategic-alliance' })],
|
|
703
|
+
costStructure: [createCostItem({ name: 'Ops', category: 'fixed', amount: 500000 })],
|
|
704
|
+
})
|
|
705
|
+
|
|
706
|
+
const summary = generateCanvasSummary(canvas)
|
|
707
|
+
|
|
708
|
+
expect(summary.totalAddressableMarket).toBe(100000000) // 10000 * 10000
|
|
709
|
+
expect(summary.projectedAnnualRevenue).toBe(1200000) // 100 * 12 * 1000
|
|
710
|
+
expect(summary.totalAnnualCosts).toBe(500000)
|
|
711
|
+
expect(summary.projectedProfit).toBe(700000)
|
|
712
|
+
})
|
|
713
|
+
})
|
|
714
|
+
|
|
715
|
+
// =============================================================================
|
|
716
|
+
// CANVAS ANALYSIS (2 tests)
|
|
717
|
+
// =============================================================================
|
|
718
|
+
|
|
719
|
+
describe('Canvas Analysis', () => {
|
|
720
|
+
it('should analyze canvas strength', () => {
|
|
721
|
+
const canvas = createCanvas({
|
|
722
|
+
name: 'Strong Business',
|
|
723
|
+
customerSegments: [
|
|
724
|
+
createCustomerSegment({ name: 'Enterprise', size: 10000, revenuePerCustomer: 50000 }),
|
|
725
|
+
],
|
|
726
|
+
valuePropositions: [
|
|
727
|
+
createValueProposition({ name: 'Unique Value', valueType: 'newness', benefits: ['A', 'B', 'C'] }),
|
|
728
|
+
],
|
|
729
|
+
channels: [
|
|
730
|
+
createChannel({ name: 'Sales', type: 'direct', costPerAcquisition: 1000 }),
|
|
731
|
+
createChannel({ name: 'Marketing', type: 'digital', costPerAcquisition: 100 }),
|
|
732
|
+
],
|
|
733
|
+
customerRelationships: [createCustomerRelationship({ name: 'AM', type: 'dedicated-assistance' })],
|
|
734
|
+
revenueStreams: [
|
|
735
|
+
createRevenueStream({ name: 'Sub', type: 'recurring', pricingModel: 'subscription', price: 1000 }),
|
|
736
|
+
],
|
|
737
|
+
keyResources: [
|
|
738
|
+
createKeyResource({ name: 'IP', type: 'intellectual' }),
|
|
739
|
+
createKeyResource({ name: 'Team', type: 'human', headcount: 20 }),
|
|
740
|
+
],
|
|
741
|
+
keyActivities: [createKeyActivity({ name: 'R&D', category: 'production' })],
|
|
742
|
+
keyPartnerships: [createKeyPartnership({ name: 'Tech Partner', type: 'strategic-alliance' })],
|
|
743
|
+
costStructure: [createCostItem({ name: 'Ops', category: 'fixed', amount: 1000000 })],
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
const analysis = analyzeCanvasStrength(canvas)
|
|
747
|
+
|
|
748
|
+
expect(analysis.overallScore).toBeGreaterThan(0)
|
|
749
|
+
expect(analysis.overallScore).toBeLessThanOrEqual(100)
|
|
750
|
+
expect(analysis.strengths).toBeDefined()
|
|
751
|
+
expect(analysis.weaknesses).toBeDefined()
|
|
752
|
+
expect(analysis.blockScores).toHaveProperty('customerSegments')
|
|
753
|
+
expect(analysis.blockScores).toHaveProperty('valuePropositions')
|
|
754
|
+
})
|
|
755
|
+
|
|
756
|
+
it('should identify canvas gaps', () => {
|
|
757
|
+
const canvas = createCanvas({
|
|
758
|
+
name: 'Gaps Business',
|
|
759
|
+
customerSegments: [createCustomerSegment({ name: 'Unknown', type: 'mass-market' })],
|
|
760
|
+
valuePropositions: [], // Gap: no value props
|
|
761
|
+
channels: [createChannel({ name: 'None', type: 'direct' })],
|
|
762
|
+
customerRelationships: [], // Gap: no relationships
|
|
763
|
+
revenueStreams: [createRevenueStream({ name: 'Revenue', type: 'one-time', pricingModel: 'fixed' })],
|
|
764
|
+
keyResources: [], // Gap: no resources
|
|
765
|
+
keyActivities: [createKeyActivity({ name: 'Activity', category: 'production' })],
|
|
766
|
+
keyPartnerships: [], // Gap: no partnerships
|
|
767
|
+
costStructure: [createCostItem({ name: 'Cost', category: 'fixed', amount: 100000 })],
|
|
768
|
+
})
|
|
769
|
+
|
|
770
|
+
const gaps = identifyCanvasGaps(canvas)
|
|
771
|
+
|
|
772
|
+
expect(gaps.criticalGaps).toContain('valuePropositions')
|
|
773
|
+
expect(gaps.warnings).toBeDefined()
|
|
774
|
+
expect(gaps.recommendations).toBeDefined()
|
|
775
|
+
expect(gaps.recommendations.length).toBeGreaterThan(0)
|
|
776
|
+
})
|
|
777
|
+
})
|
|
778
|
+
|
|
779
|
+
// =============================================================================
|
|
780
|
+
// TYPE DEFINITIONS (verify TypeScript types work)
|
|
781
|
+
// =============================================================================
|
|
782
|
+
|
|
783
|
+
describe('Type Definitions', () => {
|
|
784
|
+
it('should export proper TypeScript types', () => {
|
|
785
|
+
// These should compile without errors
|
|
786
|
+
const segment: CustomerSegment = {
|
|
787
|
+
name: 'Test',
|
|
788
|
+
type: 'mass-market',
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
const value: ValueProposition = {
|
|
792
|
+
name: 'Test',
|
|
793
|
+
benefits: [],
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
const channel: Channel = {
|
|
797
|
+
name: 'Test',
|
|
798
|
+
type: 'direct',
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const relationship: CustomerRelationship = {
|
|
802
|
+
name: 'Test',
|
|
803
|
+
type: 'automated',
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const revenue: RevenueStream = {
|
|
807
|
+
name: 'Test',
|
|
808
|
+
type: 'recurring',
|
|
809
|
+
pricingModel: 'subscription',
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const resource: KeyResource = {
|
|
813
|
+
name: 'Test',
|
|
814
|
+
type: 'intellectual',
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
const activity: KeyActivity = {
|
|
818
|
+
name: 'Test',
|
|
819
|
+
category: 'production',
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const partnership: KeyPartnership = {
|
|
823
|
+
name: 'Test',
|
|
824
|
+
type: 'strategic-alliance',
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const cost: CostItem = {
|
|
828
|
+
name: 'Test',
|
|
829
|
+
category: 'fixed',
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
expect(segment).toBeDefined()
|
|
833
|
+
expect(value).toBeDefined()
|
|
834
|
+
expect(channel).toBeDefined()
|
|
835
|
+
expect(relationship).toBeDefined()
|
|
836
|
+
expect(revenue).toBeDefined()
|
|
837
|
+
expect(resource).toBeDefined()
|
|
838
|
+
expect(activity).toBeDefined()
|
|
839
|
+
expect(partnership).toBeDefined()
|
|
840
|
+
expect(cost).toBeDefined()
|
|
841
|
+
})
|
|
842
|
+
})
|