@tanstack/devtools 0.6.20 → 0.6.22
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/dist/chunk/{XFQ6P775.js → XF4JFOLU.js} +15 -0
- package/dist/dev.js +13 -3
- package/dist/devtools/{YM72BEIK.js → MBQPV7BO.js} +1907 -70
- package/dist/devtools/{6XAY2RKM.js → YRFZDV5N.js} +2260 -169
- package/dist/index.js +13 -3
- package/dist/server.js +9 -2
- package/package.json +6 -3
- package/src/components/source-inspector.tsx +158 -0
- package/src/context/devtools-context.tsx +24 -1
- package/src/core.tsx +15 -1
- package/src/devtools.tsx +3 -28
- package/src/styles/use-styles.ts +829 -0
- package/src/tabs/marketplace/card-utils.test.ts +219 -0
- package/src/tabs/marketplace/card-utils.ts +85 -0
- package/src/tabs/marketplace/marketplace-header.tsx +54 -0
- package/src/tabs/marketplace/plugin-card.tsx +165 -0
- package/src/tabs/marketplace/plugin-section.tsx +51 -0
- package/src/tabs/marketplace/plugin-utils.test.ts +518 -0
- package/src/tabs/marketplace/plugin-utils.ts +248 -0
- package/src/tabs/marketplace/settings-panel.tsx +41 -0
- package/src/tabs/marketplace/tag-filters.tsx +35 -0
- package/src/tabs/marketplace/types.ts +47 -0
- package/src/tabs/plugin-marketplace.tsx +346 -0
- package/src/tabs/plugin-registry.ts +222 -0
- package/src/tabs/plugins-tab.tsx +112 -65
- package/src/tabs/semver-utils.test.ts +218 -0
- package/src/tabs/semver-utils.ts +114 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
buildPluginCards,
|
|
4
|
+
detectFramework,
|
|
5
|
+
groupIntoSections,
|
|
6
|
+
isPluginRegistered,
|
|
7
|
+
} from './plugin-utils'
|
|
8
|
+
import { FRAMEWORKS } from './types'
|
|
9
|
+
import type { PluginCard } from './types'
|
|
10
|
+
import type { PackageJson } from '@tanstack/devtools-client'
|
|
11
|
+
|
|
12
|
+
describe('detectFramework', () => {
|
|
13
|
+
it('should detect React', () => {
|
|
14
|
+
const pkg: PackageJson = {
|
|
15
|
+
name: 'test-app',
|
|
16
|
+
dependencies: { react: '^18.0.0' },
|
|
17
|
+
}
|
|
18
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('react')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should detect React from react-dom', () => {
|
|
22
|
+
const pkg: PackageJson = {
|
|
23
|
+
name: 'test-app',
|
|
24
|
+
dependencies: { 'react-dom': '^18.0.0' },
|
|
25
|
+
}
|
|
26
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('react')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should detect Vue', () => {
|
|
30
|
+
const pkg: PackageJson = {
|
|
31
|
+
name: 'test-app',
|
|
32
|
+
dependencies: { vue: '^3.0.0' },
|
|
33
|
+
}
|
|
34
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('vue')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should detect Solid', () => {
|
|
38
|
+
const pkg: PackageJson = {
|
|
39
|
+
name: 'test-app',
|
|
40
|
+
dependencies: { 'solid-js': '^1.0.0' },
|
|
41
|
+
}
|
|
42
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('solid')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should detect Svelte', () => {
|
|
46
|
+
const pkg: PackageJson = {
|
|
47
|
+
name: 'test-app',
|
|
48
|
+
dependencies: { svelte: '^4.0.0' },
|
|
49
|
+
}
|
|
50
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('svelte')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should detect Angular', () => {
|
|
54
|
+
const pkg: PackageJson = {
|
|
55
|
+
name: 'test-app',
|
|
56
|
+
dependencies: { '@angular/core': '^17.0.0' },
|
|
57
|
+
}
|
|
58
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('angular')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('should check devDependencies as well', () => {
|
|
62
|
+
const pkg: PackageJson = {
|
|
63
|
+
name: 'test-app',
|
|
64
|
+
devDependencies: { react: '^18.0.0' },
|
|
65
|
+
}
|
|
66
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('react')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should return unknown when no framework is detected', () => {
|
|
70
|
+
const pkg: PackageJson = {
|
|
71
|
+
name: 'test-app',
|
|
72
|
+
dependencies: { lodash: '^4.0.0' },
|
|
73
|
+
}
|
|
74
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('unknown')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should return first matching framework if multiple are present', () => {
|
|
78
|
+
const pkg: PackageJson = {
|
|
79
|
+
name: 'test-app',
|
|
80
|
+
dependencies: {
|
|
81
|
+
react: '^18.0.0',
|
|
82
|
+
vue: '^3.0.0',
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
// Should return react since it's first in the FRAMEWORKS array
|
|
86
|
+
expect(detectFramework(pkg, FRAMEWORKS)).toBe('react')
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('isPluginRegistered', () => {
|
|
91
|
+
it('should match with custom pluginId', () => {
|
|
92
|
+
const registeredPlugins = new Set(['tanstack-query-0', 'tanstack-form-1'])
|
|
93
|
+
expect(
|
|
94
|
+
isPluginRegistered(
|
|
95
|
+
registeredPlugins,
|
|
96
|
+
'@tanstack/react-query-devtools',
|
|
97
|
+
'@tanstack/react-query-devtools',
|
|
98
|
+
'react',
|
|
99
|
+
'tanstack-query',
|
|
100
|
+
),
|
|
101
|
+
).toBe(true)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should match when pluginId is a prefix', () => {
|
|
105
|
+
const registeredPlugins = new Set(['tanstack-form-4'])
|
|
106
|
+
expect(
|
|
107
|
+
isPluginRegistered(
|
|
108
|
+
registeredPlugins,
|
|
109
|
+
'@tanstack/react-form-devtools',
|
|
110
|
+
'@tanstack/react-form-devtools',
|
|
111
|
+
'react',
|
|
112
|
+
'tanstack-form',
|
|
113
|
+
),
|
|
114
|
+
).toBe(true)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should match when pluginId is contained', () => {
|
|
118
|
+
const registeredPlugins = new Set(['my-tanstack-query-wrapper'])
|
|
119
|
+
expect(
|
|
120
|
+
isPluginRegistered(
|
|
121
|
+
registeredPlugins,
|
|
122
|
+
'@tanstack/react-query-devtools',
|
|
123
|
+
'@tanstack/react-query-devtools',
|
|
124
|
+
'react',
|
|
125
|
+
'tanstack-query',
|
|
126
|
+
),
|
|
127
|
+
).toBe(true)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('should not match when pluginId is not found', () => {
|
|
131
|
+
const registeredPlugins = new Set(['tanstack-router-0'])
|
|
132
|
+
expect(
|
|
133
|
+
isPluginRegistered(
|
|
134
|
+
registeredPlugins,
|
|
135
|
+
'@tanstack/react-query-devtools',
|
|
136
|
+
'@tanstack/react-query-devtools',
|
|
137
|
+
'react',
|
|
138
|
+
'tanstack-query',
|
|
139
|
+
),
|
|
140
|
+
).toBe(false)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should match with direct package name', () => {
|
|
144
|
+
const registeredPlugins = new Set(['@tanstack/react-query-devtools'])
|
|
145
|
+
expect(
|
|
146
|
+
isPluginRegistered(
|
|
147
|
+
registeredPlugins,
|
|
148
|
+
'@tanstack/react-query-devtools',
|
|
149
|
+
'@tanstack/react-query-devtools',
|
|
150
|
+
'react',
|
|
151
|
+
),
|
|
152
|
+
).toBe(true)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should match with plugin parts in lowercase', () => {
|
|
156
|
+
const registeredPlugins = new Set(['react-query-plugin'])
|
|
157
|
+
expect(
|
|
158
|
+
isPluginRegistered(
|
|
159
|
+
registeredPlugins,
|
|
160
|
+
'@tanstack/react-query-devtools',
|
|
161
|
+
'react-query-devtools',
|
|
162
|
+
'react',
|
|
163
|
+
),
|
|
164
|
+
).toBe(true)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('should match with framework and plugin parts', () => {
|
|
168
|
+
const registeredPlugins = new Set(['react-custom-query'])
|
|
169
|
+
expect(
|
|
170
|
+
isPluginRegistered(
|
|
171
|
+
registeredPlugins,
|
|
172
|
+
'@tanstack/react-query-devtools',
|
|
173
|
+
'query-devtools',
|
|
174
|
+
'react',
|
|
175
|
+
),
|
|
176
|
+
).toBe(true)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('should not match unrelated plugin names', () => {
|
|
180
|
+
const registeredPlugins = new Set(['vue-router'])
|
|
181
|
+
expect(
|
|
182
|
+
isPluginRegistered(
|
|
183
|
+
registeredPlugins,
|
|
184
|
+
'@tanstack/react-query-devtools',
|
|
185
|
+
'react-query-devtools',
|
|
186
|
+
'react',
|
|
187
|
+
),
|
|
188
|
+
).toBe(false)
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
describe('groupIntoSections', () => {
|
|
193
|
+
const createMockCard = (overrides: Partial<PluginCard>): PluginCard => ({
|
|
194
|
+
requiredPackageName: '@tanstack/react-query',
|
|
195
|
+
devtoolsPackage: '@tanstack/react-query-devtools',
|
|
196
|
+
framework: 'react',
|
|
197
|
+
hasPackage: false,
|
|
198
|
+
hasDevtools: false,
|
|
199
|
+
isRegistered: false,
|
|
200
|
+
actionType: 'install',
|
|
201
|
+
status: 'idle',
|
|
202
|
+
isCurrentFramework: true,
|
|
203
|
+
metadata: {
|
|
204
|
+
packageName: '@tanstack/react-query-devtools',
|
|
205
|
+
title: 'Query Devtools',
|
|
206
|
+
framework: 'react',
|
|
207
|
+
},
|
|
208
|
+
...overrides,
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('should group active plugins', () => {
|
|
212
|
+
const cards = [
|
|
213
|
+
createMockCard({
|
|
214
|
+
actionType: 'already-installed',
|
|
215
|
+
isRegistered: true,
|
|
216
|
+
metadata: {
|
|
217
|
+
packageName: 'pkg1',
|
|
218
|
+
title: 'Active Plugin',
|
|
219
|
+
framework: 'react',
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
const sections = groupIntoSections(cards)
|
|
225
|
+
|
|
226
|
+
expect(sections).toHaveLength(1)
|
|
227
|
+
expect(sections[0]?.id).toBe('active')
|
|
228
|
+
expect(sections[0]?.displayName).toBe('✓ Active Plugins')
|
|
229
|
+
expect(sections[0]?.cards).toHaveLength(1)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('should group featured plugins', () => {
|
|
233
|
+
const cards = [
|
|
234
|
+
createMockCard({
|
|
235
|
+
actionType: 'install',
|
|
236
|
+
isCurrentFramework: true,
|
|
237
|
+
metadata: {
|
|
238
|
+
packageName: 'pkg1',
|
|
239
|
+
title: 'Featured Plugin',
|
|
240
|
+
framework: 'react',
|
|
241
|
+
featured: true,
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
]
|
|
245
|
+
|
|
246
|
+
const sections = groupIntoSections(cards)
|
|
247
|
+
|
|
248
|
+
expect(sections).toHaveLength(1)
|
|
249
|
+
expect(sections[0]?.id).toBe('featured')
|
|
250
|
+
expect(sections[0]?.displayName).toBe('⭐ Featured')
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('should not include already-installed plugins in featured section', () => {
|
|
254
|
+
const cards = [
|
|
255
|
+
createMockCard({
|
|
256
|
+
actionType: 'already-installed',
|
|
257
|
+
isRegistered: true,
|
|
258
|
+
metadata: {
|
|
259
|
+
packageName: 'pkg1',
|
|
260
|
+
title: 'Active Featured',
|
|
261
|
+
framework: 'react',
|
|
262
|
+
featured: true,
|
|
263
|
+
},
|
|
264
|
+
}),
|
|
265
|
+
]
|
|
266
|
+
|
|
267
|
+
const sections = groupIntoSections(cards)
|
|
268
|
+
|
|
269
|
+
expect(sections).toHaveLength(1)
|
|
270
|
+
expect(sections[0]?.id).toBe('active')
|
|
271
|
+
expect(sections.find((s) => s.id === 'featured')).toBeUndefined()
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
it('should group available plugins', () => {
|
|
275
|
+
const cards = [
|
|
276
|
+
createMockCard({
|
|
277
|
+
actionType: 'install',
|
|
278
|
+
isCurrentFramework: true,
|
|
279
|
+
metadata: {
|
|
280
|
+
packageName: 'pkg1',
|
|
281
|
+
title: 'Available Plugin',
|
|
282
|
+
framework: 'react',
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
const sections = groupIntoSections(cards)
|
|
288
|
+
|
|
289
|
+
expect(sections).toHaveLength(1)
|
|
290
|
+
expect(sections[0]?.id).toBe('available')
|
|
291
|
+
expect(sections[0]?.displayName).toBe('Available Plugins')
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('should not include featured plugins in available section', () => {
|
|
295
|
+
const cards = [
|
|
296
|
+
createMockCard({
|
|
297
|
+
actionType: 'install',
|
|
298
|
+
isCurrentFramework: true,
|
|
299
|
+
metadata: {
|
|
300
|
+
packageName: 'pkg1',
|
|
301
|
+
title: 'Featured Plugin',
|
|
302
|
+
framework: 'react',
|
|
303
|
+
featured: true,
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
const sections = groupIntoSections(cards)
|
|
309
|
+
|
|
310
|
+
expect(sections.find((s) => s.id === 'available')).toBeUndefined()
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('should create all three sections when appropriate', () => {
|
|
314
|
+
const cards = [
|
|
315
|
+
createMockCard({
|
|
316
|
+
actionType: 'already-installed',
|
|
317
|
+
isRegistered: true,
|
|
318
|
+
metadata: {
|
|
319
|
+
packageName: 'active',
|
|
320
|
+
title: 'Active',
|
|
321
|
+
framework: 'react',
|
|
322
|
+
},
|
|
323
|
+
}),
|
|
324
|
+
createMockCard({
|
|
325
|
+
actionType: 'install',
|
|
326
|
+
isCurrentFramework: true,
|
|
327
|
+
metadata: {
|
|
328
|
+
packageName: 'featured',
|
|
329
|
+
title: 'Featured',
|
|
330
|
+
framework: 'react',
|
|
331
|
+
featured: true,
|
|
332
|
+
},
|
|
333
|
+
}),
|
|
334
|
+
createMockCard({
|
|
335
|
+
actionType: 'install',
|
|
336
|
+
isCurrentFramework: true,
|
|
337
|
+
metadata: {
|
|
338
|
+
packageName: 'available',
|
|
339
|
+
title: 'Available',
|
|
340
|
+
framework: 'react',
|
|
341
|
+
},
|
|
342
|
+
}),
|
|
343
|
+
]
|
|
344
|
+
|
|
345
|
+
const sections = groupIntoSections(cards)
|
|
346
|
+
|
|
347
|
+
expect(sections).toHaveLength(3)
|
|
348
|
+
expect(sections[0]?.id).toBe('active')
|
|
349
|
+
expect(sections[1]?.id).toBe('featured')
|
|
350
|
+
expect(sections[2]?.id).toBe('available')
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
it('should not create sections for wrong framework plugins', () => {
|
|
354
|
+
const cards = [
|
|
355
|
+
createMockCard({
|
|
356
|
+
actionType: 'install',
|
|
357
|
+
isCurrentFramework: false,
|
|
358
|
+
metadata: {
|
|
359
|
+
packageName: 'pkg1',
|
|
360
|
+
title: 'Wrong Framework',
|
|
361
|
+
framework: 'vue',
|
|
362
|
+
},
|
|
363
|
+
}),
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
const sections = groupIntoSections(cards)
|
|
367
|
+
|
|
368
|
+
expect(sections).toHaveLength(0)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
it('should handle empty card array', () => {
|
|
372
|
+
const sections = groupIntoSections([])
|
|
373
|
+
expect(sections).toHaveLength(0)
|
|
374
|
+
})
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
describe('buildPluginCards', () => {
|
|
378
|
+
const mockPackageJson: PackageJson = {
|
|
379
|
+
name: 'test-app',
|
|
380
|
+
dependencies: {
|
|
381
|
+
'@tanstack/react-query': '^5.0.0',
|
|
382
|
+
},
|
|
383
|
+
devDependencies: {
|
|
384
|
+
'@tanstack/react-query-devtools': '^5.0.0',
|
|
385
|
+
},
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
it('should build cards for all plugins in registry', () => {
|
|
389
|
+
const cards = buildPluginCards(mockPackageJson, 'react', new Set(), [])
|
|
390
|
+
|
|
391
|
+
expect(cards.length).toBeGreaterThan(0)
|
|
392
|
+
expect(cards.every((card) => card.devtoolsPackage)).toBe(true)
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
it('should mark plugins as current framework', () => {
|
|
396
|
+
const cards = buildPluginCards(mockPackageJson, 'react', new Set(), [])
|
|
397
|
+
|
|
398
|
+
const reactPlugins = cards.filter((c) => c.framework === 'react')
|
|
399
|
+
expect(reactPlugins.every((c) => c.isCurrentFramework)).toBe(true)
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
it('should mark wrong framework plugins', () => {
|
|
403
|
+
const cards = buildPluginCards(mockPackageJson, 'vue', new Set(), [])
|
|
404
|
+
|
|
405
|
+
const reactPlugins = cards.filter((c) => c.framework === 'react')
|
|
406
|
+
expect(reactPlugins.every((c) => c.actionType === 'wrong-framework')).toBe(
|
|
407
|
+
true,
|
|
408
|
+
)
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
it('should detect already installed and registered plugins', () => {
|
|
412
|
+
const registeredPlugins = new Set(['tanstack-query'])
|
|
413
|
+
|
|
414
|
+
const cards = buildPluginCards(
|
|
415
|
+
mockPackageJson,
|
|
416
|
+
'react',
|
|
417
|
+
registeredPlugins,
|
|
418
|
+
[],
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
const queryPlugin = cards.find(
|
|
422
|
+
(c) => c.devtoolsPackage === '@tanstack/react-query-devtools',
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
expect(queryPlugin?.hasDevtools).toBe(true)
|
|
426
|
+
expect(queryPlugin?.isRegistered).toBe(true)
|
|
427
|
+
expect(queryPlugin?.actionType).toBe('already-installed')
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
it('should detect add-to-devtools action when installed but not registered', () => {
|
|
431
|
+
const cards = buildPluginCards(mockPackageJson, 'react', new Set(), [])
|
|
432
|
+
|
|
433
|
+
const queryPlugin = cards.find(
|
|
434
|
+
(c) => c.devtoolsPackage === '@tanstack/react-query-devtools',
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
expect(queryPlugin?.hasDevtools).toBe(true)
|
|
438
|
+
expect(queryPlugin?.isRegistered).toBe(false)
|
|
439
|
+
expect(queryPlugin?.actionType).toBe('add-to-devtools')
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('should detect requires-package action', () => {
|
|
443
|
+
const pkgWithoutQuery: PackageJson = {
|
|
444
|
+
name: 'test-app',
|
|
445
|
+
dependencies: {},
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const cards = buildPluginCards(pkgWithoutQuery, 'react', new Set(), [])
|
|
449
|
+
|
|
450
|
+
const queryPlugin = cards.find(
|
|
451
|
+
(c) => c.devtoolsPackage === '@tanstack/react-query-devtools',
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
expect(queryPlugin?.actionType).toBe('requires-package')
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
it('should detect install-devtools action', () => {
|
|
458
|
+
const pkgWithQuery: PackageJson = {
|
|
459
|
+
name: 'test-app',
|
|
460
|
+
dependencies: {
|
|
461
|
+
'@tanstack/react-query': '^5.0.0',
|
|
462
|
+
},
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const cards = buildPluginCards(pkgWithQuery, 'react', new Set(), [])
|
|
466
|
+
|
|
467
|
+
const queryPlugin = cards.find(
|
|
468
|
+
(c) => c.devtoolsPackage === '@tanstack/react-query-devtools',
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
expect(queryPlugin?.hasPackage).toBe(true)
|
|
472
|
+
expect(queryPlugin?.hasDevtools).toBe(false)
|
|
473
|
+
expect(queryPlugin?.actionType).toBe('install-devtools')
|
|
474
|
+
})
|
|
475
|
+
|
|
476
|
+
it('should preserve status from existing cards', () => {
|
|
477
|
+
const existingCards: Array<PluginCard> = [
|
|
478
|
+
{
|
|
479
|
+
requiredPackageName: '@tanstack/react-query',
|
|
480
|
+
devtoolsPackage: '@tanstack/react-query-devtools',
|
|
481
|
+
framework: 'react',
|
|
482
|
+
hasPackage: false,
|
|
483
|
+
hasDevtools: false,
|
|
484
|
+
isRegistered: false,
|
|
485
|
+
actionType: 'install',
|
|
486
|
+
status: 'installing',
|
|
487
|
+
isCurrentFramework: true,
|
|
488
|
+
metadata: {
|
|
489
|
+
packageName: '@tanstack/react-query-devtools',
|
|
490
|
+
title: 'Query',
|
|
491
|
+
framework: 'react',
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
]
|
|
495
|
+
|
|
496
|
+
const cards = buildPluginCards(
|
|
497
|
+
mockPackageJson,
|
|
498
|
+
'react',
|
|
499
|
+
new Set(),
|
|
500
|
+
existingCards,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
const queryPlugin = cards.find(
|
|
504
|
+
(c) => c.devtoolsPackage === '@tanstack/react-query-devtools',
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
expect(queryPlugin?.status).toBe('installing')
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
it('should handle framework-agnostic plugins', () => {
|
|
511
|
+
const cards = buildPluginCards(mockPackageJson, 'react', new Set(), [])
|
|
512
|
+
|
|
513
|
+
const otherFrameworkPlugins = cards.filter(
|
|
514
|
+
(c) => c.metadata?.framework === 'other',
|
|
515
|
+
)
|
|
516
|
+
expect(otherFrameworkPlugins.every((c) => c.isCurrentFramework)).toBe(true)
|
|
517
|
+
})
|
|
518
|
+
})
|