Skip to content

Commit 0eebfab

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Also test protocol monitor autocomplete
Bug: none Change-Id: I88792c9561ab7950063335c9b949a7d10e6a5ae9 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6330113 Reviewed-by: Nancy Li <nancyly@chromium.org> Commit-Queue: Nancy Li <nancyly@chromium.org> Auto-Submit: Danil Somsikov <dsv@chromium.org>
1 parent a0151c2 commit 0eebfab

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎front_end/panels/protocol_monitor/ProtocolMonitor.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ let jsonEditor!: JSONEditor;
2727
let sendRawMessageStub!: sinon.SinonStub;
2828

2929
describeWithEnvironment('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

Comments
 (0)