@@ -8,7 +8,7 @@ import { qTestingFramework } from './framework/framework'
88import sinon from 'sinon'
99import { Messenger } from './framework/messenger'
1010import { JDKVersion } from 'aws-core-vscode/codewhisperer'
11- import { GumbyController , TabsStorage } from 'aws-core-vscode/amazonqGumby'
11+ import { GumbyController , startTransformByQ , TabsStorage } from 'aws-core-vscode/amazonqGumby'
1212
1313describe ( 'Amazon Q Code Transformation' , function ( ) {
1414 let framework : qTestingFramework
@@ -49,8 +49,8 @@ describe('Amazon Q Code Transformation', function () {
4949 } )
5050
5151 describe ( 'Starting a transformation from chat' , ( ) => {
52- it ( 'Can click through all user input forms' , async ( ) => {
53- tab . addChatMessage ( { command : '/transform' } )
52+ it ( 'Can click through all user input forms for a Java upgrade ' , async ( ) => {
53+ sinon . stub ( startTransformByQ , 'getValidSQLConversionCandidateProjects' ) . resolves ( [ ] )
5454 sinon . stub ( GumbyController . prototype , 'validateLanguageUpgradeProjects' as keyof GumbyController ) . resolves ( [
5555 {
5656 name : 'qct-sample-java-8-app-main' ,
@@ -59,6 +59,8 @@ describe('Amazon Q Code Transformation', function () {
5959 } ,
6060 ] )
6161
62+ tab . addChatMessage ( { command : '/transform' } )
63+
6264 // wait for /transform to respond with some intro messages and the first user input form
6365 await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 3 , {
6466 waitTimeoutInMs : 5000 ,
@@ -141,5 +143,128 @@ describe('Amazon Q Code Transformation', function () {
141143 // this 'Sorry' message is OK - just making sure that the UI components are working correctly
142144 assert . strictEqual ( jdkPathResponse ?. body ?. includes ( "Sorry, I couldn't locate your Java installation" ) , true )
143145 } )
146+
147+ it ( 'Can provide metadata file for a SQL conversion' , async ( ) => {
148+ sinon . stub ( startTransformByQ , 'getValidSQLConversionCandidateProjects' ) . resolves ( [
149+ {
150+ name : 'OracleExample' ,
151+ path : '/Users/alias/Desktop/OracleExample' ,
152+ JDKVersion : JDKVersion . JDK17 ,
153+ } ,
154+ ] )
155+ sinon . stub ( startTransformByQ , 'getValidLanguageUpgradeCandidateProjects' ) . resolves ( [ ] )
156+ sinon . stub ( GumbyController . prototype , 'validateSQLConversionProjects' as keyof GumbyController ) . resolves ( [
157+ {
158+ name : 'OracleExample' ,
159+ path : '/Users/alias/Desktop/OracleExample' ,
160+ JDKVersion : JDKVersion . JDK17 ,
161+ } ,
162+ ] )
163+
164+ tab . addChatMessage ( { command : '/transform' } )
165+
166+ // wait for /transform to respond with some intro messages and the first user input message
167+ await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 3 , {
168+ waitTimeoutInMs : 5000 ,
169+ waitIntervalInMs : 1000 ,
170+ } )
171+ const selectMetadataMessage = tab . getChatItems ( ) . pop ( )
172+ assert . strictEqual (
173+ selectMetadataMessage ?. body ?. includes ( 'I can convert the embedded SQL' ) ?? undefined ,
174+ true
175+ )
176+
177+ // verify that we processed the metadata file
178+ const processMetadataFileStub = sinon . stub (
179+ GumbyController . prototype ,
180+ 'processMetadataFile' as keyof GumbyController
181+ )
182+ tab . clickCustomFormButton ( {
183+ id : 'gumbySQLConversionMetadataTransformFormConfirm' ,
184+ text : 'Select metadata file' ,
185+ } )
186+ sinon . assert . calledOnce ( processMetadataFileStub )
187+ } )
188+
189+ it ( 'Can choose "language upgrade" when eligible for a Java upgrade AND SQL conversion' , async ( ) => {
190+ sinon . stub ( startTransformByQ , 'getValidSQLConversionCandidateProjects' ) . resolves ( [
191+ {
192+ name : 'OracleExample' ,
193+ path : '/Users/alias/Desktop/OracleExample' ,
194+ JDKVersion : JDKVersion . JDK17 ,
195+ } ,
196+ ] )
197+ sinon . stub ( startTransformByQ , 'getValidLanguageUpgradeCandidateProjects' ) . resolves ( [
198+ {
199+ name : 'qct-sample-java-8-app-main' ,
200+ path : '/Users/alias/Desktop/qct-sample-java-8-app-main' ,
201+ JDKVersion : JDKVersion . JDK8 ,
202+ } ,
203+ ] )
204+
205+ tab . addChatMessage ( { command : '/transform' } )
206+
207+ // wait for /transform to respond with some intro messages and a prompt asking user what they want to do
208+ await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 2 , {
209+ waitTimeoutInMs : 5000 ,
210+ waitIntervalInMs : 1000 ,
211+ } )
212+ const prompt = tab . getChatItems ( ) . pop ( )
213+ assert . strictEqual (
214+ prompt ?. body ?. includes ( 'You can enter "language upgrade" or "sql conversion"' ) ?? undefined ,
215+ true
216+ )
217+
218+ // 3 additional chat messages get sent after user enters a choice; wait for all of them
219+ tab . addChatMessage ( { prompt : 'language upgrade' } )
220+ await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 5 , {
221+ waitTimeoutInMs : 5000 ,
222+ waitIntervalInMs : 1000 ,
223+ } )
224+ const projectForm = tab . getChatItems ( ) . pop ( )
225+ assert . strictEqual ( projectForm ?. formItems ?. [ 0 ] ?. id ?? undefined , 'GumbyTransformLanguageUpgradeProjectForm' )
226+ } )
227+
228+ it ( 'Can choose "sql conversion" when eligible for a Java upgrade AND SQL conversion' , async ( ) => {
229+ sinon . stub ( startTransformByQ , 'getValidSQLConversionCandidateProjects' ) . resolves ( [
230+ {
231+ name : 'OracleExample' ,
232+ path : '/Users/alias/Desktop/OracleExample' ,
233+ JDKVersion : JDKVersion . JDK17 ,
234+ } ,
235+ ] )
236+ sinon . stub ( startTransformByQ , 'getValidLanguageUpgradeCandidateProjects' ) . resolves ( [
237+ {
238+ name : 'qct-sample-java-8-app-main' ,
239+ path : '/Users/alias/Desktop/qct-sample-java-8-app-main' ,
240+ JDKVersion : JDKVersion . JDK8 ,
241+ } ,
242+ ] )
243+
244+ tab . addChatMessage ( { command : '/transform' } )
245+
246+ // wait for /transform to respond with some intro messages and a prompt asking user what they want to do
247+ await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 2 , {
248+ waitTimeoutInMs : 5000 ,
249+ waitIntervalInMs : 1000 ,
250+ } )
251+ const prompt = tab . getChatItems ( ) . pop ( )
252+ assert . strictEqual (
253+ prompt ?. body ?. includes ( 'You can enter "language upgrade" or "sql conversion"' ) ?? undefined ,
254+ true
255+ )
256+
257+ // 3 additional chat messages get sent after user enters a choice; wait for all of them
258+ tab . addChatMessage ( { prompt : 'sql conversion' } )
259+ await tab . waitForEvent ( ( ) => tab . getChatItems ( ) . length > 5 , {
260+ waitTimeoutInMs : 5000 ,
261+ waitIntervalInMs : 1000 ,
262+ } )
263+ const selectMetadataMessage = tab . getChatItems ( ) . pop ( )
264+ assert . strictEqual (
265+ selectMetadataMessage ?. body ?. includes ( 'I can convert the embedded SQL' ) ?? undefined ,
266+ true
267+ )
268+ } )
144269 } )
145270} )
0 commit comments