@@ -17,30 +17,30 @@ import {createTarget, describeWithLocale} from '../../testing/EnvironmentHelpers
1717import { describeWithMockConnection } from '../../testing/MockConnection.js' ;
1818import { MockProtocolBackend } from '../../testing/MockScopeChain.js' ;
1919
20- import * as Explain from './explain .js' ;
20+ import * as Console from './console .js' ;
2121
2222const { urlString} = Platform . DevToolsPath ;
2323
2424describeWithLocale ( 'PromptBuilder' , ( ) => {
2525 describe ( 'allowHeader' , ( ) => {
2626 it ( 'disallows cookie headers' , ( ) => {
27- assert . isNotOk ( Explain . allowHeader ( { name : 'Cookie' , value : '' } ) ) ;
28- assert . isNotOk ( Explain . allowHeader ( { name : 'cookiE' , value : '' } ) ) ;
29- assert . isNotOk ( Explain . allowHeader ( { name : 'cookie' , value : '' } ) ) ;
30- assert . isNotOk ( Explain . allowHeader ( { name : 'set-cookie' , value : '' } ) ) ;
31- assert . isNotOk ( Explain . allowHeader ( { name : 'Set-cOokie' , value : '' } ) ) ;
27+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'Cookie' , value : '' } ) ) ;
28+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'cookiE' , value : '' } ) ) ;
29+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'cookie' , value : '' } ) ) ;
30+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'set-cookie' , value : '' } ) ) ;
31+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'Set-cOokie' , value : '' } ) ) ;
3232 } ) ;
3333
3434 it ( 'disallows authorization headers' , ( ) => {
35- assert . isNotOk ( Explain . allowHeader ( { name : 'AuthoRization' , value : '' } ) ) ;
36- assert . isNotOk ( Explain . allowHeader ( { name : 'authorization' , value : '' } ) ) ;
35+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'AuthoRization' , value : '' } ) ) ;
36+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'authorization' , value : '' } ) ) ;
3737 } ) ;
3838
3939 it ( 'disallows custom headers' , ( ) => {
40- assert . isNotOk ( Explain . allowHeader ( { name : 'X-smth' , value : '' } ) ) ;
41- assert . isNotOk ( Explain . allowHeader ( { name : 'X-' , value : '' } ) ) ;
42- assert . isNotOk ( Explain . allowHeader ( { name : 'x-smth' , value : '' } ) ) ;
43- assert . isNotOk ( Explain . allowHeader ( { name : 'x-' , value : '' } ) ) ;
40+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'X-smth' , value : '' } ) ) ;
41+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'X-' , value : '' } ) ) ;
42+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'x-smth' , value : '' } ) ) ;
43+ assert . isNotOk ( Console . PromptBuilder . allowHeader ( { name : 'x-' , value : '' } ) ) ;
4444 } ) ;
4545 } ) ;
4646
@@ -64,7 +64,7 @@ describeWithLocale('PromptBuilder', () => {
6464
6565 describe ( 'format formatNetworkRequest' , ( ) => {
6666 it ( 'formats a network request' , ( ) => {
67- assert . strictEqual ( Explain . formatNetworkRequest ( NETWORK_REQUEST ) , `Request: https://example.com
67+ assert . strictEqual ( Console . PromptBuilder . formatNetworkRequest ( NETWORK_REQUEST ) , `Request: https://example.com
6868
6969Request headers:
7070Origin: https://example.com
@@ -79,7 +79,7 @@ Response status: 404 Not found`);
7979 describe ( 'formatRelatedCode' , ( ) => {
8080 it ( 'formats a single line code' , ( ) => {
8181 assert . strictEqual (
82- Explain . formatRelatedCode (
82+ Console . PromptBuilder . formatRelatedCode (
8383 {
8484 text : '12345678901234567890' ,
8585 columnNumber : 10 ,
@@ -88,7 +88,7 @@ Response status: 404 Not found`);
8888 /* maxLength=*/ 5 ) ,
8989 '89012' ) ;
9090 assert . strictEqual (
91- Explain . formatRelatedCode (
91+ Console . PromptBuilder . formatRelatedCode (
9292 {
9393 text : '12345678901234567890' ,
9494 columnNumber : 10 ,
@@ -97,7 +97,7 @@ Response status: 404 Not found`);
9797 /* maxLength=*/ 6 ) ,
9898 '890123' ) ;
9999 assert . strictEqual (
100- Explain . formatRelatedCode (
100+ Console . PromptBuilder . formatRelatedCode (
101101 {
102102 text : '12345678901234567890' ,
103103 columnNumber : 10 ,
@@ -109,7 +109,7 @@ Response status: 404 Not found`);
109109
110110 it ( 'formats a multiline code' , ( ) => {
111111 assert . strictEqual (
112- Explain . formatRelatedCode (
112+ Console . PromptBuilder . formatRelatedCode (
113113 {
114114 text : '123\n456\n789\n123\n456\n789\n' ,
115115 columnNumber : 1 ,
@@ -118,7 +118,7 @@ Response status: 404 Not found`);
118118 /* maxLength=*/ 5 ) ,
119119 '456' ) ;
120120 assert . strictEqual (
121- Explain . formatRelatedCode (
121+ Console . PromptBuilder . formatRelatedCode (
122122 {
123123 text : '123\n456\n789\n123\n456\n789\n' ,
124124 columnNumber : 1 ,
@@ -127,7 +127,7 @@ Response status: 404 Not found`);
127127 /* maxLength=*/ 10 ) ,
128128 '456\n789\n123' ) ;
129129 assert . strictEqual (
130- Explain . formatRelatedCode (
130+ Console . PromptBuilder . formatRelatedCode (
131131 {
132132 text : '123\n456\n789\n123\n456\n789\n' ,
133133 columnNumber : 1 ,
@@ -172,38 +172,38 @@ function bigger() {
172172export const y = "";
173173` ;
174174 assert . strictEqual (
175- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 233 ) ,
175+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 233 ) ,
176176 ' // x\n if (true) {\n // y\n\n // zzzzzz\n }\n\n let y = x + 2;\n\n if (false) {\n // a\n\n f1();\n if (x == x) {\n // z\n }\n }' ,
177177 ) ;
178178 assert . strictEqual (
179- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 232 ) ,
179+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 232 ) ,
180180 ' // x\n if (true) {\n // y\n\n // zzzzzz\n }\n\n let y = x + 2;' ,
181181 ) ;
182182 assert . strictEqual (
183- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 600 ) ,
183+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 600 ) ,
184184 text . trim ( ) ,
185185 ) ;
186186 assert . strictEqual (
187- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 50 ) ,
187+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 50 ) ,
188188 ' // x\n if (true) {\n // y\n\n // zzzzzz\n }' ,
189189 ) ;
190190 assert . strictEqual (
191- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 40 ) ,
191+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 11 } , /* maxLength=*/ 40 ) ,
192192 ' // x' ,
193193 ) ;
194194 assert . strictEqual (
195- Explain . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 18 } , /* maxLength=*/ 50 ) ,
195+ Console . PromptBuilder . formatRelatedCode ( { text, columnNumber : 4 , lineNumber : 18 } , /* maxLength=*/ 50 ) ,
196196 ' let y = x + 2;' ,
197197 ) ;
198198 } ) ;
199199 } ) ;
200200
201201 it ( 'Extracts expected whitespace from beginnings of lines' , ( ) => {
202- assert . strictEqual ( Explain . lineWhitespace ( ' a' ) , ' ' ) ;
203- assert . strictEqual ( Explain . lineWhitespace ( 'a' ) , '' ) ;
204- assert . isNull ( Explain . lineWhitespace ( ' ' ) ) ;
205- assert . isNull ( Explain . lineWhitespace ( '' ) ) ;
206- assert . strictEqual ( Explain . lineWhitespace ( '\t\ta' ) , '\t\t' ) ;
202+ assert . strictEqual ( Console . PromptBuilder . lineWhitespace ( ' a' ) , ' ' ) ;
203+ assert . strictEqual ( Console . PromptBuilder . lineWhitespace ( 'a' ) , '' ) ;
204+ assert . isNull ( Console . PromptBuilder . lineWhitespace ( ' ' ) ) ;
205+ assert . isNull ( Console . PromptBuilder . lineWhitespace ( '' ) ) ;
206+ assert . strictEqual ( Console . PromptBuilder . lineWhitespace ( '\t\ta' ) , '\t\t' ) ;
207207 } ) ;
208208
209209 describeWithMockConnection ( 'buildPrompt' , ( ) => {
@@ -239,7 +239,7 @@ export const y = "";
239239 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
240240 messageDetails ) ;
241241 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
242- const promptBuilder = new Explain . PromptBuilder ( message ) ;
242+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
243243 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
244244 assert . strictEqual ( prompt , [
245245 PROMPT_PREFIX ,
@@ -276,7 +276,7 @@ export const y = "";
276276 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
277277 messageDetails ) ;
278278 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
279- const promptBuilder = new Explain . PromptBuilder ( message ) ;
279+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
280280 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
281281 assert . strictEqual ( prompt , [
282282 PROMPT_PREFIX ,
@@ -321,7 +321,7 @@ export const y = "";
321321 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , Protocol . Log . LogEntryLevel . Error ,
322322 ERROR_MESSAGE , messageDetails ) ;
323323 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
324- const promptBuilder = new Explain . PromptBuilder ( message ) ;
324+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
325325 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
326326 assert . strictEqual ( prompt , [
327327 PROMPT_PREFIX ,
@@ -388,7 +388,7 @@ export const y = "";
388388 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
389389 messageDetails ) ;
390390 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
391- const promptBuilder = new Explain . PromptBuilder ( message ) ;
391+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
392392 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
393393 assert . strictEqual ( prompt , [
394394 PROMPT_PREFIX ,
@@ -418,7 +418,7 @@ export const y = "";
418418 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
419419 messageDetails ) ;
420420 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
421- const promptBuilder = new Explain . PromptBuilder ( message ) ;
421+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
422422 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
423423 assert . strictEqual ( prompt , [
424424 PROMPT_PREFIX ,
@@ -453,7 +453,7 @@ export const y = "";
453453 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , Protocol . Log . LogEntryLevel . Error ,
454454 ERROR_MESSAGE , messageDetails ) ;
455455 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
456- const promptBuilder = new Explain . PromptBuilder ( message ) ;
456+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
457457 const { prompt, sources} = await promptBuilder . buildPrompt ( ) ;
458458 assert . strictEqual ( prompt , [
459459 PROMPT_PREFIX ,
@@ -504,7 +504,7 @@ export const y = "";
504504 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
505505 messageDetails ) ;
506506 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
507- const promptBuilder = new Explain . PromptBuilder ( message ) ;
507+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
508508 const { prompt, sources, isPageReloadRecommended} = await promptBuilder . buildPrompt ( ) ;
509509 assert . strictEqual ( prompt , [
510510 PROMPT_PREFIX ,
@@ -539,10 +539,10 @@ export const y = "";
539539 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , /* level */ null , ERROR_MESSAGE ,
540540 messageDetails ) ;
541541 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
542- const promptBuilder = new Explain . PromptBuilder ( message ) ;
542+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
543543 const { sources, isPageReloadRecommended} = await promptBuilder . buildPrompt ( ) ;
544544 assert . isTrue ( isPageReloadRecommended , 'PromptBuilder did not recommend reloading the page' ) ;
545- assert . isNotTrue ( sources . some ( source => source . type === Explain . SourceType . NETWORK_REQUEST ) ) ;
545+ assert . isNotTrue ( sources . some ( source => source . type === Console . PromptBuilder . SourceType . NETWORK_REQUEST ) ) ;
546546 } ) ;
547547
548548 } ) ;
@@ -564,7 +564,7 @@ export const y = "";
564564 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , Protocol . Log . LogEntryLevel . Error ,
565565 ERROR_MESSAGE , messageDetails ) ;
566566 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
567- const promptBuilder = new Explain . PromptBuilder ( message ) ;
567+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
568568 const query = await promptBuilder . getSearchQuery ( ) ;
569569 assert . strictEqual ( query , 'kaboom!' ) ;
570570 } ) ;
@@ -579,7 +579,7 @@ export const y = "";
579579 runtimeModel , Common . Console . FrontendMessageSource . ConsoleAPI , Protocol . Log . LogEntryLevel . Error ,
580580 ERROR_MESSAGE , messageDetails ) ;
581581 const { message} = createConsoleViewMessageWithStubDeps ( rawMessage ) ;
582- const promptBuilder = new Explain . PromptBuilder ( message ) ;
582+ const promptBuilder = new Console . PromptBuilder . PromptBuilder ( message ) ;
583583 const query = await promptBuilder . getSearchQuery ( ) ;
584584 assert . strictEqual ( query , 'Got an error: Error: fail' ) ;
585585 } ) ;
0 commit comments