18
18
19
19
import '@testing-library/jest-dom/vitest' ;
20
20
21
- import { render , screen } from '@testing-library/svelte' ;
21
+ import { fireEvent , render , screen } from '@testing-library/svelte' ;
22
22
import { beforeEach , expect , test , vi } from 'vitest' ;
23
23
24
24
import { type CombinedExtensionInfoUI } from '/@/stores/all-installed-extensions' ;
@@ -104,6 +104,20 @@ const combined: CombinedExtensionInfoUI[] = [
104
104
} ,
105
105
] as unknown [ ] as CombinedExtensionInfoUI [ ] ;
106
106
107
+ const combinedWithError : CombinedExtensionInfoUI [ ] = [
108
+ {
109
+ id : 'idAInstalled' ,
110
+ displayName : 'A failed installed Extension' ,
111
+ name : 'A extension' ,
112
+ removable : true ,
113
+ state : 'failed' ,
114
+ error : {
115
+ message : 'custom error' ,
116
+ stack : 'custom stack' ,
117
+ } ,
118
+ } ,
119
+ ] as unknown [ ] as CombinedExtensionInfoUI [ ] ;
120
+
107
121
test ( 'Expect to have details page' , async ( ) => {
108
122
const extensionId = 'idAInstalled' ;
109
123
@@ -120,6 +134,37 @@ test('Expect to have details page', async () => {
120
134
121
135
const extensionBadge = screen . getByRole ( 'region' , { name : 'Extension Badge' } ) ;
122
136
expect ( extensionBadge ) . toBeInTheDocument ( ) ;
137
+
138
+ // no tabs as not failing state
139
+ const readmeTab = screen . queryByRole ( 'button' , { name : 'Readme' } ) ;
140
+ expect ( readmeTab ) . not . toBeInTheDocument ( ) ;
141
+ const errorTab = screen . queryByRole ( 'button' , { name : 'Error' } ) ;
142
+ expect ( errorTab ) . not . toBeInTheDocument ( ) ;
143
+ } ) ;
144
+
145
+ test ( 'Expect to have details page with error tab with failed state' , async ( ) => {
146
+ const extensionId = 'idAInstalled' ;
147
+
148
+ catalogExtensionInfos . set ( [ aFakeExtension ] ) ;
149
+ extensionInfos . set ( combinedWithError ) ;
150
+
151
+ await waitRender ( { extensionId } ) ;
152
+
153
+ // check that we have two tabs
154
+ const readmeTab = screen . getByRole ( 'button' , { name : 'Readme' } ) ;
155
+ expect ( readmeTab ) . toBeInTheDocument ( ) ;
156
+
157
+ // check that we have two tabs
158
+ const errorTab = screen . getByRole ( 'button' , { name : 'Error' } ) ;
159
+ expect ( errorTab ) . toBeInTheDocument ( ) ;
160
+
161
+ // click on the error tab
162
+ await fireEvent . click ( errorTab ) ;
163
+
164
+ // now check that the error is on the page
165
+ // should contain the error
166
+ const error = screen . getByText ( 'Error: custom error' ) ;
167
+ expect ( error ) . toBeInTheDocument ( ) ;
123
168
} ) ;
124
169
125
170
test ( 'Expect empty screen' , async ( ) => {
0 commit comments