55import '../utils/setup'
66import { Workbench , EditorView , InputBox , TextEditor , WebviewView , Key } from 'vscode-extension-tester'
77import { testContext } from '../utils/testContext'
8- import { sleep , expect } from '../utils/generalUtils'
9-
10- function pressShortcut ( element : any , key : string , platform : 'mac' | 'windows' , modifier : 'cmd' | 'alt' = 'cmd' ) {
11- const modifierKey = modifier === 'cmd' ? ( platform === 'mac' ? Key . META : Key . CONTROL ) : Key . ALT
12- return element . sendKeys ( modifierKey , key )
13- }
8+ import { sleep , expect , pressKey , createNewTextFile } from '../utils/generalUtils'
149
1510describe ( 'Amazon Q Inline Completion / Chat Functionality' , function ( ) {
1611 // this timeout is the general timeout for the entire test suite
@@ -25,48 +20,33 @@ describe('Amazon Q Inline Completion / Chat Functionality', function () {
2520 await webviewView . switchBack ( )
2621 workbench = testContext . workbench
2722
28- await workbench . executeCommand ( 'Create: New File...' )
29- await ( await InputBox . create ( ) ) . selectQuickPick ( 'Text File' )
30- await sleep ( 1000 )
3123 editorView = new EditorView ( )
3224 testContext . editorView = editorView
33- textEditor = ( await editorView . openEditor ( 'Untitled-1' ) ) as TextEditor
34- // or if the file we want is currently opened we can simply do
35- // editor = new TextEditor();
36- } )
3725
38- after ( async function ( ) {
39- // cleanup, delete the file contents and close the editor
40- await textEditor . clearText ( )
41- await editorView . closeAllEditors ( )
42-
43- // after, in order to not affect the other tests, we must switch back to the webview
44- await webviewView . switchToFrame ( )
26+ textEditor = await createNewTextFile ( workbench , editorView )
4527 } )
4628
47- it ( 'Inline Test' , async ( ) => {
48- // the file is currently empty, lets write something in it
49- // note the coordinates are (1, 1) for the beginning of the file
50- await textEditor . typeTextAt ( 1 , 1 , 'hello' )
29+ // after(async function () {
30+ // await editorView.closeAllEditors()
31+ // })
5132
52- // now we can check if the text is correct
33+ it ( 'Inline Test' , async ( ) => {
34+ await textEditor . typeTextAt ( 1 , 1 , 'Select Me' )
5335 const text = await textEditor . getText ( )
54- expect ( text ) . equals ( 'hello' )
36+ expect ( text ) . equals ( 'Select Me' )
37+ await textEditor . clearText ( )
5538
39+ await workbench . executeCommand ( 'Amazon Q: Inline Chat' )
40+ const input = new InputBox ( )
41+ await input . sendKeys ( 'Write a simple sentece' )
42+ await input . sendKeys ( Key . ENTER )
43+ await sleep ( 5000 )
44+ const driver = textEditor . getDriver ( )
45+ await pressKey ( driver , 'Enter' )
46+ await sleep ( 3000 )
47+ await pressKey ( driver , 'Tab' )
5648 // we can also replace all the text with whatever we want
57- await textEditor . setText ( `line1\nline2\nline3` )
58- // assert how many lines there are now
59- expect ( await textEditor . getNumberOfLines ( ) ) . equals ( 3 )
60-
61- // get text at the line with given number
62- const line = await textEditor . getTextAtLine ( 2 )
63- expect ( line ) . include ( 'line2' )
64-
65- // get the line number of a search string
66- const lineNum = await textEditor . getLineOfText ( '3' )
67- expect ( lineNum ) . equals ( 3 )
68-
69- // the editor should be dirty since we haven't saved yet
70- expect ( await textEditor . isDirty ( ) ) . is . true
49+ await sleep ( 3000 )
50+ // await textEditor.clear()
7151 } )
7252} )
0 commit comments