@@ -27,15 +27,20 @@ let jsonEditor!: JSONEditor;
2727let sendRawMessageStub ! : sinon . SinonStub ;
2828
2929describeWithEnvironment ( 'ProtocolMonitor' , ( ) => {
30+ let originalSendRawMessage : typeof InspectorBackend . test . sendRawMessage ;
3031 beforeEach ( ( ) => {
31- // sendRawMessageStub = sinon.stub(InspectorBackend.test,'sendRawMessage');
3232 sendRawMessageStub = sinon . stub ( ) ;
33+ originalSendRawMessage = InspectorBackend . test . sendRawMessage ;
3334 InspectorBackend . test . sendRawMessage = sendRawMessageStub ;
3435 jsonEditor = new JSONEditor ( document . createElement ( 'div' ) ) ;
3536 view = createViewFunctionStub ( ProtocolMonitorImpl , { editorWidget : jsonEditor } ) ;
3637 protocolMonitor = new ProtocolMonitorImpl ( view ) ;
3738 } ) ;
3839
40+ afterEach ( ( ) => {
41+ InspectorBackend . test . sendRawMessage = originalSendRawMessage ;
42+ } ) ;
43+
3944 it ( 'sends commands' , async ( ) => {
4045 view . input . onCommandSubmitted (
4146 new CustomEvent ( 'submit' , { detail : '{"command":"Test.test","parameters":{"test":"test"}}' } ) ) ;
@@ -46,6 +51,14 @@ describeWithEnvironment('ProtocolMonitor', () => {
4651 assert . deepEqual ( sendRawMessageStub . getCall ( 0 ) . args [ 3 ] , '' ) ;
4752 } ) ;
4853
54+ it ( 'includes previous commands into autocomplete' , async ( ) => {
55+ view . input . onCommandSubmitted ( new CustomEvent ( 'submit' , { detail : 'Test.test1' } ) ) ;
56+ view . input . onCommandSubmitted ( new CustomEvent ( 'submit' , { detail : 'Test.test2' } ) ) ;
57+ protocolMonitor . requestUpdate ( ) ;
58+ assert . includeOrderedMembers (
59+ ( await view . nextInput ) . commandSuggestions , [ 'Test.test2' , 'Test.test1' , 'Accessibility.disable' ] ) ;
60+ } ) ;
61+
4962 it ( 'records commands' , async ( ) => {
5063 protocolMonitor . wasShown ( ) ;
5164 InspectorBackend . test . onMessageSent ?.( { domain : 'Test' , method : 'Test.test' , params : { test : 'test' } , id : 1 } , null ) ;
0 commit comments