@@ -15,8 +15,14 @@ interface MockFSWatcher extends chokidar.FSWatcher {
1515jest . mock ( 'vscode' , ( ) => ( {
1616 window : {
1717 showErrorMessage : jest . fn ( ) ,
18- showInformationMessage : jest . fn ( ) ,
18+ showInformationMessage : jest . fn ( ) . mockReturnValue ( Promise . resolve ( ) ) ,
1919 createOutputChannel : jest . fn ( )
20+ } ,
21+ env : {
22+ openExternal : jest . fn ( )
23+ } ,
24+ Uri : {
25+ parse : jest . fn ( url => ( { toString : ( ) => url } ) )
2026 }
2127} ) ) ;
2228
@@ -32,8 +38,15 @@ describe('SageMaker Unified Studio Extension Tests', () => {
3238 // Reset mocks
3339 jest . resetAllMocks ( ) ;
3440
35- // Setup context
36- mockContext = { subscriptions : [ ] } as any ;
41+ // Setup context with globalState for storage
42+ mockContext = {
43+ subscriptions : [ ] ,
44+ globalState : {
45+ get : jest . fn ( ) ,
46+ update : jest . fn ( ) ,
47+ keys : jest . fn ( ) . mockReturnValue ( [ ] )
48+ }
49+ } as any ;
3750
3851 // Setup watcher
3952 mockWatcher = {
@@ -189,6 +202,59 @@ describe('SageMaker Unified Studio Extension Tests', () => {
189202 } ) ;
190203 } ) ;
191204
205+ describe ( 'Q CLI Notification Tests' , ( ) => {
206+ test ( 'should show Q CLI notification with Learn More button' , ( ) => {
207+ // Set up globalState to simulate first-time user
208+ ( mockContext . globalState . get as jest . Mock ) . mockReturnValue ( undefined ) ;
209+
210+ activate ( mockContext ) ;
211+
212+ // Verify notification is shown with correct message and button
213+ expect ( vscode . window . showInformationMessage ) . toHaveBeenCalledWith (
214+ 'The Amazon Q Command Line Interface (CLI) is installed. You can now access AI-powered assistance in your terminal.' ,
215+ { modal : false } ,
216+ { title : 'Learn More' , isCloseAffordance : false }
217+ ) ;
218+ } ) ;
219+
220+ test ( 'should open documentation when Learn More is clicked' , async ( ) => {
221+ // Set up globalState to simulate first-time user
222+ ( mockContext . globalState . get as jest . Mock ) . mockReturnValue ( undefined ) ;
223+
224+ // Mock the user clicking "Learn More"
225+ const mockSelection = { title : 'Learn More' } ;
226+ ( vscode . window . showInformationMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockSelection ) ) ;
227+
228+ activate ( mockContext ) ;
229+
230+ // Wait for the promise to resolve
231+ await new Promise ( process . nextTick ) ;
232+
233+ // Verify the documentation link is opened
234+ expect ( vscode . env . openExternal ) . toHaveBeenCalledWith (
235+ expect . objectContaining ( {
236+ toString : expect . any ( Function )
237+ } )
238+ ) ;
239+
240+ // Verify notification is marked as seen
241+ expect ( mockContext . globalState . update ) . toHaveBeenCalledWith (
242+ 'notification_seen_smus_q_cli_notification' ,
243+ true
244+ ) ;
245+ } ) ;
246+
247+ test ( 'should not show notification if already seen' , ( ) => {
248+ // Set up globalState to simulate returning user who has seen notification
249+ ( mockContext . globalState . get as jest . Mock ) . mockReturnValue ( true ) ;
250+
251+ activate ( mockContext ) ;
252+
253+ // Verify notification is not shown again
254+ expect ( vscode . window . showInformationMessage ) . not . toHaveBeenCalled ( ) ;
255+ } ) ;
256+ } ) ;
257+
192258 describe ( 'Deactivation Tests' , ( ) => {
193259 test ( 'should cleanup resources properly' , ( ) => {
194260 activate ( mockContext ) ;
@@ -198,4 +264,4 @@ describe('SageMaker Unified Studio Extension Tests', () => {
198264 expect ( mockOutputChannel . dispose ) . toHaveBeenCalled ( ) ;
199265 } ) ;
200266 } ) ;
201- } ) ;
267+ } ) ;
0 commit comments