Skip to content

Commit e6604f6

Browse files
committed
fix types
1 parent 79c6d12 commit e6604f6

8 files changed

+93
-14
lines changed

src/notebooks/deepnote/converters/codeBlockConverter.unit.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ suite('CodeBlockConverter', () => {
4040
suite('convertToCell', () => {
4141
test('converts code block to cell', () => {
4242
const block: DeepnoteBlock = {
43+
blockGroup: 'test-group',
4344
content: 'print("hello")',
4445
id: 'block-123',
4546
sortingKey: 'a0',
@@ -55,6 +56,7 @@ suite('CodeBlockConverter', () => {
5556

5657
test('handles empty content', () => {
5758
const block: DeepnoteBlock = {
59+
blockGroup: 'test-group',
5860
content: '',
5961
id: 'block-123',
6062
sortingKey: 'a0',
@@ -80,6 +82,7 @@ suite('CodeBlockConverter', () => {
8082

8183
test('handles multi-line content', () => {
8284
const block: DeepnoteBlock = {
85+
blockGroup: 'test-group',
8386
content: 'import numpy as np\nimport pandas as pd\n\nprint("hello")',
8487
id: 'block-123',
8588
sortingKey: 'a0',
@@ -95,6 +98,7 @@ suite('CodeBlockConverter', () => {
9598
suite('applyChangesToBlock', () => {
9699
test('applies cell content to block', () => {
97100
const block: DeepnoteBlock = {
101+
blockGroup: 'test-group',
98102
content: 'old content',
99103
id: 'block-123',
100104
sortingKey: 'a0',
@@ -109,6 +113,7 @@ suite('CodeBlockConverter', () => {
109113

110114
test('handles empty cell value', () => {
111115
const block: DeepnoteBlock = {
116+
blockGroup: 'test-group',
112117
content: 'old content',
113118
id: 'block-123',
114119
sortingKey: 'a0',
@@ -123,6 +128,7 @@ suite('CodeBlockConverter', () => {
123128

124129
test('does not modify other block properties', () => {
125130
const block: DeepnoteBlock = {
131+
blockGroup: 'test-group',
126132
content: 'old content',
127133
executionCount: 5,
128134
id: 'block-123',

src/notebooks/deepnote/converters/markdownBlockConverter.unit.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ suite('MarkdownBlockConverter', () => {
4040
suite('convertToCell', () => {
4141
test('converts markdown block to cell', () => {
4242
const block: DeepnoteBlock = {
43+
blockGroup: 'test-group',
4344
content: '# Title\n\nParagraph text',
4445
id: 'block-123',
4546
sortingKey: 'a0',
@@ -55,6 +56,7 @@ suite('MarkdownBlockConverter', () => {
5556

5657
test('handles empty content', () => {
5758
const block: DeepnoteBlock = {
59+
blockGroup: 'test-group',
5860
content: '',
5961
id: 'block-123',
6062
sortingKey: 'a0',
@@ -80,6 +82,7 @@ suite('MarkdownBlockConverter', () => {
8082

8183
test('handles complex markdown', () => {
8284
const block: DeepnoteBlock = {
85+
blockGroup: 'test-group',
8386
content: '# Title\n\n## Subtitle\n\n- List item 1\n- List item 2\n\n```python\nprint("code")\n```',
8487
id: 'block-123',
8588
sortingKey: 'a0',
@@ -98,6 +101,7 @@ suite('MarkdownBlockConverter', () => {
98101
suite('applyChangesToBlock', () => {
99102
test('applies cell content to block', () => {
100103
const block: DeepnoteBlock = {
104+
blockGroup: 'test-group',
101105
content: 'old content',
102106
id: 'block-123',
103107
sortingKey: 'a0',
@@ -112,6 +116,7 @@ suite('MarkdownBlockConverter', () => {
112116

113117
test('handles empty cell value', () => {
114118
const block: DeepnoteBlock = {
119+
blockGroup: 'test-group',
115120
content: 'old content',
116121
id: 'block-123',
117122
sortingKey: 'a0',
@@ -126,6 +131,7 @@ suite('MarkdownBlockConverter', () => {
126131

127132
test('does not modify other block properties', () => {
128133
const block: DeepnoteBlock = {
134+
blockGroup: 'test-group',
129135
content: 'old content',
130136
id: 'block-123',
131137
metadata: { custom: 'value' },
@@ -145,6 +151,7 @@ suite('MarkdownBlockConverter', () => {
145151

146152
test('handles complex markdown content', () => {
147153
const block: DeepnoteBlock = {
154+
blockGroup: 'test-group',
148155
content: 'old content',
149156
id: 'block-123',
150157
sortingKey: 'a0',

src/notebooks/deepnote/deepnoteDataConverter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export class DeepnoteDataConverter {
100100

101101
private createFallbackBlock(cell: NotebookCellData, index: number): DeepnoteBlock {
102102
return {
103+
blockGroup: 'group-123',
103104
id: generateBlockId(),
104105
sortingKey: generateSortingKey(index),
105106
type: cell.kind === NotebookCellKind.Code ? 'code' : 'markdown',

src/notebooks/deepnote/deepnoteDataConverter.unit.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ suite('DeepnoteDataConverter', () => {
1515
test('converts simple code block to cell', () => {
1616
const blocks: DeepnoteBlock[] = [
1717
{
18+
blockGroup: 'test-group',
1819
id: 'block1',
1920
type: 'code',
2021
content: 'print("hello")',
@@ -38,6 +39,7 @@ suite('DeepnoteDataConverter', () => {
3839
test('converts simple markdown block to cell', () => {
3940
const blocks: DeepnoteBlock[] = [
4041
{
42+
blockGroup: 'test-group',
4143
id: 'block2',
4244
type: 'markdown',
4345
content: '# Title',
@@ -58,6 +60,7 @@ suite('DeepnoteDataConverter', () => {
5860
test('handles execution count', () => {
5961
const blocks: DeepnoteBlock[] = [
6062
{
63+
blockGroup: 'test-group',
6164
id: 'block1',
6265
type: 'code',
6366
content: 'x = 1',
@@ -74,6 +77,7 @@ suite('DeepnoteDataConverter', () => {
7477
test('converts blocks with outputs', () => {
7578
const blocks: DeepnoteBlock[] = [
7679
{
80+
blockGroup: 'test-group',
7781
id: 'block1',
7882
type: 'code',
7983
content: 'print("hello")',
@@ -211,6 +215,7 @@ suite('DeepnoteDataConverter', () => {
211215

212216
const blocks: DeepnoteBlock[] = [
213217
{
218+
blockGroup: 'test-group',
214219
id: 'block1',
215220
type: 'code',
216221
content: 'print("Hello world")',
@@ -238,6 +243,7 @@ suite('DeepnoteDataConverter', () => {
238243

239244
const blocks: DeepnoteBlock[] = [
240245
{
246+
blockGroup: 'test-group',
241247
id: 'block1',
242248
type: 'code',
243249
content: 'print(x)',
@@ -270,6 +276,7 @@ suite('DeepnoteDataConverter', () => {
270276

271277
const blocks: DeepnoteBlock[] = [
272278
{
279+
blockGroup: 'test-group',
273280
id: 'block1',
274281
type: 'code',
275282
content: 'x',
@@ -299,6 +306,7 @@ suite('DeepnoteDataConverter', () => {
299306

300307
const blocks: DeepnoteBlock[] = [
301308
{
309+
blockGroup: 'test-group',
302310
id: 'block1',
303311
type: 'code',
304312
content: 'None',
@@ -324,6 +332,7 @@ suite('DeepnoteDataConverter', () => {
324332

325333
const blocks: DeepnoteBlock[] = [
326334
{
335+
blockGroup: 'test-group',
327336
id: 'block1',
328337
type: 'code',
329338
content: 'something',
@@ -350,6 +359,7 @@ suite('DeepnoteDataConverter', () => {
350359

351360
const blocks: DeepnoteBlock[] = [
352361
{
362+
blockGroup: 'test-group',
353363
id: 'block1',
354364
type: 'code',
355365
content: 'print()',
@@ -375,6 +385,7 @@ suite('DeepnoteDataConverter', () => {
375385

376386
const blocks: DeepnoteBlock[] = [
377387
{
388+
blockGroup: 'test-group',
378389
id: 'block1',
379390
type: 'code',
380391
content: 'result',
@@ -397,6 +408,7 @@ suite('DeepnoteDataConverter', () => {
397408
test('blocks -> cells -> blocks preserves data', () => {
398409
const originalBlocks: DeepnoteBlock[] = [
399410
{
411+
blockGroup: 'test-group',
400412
id: 'block1',
401413
type: 'code',
402414
content: 'print("hello")',
@@ -412,6 +424,7 @@ suite('DeepnoteDataConverter', () => {
412424
]
413425
},
414426
{
427+
blockGroup: 'test-group',
415428
id: 'block2',
416429
type: 'markdown',
417430
content: '# Title',

src/notebooks/deepnote/deepnoteSerializer.unit.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,30 @@ suite('DeepnoteNotebookSerializer', () => {
2121
{
2222
id: 'notebook-1',
2323
name: 'First Notebook',
24-
blocks: [{ id: 'block-1', content: 'print("hello")', sortingKey: 'a0', type: 'code' }],
24+
blocks: [
25+
{
26+
blockGroup: 'group-123',
27+
id: 'block-1',
28+
content: 'print("hello")',
29+
sortingKey: 'a0',
30+
type: 'code'
31+
}
32+
],
2533
executionMode: 'python',
2634
isModule: false
2735
},
2836
{
2937
id: 'notebook-2',
3038
name: 'Second Notebook',
31-
blocks: [{ id: 'block-2', content: '# Title', sortingKey: 'a1', type: 'markdown' }],
39+
blocks: [
40+
{
41+
blockGroup: 'group-123',
42+
id: 'block-2',
43+
content: '# Title',
44+
sortingKey: 'a1',
45+
type: 'markdown'
46+
}
47+
],
3248
executionMode: 'python',
3349
isModule: false
3450
}

src/notebooks/deepnote/deepnoteTreeDataProvider.unit.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,30 @@ suite('DeepnoteTreeDataProvider', () => {
1919
{
2020
id: 'notebook-1',
2121
name: 'First Notebook',
22-
blocks: [{ id: 'block-1', content: 'print("hello")', sortingKey: 'a0', type: 'code' }],
22+
blocks: [
23+
{
24+
blockGroup: 'group-123',
25+
id: 'block-1',
26+
content: 'print("hello")',
27+
sortingKey: 'a0',
28+
type: 'code'
29+
}
30+
],
2331
executionMode: 'python',
2432
isModule: false
2533
},
2634
{
2735
id: 'notebook-2',
2836
name: 'Second Notebook',
29-
blocks: [{ id: 'block-2', content: '# Title', sortingKey: 'a0', type: 'markdown' }],
37+
blocks: [
38+
{
39+
blockGroup: 'group-123',
40+
id: 'block-2',
41+
content: '# Title',
42+
sortingKey: 'a0',
43+
type: 'markdown'
44+
}
45+
],
3046
executionMode: 'python',
3147
isModule: false
3248
}

src/notebooks/deepnote/deepnoteTreeItem.unit.test.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ suite('DeepnoteTreeItem', () => {
3030
const mockNotebook: DeepnoteNotebook = {
3131
id: 'notebook-456',
3232
name: 'Analysis Notebook',
33-
blocks: [{ id: 'block-1', content: 'print("hello")', sortingKey: 'a0', type: 'code' }],
33+
blocks: [{ blockGroup: 'group-123', id: 'block-1', content: 'print("hello")', sortingKey: 'a0', type: 'code' }],
3434
executionMode: 'python',
3535
isModule: false
3636
};
@@ -244,10 +244,34 @@ suite('DeepnoteTreeItem', () => {
244244
const notebookWithMultipleBlocks = {
245245
...mockNotebook,
246246
blocks: [
247-
{ id: 'block-1', content: 'import pandas', sortingKey: 'a0', type: 'code' as const },
248-
{ id: 'block-2', content: '# Analysis', sortingKey: 'a1', type: 'markdown' as const },
249-
{ id: 'block-3', content: 'df = pd.read_csv("data.csv")', sortingKey: 'a2', type: 'code' as const },
250-
{ id: 'block-4', content: 'print(df.head())', sortingKey: 'a3', type: 'code' as const }
247+
{
248+
blockGroup: 'group-123',
249+
id: 'block-1',
250+
content: 'import pandas',
251+
sortingKey: 'a0',
252+
type: 'code' as const
253+
},
254+
{
255+
blockGroup: 'group-123',
256+
id: 'block-2',
257+
content: '# Analysis',
258+
sortingKey: 'a1',
259+
type: 'markdown' as const
260+
},
261+
{
262+
blockGroup: 'group-123',
263+
id: 'block-3',
264+
content: 'df = pd.read_csv("data.csv")',
265+
sortingKey: 'a2',
266+
type: 'code' as const
267+
},
268+
{
269+
blockGroup: 'group-123',
270+
id: 'block-4',
271+
content: 'print(df.head())',
272+
sortingKey: 'a3',
273+
type: 'code' as const
274+
}
251275
]
252276
};
253277

src/notebooks/deepnote/pocket.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,14 @@ export function createBlockFromPocket(cell: NotebookCellData, index: number): De
5858
}
5959

6060
const block: DeepnoteBlock = {
61+
blockGroup: pocket?.blockGroup || 'default-group',
6162
content: cell.value,
6263
id: pocket?.id || generateBlockId(),
6364
metadata,
6465
sortingKey: pocket?.sortingKey || generateSortingKey(index),
6566
type: pocket?.type || 'code'
6667
};
6768

68-
// Only add optional fields if they exist
69-
if (pocket?.blockGroup) {
70-
block.blockGroup = pocket.blockGroup;
71-
}
72-
7369
if (pocket?.executionCount !== undefined) {
7470
block.executionCount = pocket.executionCount;
7571
}

0 commit comments

Comments
 (0)