File tree Expand file tree Collapse file tree 1 file changed +4
-17
lines changed
browser-extension/tests/lib/enhancers Expand file tree Collapse file tree 1 file changed +4
-17
lines changed Original file line number Diff line number Diff line change @@ -29,30 +29,17 @@ vi.mock('../../../src/overtype/overtype', () => {
2929
3030const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
3131
32- async function loadHtmlFromHar ( key : string ) : Promise < string > {
32+ async function loadHtmlFromHar ( key : keyof typeof PAGES ) : Promise < string > {
33+ const url = PAGES [ key ]
3334 const harPath = path . join ( __dirname , '../../har' , `${ key } .har` )
3435 const harContent = await fs . readFile ( harPath , 'utf-8' )
3536 const harData = JSON . parse ( harContent )
3637
37- const mainEntry = harData . log . entries . find (
38- ( entry : any ) =>
39- entry . request . url . includes ( 'github.com' ) &&
40- entry . response . content . mimeType ?. includes ( 'text/html' ) &&
41- entry . response . content . text ,
42- )
43-
38+ const mainEntry = harData . log . entries . find ( ( entry : any ) => entry . request . url === url )
4439 if ( ! mainEntry ) {
4540 throw new Error ( `No HTML content found in HAR file: ${ key } .har` )
4641 }
47-
48- let html = mainEntry . response . content . text
49-
50- // Check if content is base64 encoded
51- if ( mainEntry . response . content . encoding === 'base64' ) {
52- html = Buffer . from ( html , 'base64' ) . toString ( 'utf-8' )
53- }
54-
55- return html
42+ return mainEntry . response . content . text
5643}
5744
5845describe ( 'github' , ( ) => {
You can’t perform that action at this time.
0 commit comments