@@ -402,35 +402,39 @@ describe('Testing AddOnStore Component', () => {
402
402
403
403
expect ( dropdownToggle . textContent ) . toBe ( 'Enabled' ) ;
404
404
} ) ;
405
+
405
406
// Add this test to AddOnStore.spec.tsx
406
407
test ( 'properly marks plugins as installed or not installed based on their IDs' , async ( ) => {
407
- // Mock the PluginHelper implementation
408
- vi . mock ( 'components/AddOn/support/services/Plugin.helper' , ( ) => ( {
409
- __esModule : true ,
410
- default : vi . fn ( ) . mockImplementation ( ( ) => ( {
411
- fetchStore : vi . fn ( ) . mockResolvedValue ( [
412
- {
413
- id : '1' , // This ID matches one in the installed plugins
414
- pluginName : 'Plugin 1' ,
415
- pluginDesc : 'Description 1' ,
416
- pluginCreatedBy : 'User 1' ,
417
- } ,
418
- {
419
- id : '2' , // This ID doesn't match any installed plugin
420
- pluginName : 'Plugin 2' ,
421
- pluginDesc : 'Description 2' ,
422
- pluginCreatedBy : 'User 2' ,
423
- } ,
424
- ] ) ,
425
- fetchInstalled : vi . fn ( ) . mockResolvedValue ( [
426
- {
427
- id : '1' , // This ID matches one of the store plugins
428
- pluginName : 'Installed Plugin 1' ,
429
- pluginDesc : 'Installed Description 1' ,
430
- pluginCreatedBy : 'User 3' ,
431
- } ,
432
- ] ) ,
433
- } ) ) ,
408
+ // Reset and configure mocks for this specific test
409
+ vi . resetAllMocks ( ) ;
410
+ const mockFetchStore = vi . fn ( ) . mockResolvedValue ( [
411
+ {
412
+ id : '1' , // This ID matches one in the installed plugins
413
+ pluginName : 'Plugin 1' ,
414
+ pluginDesc : 'Description 1' ,
415
+ pluginCreatedBy : 'User 1' ,
416
+ } ,
417
+ {
418
+ id : '2' , // This ID doesn't match any installed plugin
419
+ pluginName : 'Plugin 2' ,
420
+ pluginDesc : 'Description 2' ,
421
+ pluginCreatedBy : 'User 2' ,
422
+ } ,
423
+ ] ) ;
424
+ const mockFetchInstalled = vi . fn ( ) . mockResolvedValue ( [
425
+ {
426
+ id : '1' , // This ID matches one of the store plugins
427
+ pluginName : 'Installed Plugin 1' ,
428
+ pluginDesc : 'Installed Description 1' ,
429
+ pluginCreatedBy : 'User 3' ,
430
+ } ,
431
+ ] ) ;
432
+
433
+ // Configure the mock implementation for this test
434
+ vi . mocked ( PluginHelper ) . mockImplementation ( ( ) => ( {
435
+ fetchStore : mockFetchStore ,
436
+ fetchInstalled : mockFetchInstalled ,
437
+ generateLinks : vi . fn ( ) ,
434
438
} ) ) ;
435
439
436
440
// Create a spy on the store dispatch
0 commit comments