termcast 1.3.44 → 1.3.46

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.
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Comprehensive Detail.Metadata showcase demonstrating all metadata features:
3
+ * - Labels (short/long values, colored text, header-only)
4
+ * - Separators between groups
5
+ * - Groups without separators
6
+ * - Links (short and long)
7
+ * - TagList with colored tags
8
+ * - Various Color enum values
9
+ */
10
+
11
+ import React from 'react'
12
+ import { Detail, Color } from 'termcast'
13
+ import { renderWithProviders } from '../utils'
14
+
15
+ const DetailMetadataShowcase = () => {
16
+ return (
17
+ <Detail
18
+ navigationTitle="Metadata Showcase"
19
+ markdown={`# Project Update: Q1 2024 Review
20
+
21
+ This detail view demonstrates markdown content alongside metadata.
22
+
23
+ ---
24
+
25
+ ## Summary
26
+
27
+ The project has made significant progress this quarter. Key highlights include:
28
+
29
+ - Completed the new authentication system
30
+ - Migrated 85% of users to the new platform
31
+ - Reduced API response time by 40%
32
+
33
+ ## Technical Details
34
+
35
+ The refactoring effort focused on three main areas:
36
+
37
+ 1. **Database optimization** - Indexed frequently queried columns
38
+ 2. **Caching layer** - Added Redis for session management
39
+ 3. **Code cleanup** - Removed deprecated endpoints
40
+
41
+ ## Next Steps
42
+
43
+ We will continue with Phase 2 in the upcoming sprint. The team should prioritize:
44
+
45
+ - Finishing the remaining user migrations
46
+ - Implementing the new dashboard
47
+ - Writing integration tests
48
+
49
+ ---
50
+
51
+ *Last updated: January 20, 2024*`}
52
+ metadata={
53
+ <Detail.Metadata>
54
+ {/* Header label (title only, no text) */}
55
+ <Detail.Metadata.Label title="Basic Information" />
56
+
57
+ {/* Short values - row layout */}
58
+ <Detail.Metadata.Label title="Name" text="Alice Johnson" />
59
+ <Detail.Metadata.Label title="Role" text="Engineer" />
60
+ <Detail.Metadata.Label title="Team" text="Platform" />
61
+
62
+ <Detail.Metadata.Separator />
63
+
64
+ {/* Colored text values */}
65
+ <Detail.Metadata.Label title="Status" text={{ value: "Active", color: Color.Green }} />
66
+ <Detail.Metadata.Label title="Priority" text={{ value: "High", color: Color.Red }} />
67
+ <Detail.Metadata.Label title="Type" text={{ value: "Feature", color: Color.Blue }} />
68
+ <Detail.Metadata.Label title="Risk" text={{ value: "Medium", color: Color.Orange }} />
69
+
70
+ <Detail.Metadata.Separator />
71
+
72
+ {/* Long values - column layout */}
73
+ <Detail.Metadata.Label
74
+ title="Description"
75
+ text="This is a comprehensive metadata showcase that demonstrates all the different ways you can display information using the Detail.Metadata component."
76
+ />
77
+ <Detail.Metadata.Label
78
+ title="File Path"
79
+ text="/Users/developer/projects/termcast/src/examples/detail-metadata-showcase.tsx"
80
+ />
81
+
82
+ {/* No separator here - grouping without visual break */}
83
+ <Detail.Metadata.Label title="Author" text="Alice Johnson" />
84
+ <Detail.Metadata.Label title="Reviewer" text="Bob Smith" />
85
+
86
+ <Detail.Metadata.Separator />
87
+
88
+ {/* Links - short */}
89
+ <Detail.Metadata.Link
90
+ title="Repository"
91
+ target="https://github.com/example/repo"
92
+ text="github.com/example"
93
+ />
94
+ <Detail.Metadata.Link
95
+ title="Docs"
96
+ target="https://docs.example.com"
97
+ text="docs.example.com"
98
+ />
99
+
100
+ {/* Link - long (column layout) */}
101
+ <Detail.Metadata.Link
102
+ title="PR Link"
103
+ target="https://github.com/organization/repository/pull/12345"
104
+ text="github.com/organization/repository/pull/12345"
105
+ />
106
+
107
+ <Detail.Metadata.Separator />
108
+
109
+ {/* TagList with plain tags */}
110
+ <Detail.Metadata.TagList title="Labels">
111
+ <Detail.Metadata.TagList.Item text="documentation" />
112
+ <Detail.Metadata.TagList.Item text="enhancement" />
113
+ <Detail.Metadata.TagList.Item text="good first issue" />
114
+ </Detail.Metadata.TagList>
115
+
116
+ {/* TagList with colored tags */}
117
+ <Detail.Metadata.TagList title="Tags">
118
+ <Detail.Metadata.TagList.Item text="bug" color={Color.Red} />
119
+ <Detail.Metadata.TagList.Item text="feature" color={Color.Green} />
120
+ <Detail.Metadata.TagList.Item text="urgent" color={Color.Orange} />
121
+ <Detail.Metadata.TagList.Item text="design" color={Color.Purple} />
122
+ <Detail.Metadata.TagList.Item text="backend" color={Color.Blue} />
123
+ </Detail.Metadata.TagList>
124
+
125
+ {/* Another header without separator */}
126
+ <Detail.Metadata.Label title="Timestamps" />
127
+ <Detail.Metadata.Label title="Created" text="2024-01-15 09:30:00" />
128
+ <Detail.Metadata.Label title="Updated" text="2024-01-20 14:45:00" />
129
+ <Detail.Metadata.Label title="Due Date" text={{ value: "2024-02-01", color: Color.Yellow }} />
130
+
131
+ <Detail.Metadata.Separator />
132
+
133
+ {/* Mixed content without separators */}
134
+ <Detail.Metadata.Label title="Metrics" />
135
+ <Detail.Metadata.Label title="Comments" text="42" />
136
+ <Detail.Metadata.Label title="Reactions" text={{ value: "+127", color: Color.Green }} />
137
+ <Detail.Metadata.Label title="Views" text="1,234" />
138
+ <Detail.Metadata.TagList title="Watchers">
139
+ <Detail.Metadata.TagList.Item text="@alice" color={Color.Magenta} />
140
+ <Detail.Metadata.TagList.Item text="@bob" color={Color.Magenta} />
141
+ <Detail.Metadata.TagList.Item text="@charlie" color={Color.Magenta} />
142
+ </Detail.Metadata.TagList>
143
+ </Detail.Metadata>
144
+ }
145
+ />
146
+ )
147
+ }
148
+
149
+ await renderWithProviders(<DetailMetadataShowcase />)
@@ -0,0 +1,549 @@
1
+ /**
2
+ * E2E tests for Detail.Metadata showcase demonstrating all metadata variations:
3
+ * - Row vs column layouts based on text length
4
+ * - Colored text values
5
+ * - Header labels (title only)
6
+ * - Separators between groups
7
+ * - Links with underlines
8
+ * - TagLists with colored tags
9
+ */
10
+
11
+ import { test, expect, afterEach, beforeEach } from 'vitest'
12
+ import { launchTerminal, Session } from 'tuistory/src'
13
+
14
+ let session: Session
15
+
16
+ beforeEach(async () => {
17
+ session = await launchTerminal({
18
+ command: 'bun',
19
+ args: ['src/examples/detail-metadata-showcase.tsx'],
20
+ cols: 100,
21
+ rows: 120,
22
+ })
23
+ })
24
+
25
+ afterEach(() => {
26
+ session?.close()
27
+ })
28
+
29
+ test('detail metadata showcase renders markdown and metadata together', async () => {
30
+ const snapshot = await session.text({
31
+ waitFor: (text) => {
32
+ return (
33
+ text.includes('Project Update') &&
34
+ text.includes('Basic Information') &&
35
+ text.includes('Alice Johnson') &&
36
+ text.includes('Watchers')
37
+ )
38
+ },
39
+ timeout: 20000,
40
+ })
41
+
42
+ expect(snapshot).toMatchInlineSnapshot(`
43
+ "
44
+
45
+
46
+
47
+
48
+ Project Update: Q1 2024 Review
49
+
50
+ This detail view demonstrates markdown content alongside metadata.
51
+
52
+ ---
53
+
54
+ Summary
55
+
56
+ The project has made significant progress this quarter. Key highlights include:
57
+
58
+ - Completed the new authentication system
59
+ - Migrated 85% of users to the new platform
60
+ - Reduced API response time by 40%
61
+
62
+ Technical Details
63
+
64
+ The refactoring effort focused on three main areas:
65
+
66
+ 1. Database optimization - Indexed frequently queried columns
67
+ 2. Caching layer - Added Redis for session management
68
+ 3. Code cleanup - Removed deprecated endpoints
69
+
70
+ Next Steps
71
+
72
+ We will continue with Phase 2 in the upcoming sprint. The team should prioritize:
73
+
74
+ - Finishing the remaining user migrations
75
+ - Implementing the new dashboard
76
+ - Writing integration tests
77
+
78
+ ---
79
+
80
+ Last updated: January 20, 2024
81
+
82
+ Basic Information
83
+
84
+ Name: Alice Johnson
85
+
86
+ Role: Engineer
87
+
88
+ Team: Platform
89
+
90
+ ─────────────────────────────────────────────────────────────────────────────────────────────
91
+
92
+ Status: Active
93
+
94
+ Priority: High
95
+
96
+ Type: Feature
97
+
98
+ Risk: Medium
99
+
100
+ ─────────────────────────────────────────────────────────────────────────────────────────────
101
+
102
+ Description: This is a comprehensive metadata showcase that demonstrates all the different
103
+ ways you can display information using the Detail.Metadata component.
104
+
105
+ File Path: /Users/developer/projects/termcast/src/examples/detail-metadata-showcase.tsx
106
+
107
+ Author: Alice Johnson
108
+
109
+ Reviewer: Bob Smith
110
+
111
+ ─────────────────────────────────────────────────────────────────────────────────────────────
112
+
113
+ Repository: github.com/example
114
+
115
+ Docs: docs.example.com
116
+
117
+ PR Link: github.com/organization/repository/pull/12345
118
+
119
+ ─────────────────────────────────────────────────────────────────────────────────────────────
120
+
121
+ Labels: documentation enhancement good first issue
122
+
123
+ Tags: bug feature urgent design backend
124
+
125
+ Timestamps
126
+
127
+ Created: 2024-01-15 09:30:00
128
+
129
+ Updated: 2024-01-20 14:45:00
130
+
131
+ Due Date: 2024-02-01
132
+
133
+ ─────────────────────────────────────────────────────────────────────────────────────────────
134
+
135
+ Metrics
136
+
137
+ Comments: 42
138
+
139
+ Reactions: +127
140
+
141
+ Views: 1,234
142
+
143
+ Watchers: @alice @bob @charlie
144
+
145
+
146
+
147
+ esc go back powered by termcast
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ "
164
+ `)
165
+
166
+ // Markdown content
167
+ expect(snapshot).toContain('Project Update')
168
+ expect(snapshot).toContain('Summary')
169
+ expect(snapshot).toContain('Technical Details')
170
+ expect(snapshot).toContain('Next Steps')
171
+ expect(snapshot).toContain('authentication system')
172
+ expect(snapshot).toContain('Database optimization')
173
+
174
+ // Header labels
175
+ expect(snapshot).toContain('Basic Information')
176
+ expect(snapshot).toContain('Timestamps')
177
+ expect(snapshot).toContain('Metrics')
178
+
179
+ // Short value labels (row layout)
180
+ expect(snapshot).toContain('Name:')
181
+ expect(snapshot).toContain('Alice Johnson')
182
+ expect(snapshot).toContain('Role:')
183
+ expect(snapshot).toContain('Engineer')
184
+
185
+ // Separators
186
+ expect(snapshot).toContain('─')
187
+
188
+ // Links
189
+ expect(snapshot).toContain('Repository:')
190
+ expect(snapshot).toContain('github.com/example')
191
+
192
+ // TagLists
193
+ expect(snapshot).toContain('Labels:')
194
+ expect(snapshot).toContain('documentation')
195
+ expect(snapshot).toContain('Tags:')
196
+ expect(snapshot).toContain('bug')
197
+
198
+ // Watchers tag list
199
+ expect(snapshot).toContain('Watchers:')
200
+ expect(snapshot).toContain('@alice')
201
+ }, 30000)
202
+
203
+ test('detail metadata renders long values in column layout', async () => {
204
+ const snapshot = await session.text({
205
+ waitFor: (text) => text.includes('Description:') && text.includes('comprehensive'),
206
+ timeout: 15000,
207
+ })
208
+
209
+ expect(snapshot).toMatchInlineSnapshot(`
210
+ "
211
+
212
+
213
+
214
+
215
+ Project Update: Q1 2024 Review
216
+
217
+ This detail view demonstrates markdown content alongside metadata.
218
+
219
+ ---
220
+
221
+ Summary
222
+
223
+ The project has made significant progress this quarter. Key highlights include:
224
+
225
+ - Completed the new authentication system
226
+ - Migrated 85% of users to the new platform
227
+ - Reduced API response time by 40%
228
+
229
+ Technical Details
230
+
231
+ The refactoring effort focused on three main areas:
232
+
233
+ 1. Database optimization - Indexed frequently queried columns
234
+ 2. Caching layer - Added Redis for session management
235
+ 3. Code cleanup - Removed deprecated endpoints
236
+
237
+ Next Steps
238
+
239
+ We will continue with Phase 2 in the upcoming sprint. The team should prioritize:
240
+
241
+ - Finishing the remaining user migrations
242
+ - Implementing the new dashboard
243
+ - Writing integration tests
244
+
245
+ ---
246
+
247
+ Last updated: January 20, 2024
248
+
249
+ Basic Information
250
+
251
+ Name: Alice Johnson
252
+
253
+ Role: Engineer
254
+
255
+ Team: Platform
256
+
257
+ ─────────────────────────────────────────────────────────────────────────────────────────────
258
+
259
+ Status: Active
260
+
261
+ Priority: High
262
+
263
+ Type: Feature
264
+
265
+ Risk: Medium
266
+
267
+ ─────────────────────────────────────────────────────────────────────────────────────────────
268
+
269
+ Description: This is a comprehensive metadata showcase that demonstrates all the different
270
+ ways you can display information using the Detail.Metadata component.
271
+
272
+ File Path: /Users/developer/projects/termcast/src/examples/detail-metadata-showcase.tsx
273
+
274
+ Author: Alice Johnson
275
+
276
+ Reviewer: Bob Smith
277
+
278
+ ─────────────────────────────────────────────────────────────────────────────────────────────
279
+
280
+ Repository: github.com/example
281
+
282
+ Docs: docs.example.com
283
+
284
+ PR Link: github.com/organization/repository/pull/12345
285
+
286
+ ─────────────────────────────────────────────────────────────────────────────────────────────
287
+
288
+ Labels: documentation enhancement good first issue
289
+
290
+ Tags: bug feature urgent design backend
291
+
292
+ Timestamps
293
+
294
+ Created: 2024-01-15 09:30:00
295
+
296
+ Updated: 2024-01-20 14:45:00
297
+
298
+ Due Date: 2024-02-01
299
+
300
+ ─────────────────────────────────────────────────────────────────────────────────────────────
301
+
302
+ Metrics
303
+
304
+ Comments: 42
305
+
306
+ Reactions: +127
307
+
308
+ Views: 1,234
309
+
310
+ Watchers: @alice @bob @charlie
311
+
312
+
313
+
314
+ esc go back powered by termcast
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+ "
331
+ `)
332
+
333
+ // Long description should wrap to column layout
334
+ expect(snapshot).toContain('Description:')
335
+ expect(snapshot).toContain('comprehensive metadata showcase')
336
+
337
+ // Long file path
338
+ expect(snapshot).toContain('File Path:')
339
+ expect(snapshot).toContain('/Users/developer/projects')
340
+
341
+ // Long PR link
342
+ expect(snapshot).toContain('PR Link:')
343
+ expect(snapshot).toContain('github.com/organization/repository')
344
+ }, 30000)
345
+
346
+ test('detail metadata renders links', async () => {
347
+ const snapshot = await session.text({
348
+ waitFor: (text) => text.includes('Repository:') && text.includes('github.com/example'),
349
+ timeout: 15000,
350
+ })
351
+
352
+ // Links are rendered with their text values
353
+ expect(snapshot).toContain('Repository:')
354
+ expect(snapshot).toContain('github.com/example')
355
+ expect(snapshot).toContain('Docs:')
356
+ expect(snapshot).toContain('docs.example.com')
357
+ expect(snapshot).toContain('PR Link:')
358
+ expect(snapshot).toContain('github.com/organization/repository/pull/12345')
359
+ }, 30000)
360
+
361
+ test('detail metadata renders separators between groups', async () => {
362
+ const snapshot = await session.text({
363
+ waitFor: (text) => text.includes('Basic Information') && text.includes('Metrics'),
364
+ timeout: 15000,
365
+ })
366
+
367
+ // Count separator lines (groups of ─ characters)
368
+ const separatorMatches = snapshot.match(/─{20,}/g)
369
+
370
+ // We have 5 separators in the showcase
371
+ expect(separatorMatches).toBeTruthy()
372
+ expect(separatorMatches!.length).toBeGreaterThanOrEqual(5)
373
+ }, 30000)
374
+
375
+ test('detail metadata renders tag lists with multiple items', async () => {
376
+ const snapshot = await session.text({
377
+ waitFor: (text) => text.includes('Labels:') && text.includes('Watchers:'),
378
+ timeout: 15000,
379
+ })
380
+
381
+ expect(snapshot).toMatchInlineSnapshot(`
382
+ "
383
+
384
+
385
+
386
+
387
+ Project Update: Q1 2024 Review
388
+
389
+ This detail view demonstrates markdown content alongside metadata.
390
+
391
+ ---
392
+
393
+ Summary
394
+
395
+ The project has made significant progress this quarter. Key highlights include:
396
+
397
+ - Completed the new authentication system
398
+ - Migrated 85% of users to the new platform
399
+ - Reduced API response time by 40%
400
+
401
+ Technical Details
402
+
403
+ The refactoring effort focused on three main areas:
404
+
405
+ 1. Database optimization - Indexed frequently queried columns
406
+ 2. Caching layer - Added Redis for session management
407
+ 3. Code cleanup - Removed deprecated endpoints
408
+
409
+ Next Steps
410
+
411
+ We will continue with Phase 2 in the upcoming sprint. The team should prioritize:
412
+
413
+ - Finishing the remaining user migrations
414
+ - Implementing the new dashboard
415
+ - Writing integration tests
416
+
417
+ ---
418
+
419
+ Last updated: January 20, 2024
420
+
421
+ Basic Information
422
+
423
+ Name: Alice Johnson
424
+
425
+ Role: Engineer
426
+
427
+ Team: Platform
428
+
429
+ ─────────────────────────────────────────────────────────────────────────────────────────────
430
+
431
+ Status: Active
432
+
433
+ Priority: High
434
+
435
+ Type: Feature
436
+
437
+ Risk: Medium
438
+
439
+ ─────────────────────────────────────────────────────────────────────────────────────────────
440
+
441
+ Description: This is a comprehensive metadata showcase that demonstrates all the different
442
+ ways you can display information using the Detail.Metadata component.
443
+
444
+ File Path: /Users/developer/projects/termcast/src/examples/detail-metadata-showcase.tsx
445
+
446
+ Author: Alice Johnson
447
+
448
+ Reviewer: Bob Smith
449
+
450
+ ─────────────────────────────────────────────────────────────────────────────────────────────
451
+
452
+ Repository: github.com/example
453
+
454
+ Docs: docs.example.com
455
+
456
+ PR Link: github.com/organization/repository/pull/12345
457
+
458
+ ─────────────────────────────────────────────────────────────────────────────────────────────
459
+
460
+ Labels: documentation enhancement good first issue
461
+
462
+ Tags: bug feature urgent design backend
463
+
464
+ Timestamps
465
+
466
+ Created: 2024-01-15 09:30:00
467
+
468
+ Updated: 2024-01-20 14:45:00
469
+
470
+ Due Date: 2024-02-01
471
+
472
+ ─────────────────────────────────────────────────────────────────────────────────────────────
473
+
474
+ Metrics
475
+
476
+ Comments: 42
477
+
478
+ Reactions: +127
479
+
480
+ Views: 1,234
481
+
482
+ Watchers: @alice @bob @charlie
483
+
484
+
485
+
486
+ esc go back powered by termcast
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+ "
503
+ `)
504
+
505
+ // Labels tag list
506
+ expect(snapshot).toContain('Labels:')
507
+ expect(snapshot).toContain('documentation')
508
+ expect(snapshot).toContain('enhancement')
509
+ expect(snapshot).toContain('good first issue')
510
+
511
+ // Tags tag list with colors
512
+ expect(snapshot).toContain('Tags:')
513
+ expect(snapshot).toContain('bug')
514
+ expect(snapshot).toContain('feature')
515
+ expect(snapshot).toContain('urgent')
516
+ expect(snapshot).toContain('design')
517
+ expect(snapshot).toContain('backend')
518
+
519
+ // Watchers tag list
520
+ expect(snapshot).toContain('Watchers:')
521
+ expect(snapshot).toContain('@alice')
522
+ expect(snapshot).toContain('@bob')
523
+ expect(snapshot).toContain('@charlie')
524
+ }, 30000)
525
+
526
+ test('detail metadata renders colored text values', async () => {
527
+ const snapshot = await session.text({
528
+ waitFor: (text) => text.includes('Status') && text.includes('Active') && text.includes('+127'),
529
+ timeout: 15000,
530
+ })
531
+
532
+ // Verify colored values are present in output
533
+ expect(snapshot).toContain('Active')
534
+ expect(snapshot).toContain('High')
535
+ expect(snapshot).toContain('Feature')
536
+ expect(snapshot).toContain('Medium')
537
+ expect(snapshot).toContain('+127')
538
+ expect(snapshot).toContain('2024-02-01')
539
+
540
+ // Verify all colored tags are present
541
+ expect(snapshot).toContain('bug')
542
+ expect(snapshot).toContain('feature')
543
+ expect(snapshot).toContain('urgent')
544
+ expect(snapshot).toContain('design')
545
+ expect(snapshot).toContain('backend')
546
+ expect(snapshot).toContain('@alice')
547
+ expect(snapshot).toContain('@bob')
548
+ expect(snapshot).toContain('@charlie')
549
+ }, 30000)