From 9442ded52a1151ea39c8420b161dd748f6661a3e Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 10:17:43 -0700 Subject: [PATCH 1/6] Simplify har-view using `keyof typeof PAGES`. --- browser-extension/tests/har-view.ts | 87 ++++++++++++----------------- 1 file changed, 37 insertions(+), 50 deletions(-) diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index ac8a5a6..2ec422d 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -8,31 +8,18 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) const app = express() const PORT = 3001 -// Store HAR data -const harCache = new Map() - -// Create mapping from HAR filename to original URL -const harToUrlMap = Object.fromEntries( - Object.entries(PAGES).map(([key, url]) => [`${key}.har`, url]), -) +// Store HAR json +const harCache = new Map() // Extract URL parts for location patching -function getUrlParts(filename: string) { - const originalUrl = harToUrlMap[filename] - if (!originalUrl) { - return null - } - - try { - const url = new URL(originalUrl) - return { - host: url.host, - hostname: url.hostname, - href: originalUrl, - pathname: url.pathname, - } - } catch { - return null +function getUrlParts(key: keyof typeof PAGES) { + const originalUrl = PAGES[key] + const url = new URL(originalUrl) + return { + host: url.host, + hostname: url.hostname, + href: originalUrl, + pathname: url.pathname, } } @@ -50,15 +37,15 @@ async function checkDevServer(): Promise { } // Load and cache HAR file -async function loadHar(filename: string) { - if (harCache.has(filename)) { - return harCache.get(filename) +async function loadHar(key: keyof typeof PAGES) { + if (harCache.has(key)) { + return harCache.get(key) } - const harPath = path.join(__dirname, 'har', filename) + const harPath = path.join(__dirname, 'har', `${key}.har`) const harContent = await fs.readFile(harPath, 'utf-8') const harData = JSON.parse(harContent) - harCache.set(filename, harData) + harCache.set(key, harData) return harData } @@ -66,7 +53,7 @@ async function loadHar(filename: string) { Object.entries(PAGES).forEach(([key, url]) => { const urlObj = new URL(url) app.get(urlObj.pathname, (_req, res) => { - res.redirect(`/page/${key}.har/gitcasso`) + res.redirect(`/page/${key}/gitcasso`) }) }) @@ -94,8 +81,8 @@ app.get('/', async (_req, res) => {
  • ${basename}
    @@ -147,14 +134,14 @@ app.get('/', async (_req, res) => { }) // Serve the main HTML page from HAR -app.get('/page/:filename', async (req, res) => { +app.get('/page/:key', async (req, res) => { try { - const filename = req.params.filename - if (!filename.endsWith('.har')) { - return res.status(400).send('Invalid file type') + const key = req.params.key as keyof typeof PAGES + if (!(key in PAGES)) { + return res.status(400).send('Invalid key - not found in PAGES') } - const harData = await loadHar(filename) + const harData = await loadHar(key) // Find the main HTML response const mainEntry = harData.log.entries.find( @@ -173,7 +160,7 @@ app.get('/page/:filename', async (req, res) => { // Replace external URLs with local asset URLs html = html.replace( /https:\/\/(github\.com|assets\.github\.com|avatars\.githubusercontent\.com|user-images\.githubusercontent\.com)/g, - `/asset/${filename.replace('.har', '')}`, + `/asset/${key}`, ) return res.send(html) @@ -184,20 +171,17 @@ app.get('/page/:filename', async (req, res) => { }) // Serve the main HTML page from HAR with Gitcasso content script injected -app.get('/page/:filename/gitcasso', async (req, res) => { +app.get('/page/:key/gitcasso', async (req, res) => { try { - const filename = req.params.filename - if (!filename.endsWith('.har')) { - return res.status(400).send('Invalid file type') + const key = req.params.key as keyof typeof PAGES + if (!(key in PAGES)) { + return res.status(400).send('Invalid key - not found in PAGES') } // Get original URL parts for location patching - const urlParts = getUrlParts(filename) - if (!urlParts) { - return res.status(400).send('Unknown HAR file - not found in har-index.ts') - } + const urlParts = getUrlParts(key) - const harData = await loadHar(filename) + const harData = await loadHar(key) // Find the main HTML response const mainEntry = harData.log.entries.find( @@ -216,7 +200,7 @@ app.get('/page/:filename/gitcasso', async (req, res) => { // Replace external URLs with local asset URLs html = html.replace( /https:\/\/(github\.com|assets\.github\.com|avatars\.githubusercontent\.com|user-images\.githubusercontent\.com)/g, - `/asset/${filename.replace('.har', '')}`, + `/asset/${key}`, ) // Inject patched content script with location patching @@ -286,12 +270,15 @@ app.get('/page/:filename/gitcasso', async (req, res) => { }) // Serve assets from HAR file -app.get('/asset/:harname/*', async (req, res) => { +app.get('/asset/:key/*', async (req, res) => { try { - const harname = `${req.params.harname}.har` + const key = req.params.key as keyof typeof PAGES + if (!(key in PAGES)) { + return res.status(400).send('Invalid key - not found in PAGES') + } const assetPath = (req.params as any)[0] as string - const harData = await loadHar(harname) + const harData = await loadHar(key) // Find matching asset in HAR const assetEntry = harData.log.entries.find((entry: any) => { From 836fb1ff8223310767155543715ce79d60ab68c7 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 10:39:11 -0700 Subject: [PATCH 2/6] Combine two copy-pasted route handlers into one. --- browser-extension/tests/har-view.ts | 185 ++++++++++++---------------- 1 file changed, 76 insertions(+), 109 deletions(-) diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index 2ec422d..a4fa3bd 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -2,6 +2,7 @@ import fs from 'node:fs/promises' import path from 'node:path' import { fileURLToPath } from 'node:url' import express from 'express' +import type { Har } from 'har-format' import { PAGES } from './har-index' const __dirname = path.dirname(fileURLToPath(import.meta.url)) @@ -9,7 +10,7 @@ const app = express() const PORT = 3001 // Store HAR json -const harCache = new Map() +const harCache = new Map() // Extract URL parts for location patching function getUrlParts(key: keyof typeof PAGES) { @@ -37,9 +38,9 @@ async function checkDevServer(): Promise { } // Load and cache HAR file -async function loadHar(key: keyof typeof PAGES) { +async function loadHar(key: keyof typeof PAGES): Promise { if (harCache.has(key)) { - return harCache.get(key) + return harCache.get(key)! } const harPath = path.join(__dirname, 'har', `${key}.har`) @@ -53,7 +54,7 @@ async function loadHar(key: keyof typeof PAGES) { Object.entries(PAGES).forEach(([key, url]) => { const urlObj = new URL(url) app.get(urlObj.pathname, (_req, res) => { - res.redirect(`/page/${key}/gitcasso`) + res.redirect(`/har/${key}/gitcasso`) }) }) @@ -81,8 +82,8 @@ app.get('/', async (_req, res) => {
  • ${basename}
    @@ -134,58 +135,20 @@ app.get('/', async (_req, res) => { }) // Serve the main HTML page from HAR -app.get('/page/:key', async (req, res) => { +app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { try { - const key = req.params.key as keyof typeof PAGES - if (!(key in PAGES)) { - return res.status(400).send('Invalid key - not found in PAGES') - } - - const harData = await loadHar(key) - - // Find the main HTML response - const mainEntry = harData.log.entries.find( - (entry: any) => - entry.request.url.includes('github.com') && - entry.response.content.mimeType?.includes('text/html') && - entry.response.content.text, - ) - - if (!mainEntry) { - return res.status(404).send('No HTML content found in HAR file') - } - - let html = mainEntry.response.content.text + const key = req.params['key'] as keyof typeof PAGES + const mode = req.params['mode'] as 'clean' | 'gitcasso' - // Replace external URLs with local asset URLs - html = html.replace( - /https:\/\/(github\.com|assets\.github\.com|avatars\.githubusercontent\.com|user-images\.githubusercontent\.com)/g, - `/asset/${key}`, - ) - - return res.send(html) - } catch (error) { - console.error('Error serving page:', error) - return res.status(500).send('Error loading page') - } -}) - -// Serve the main HTML page from HAR with Gitcasso content script injected -app.get('/page/:key/gitcasso', async (req, res) => { - try { - const key = req.params.key as keyof typeof PAGES if (!(key in PAGES)) { return res.status(400).send('Invalid key - not found in PAGES') } - // Get original URL parts for location patching - const urlParts = getUrlParts(key) - const harData = await loadHar(key) // Find the main HTML response const mainEntry = harData.log.entries.find( - (entry: any) => + (entry) => entry.request.url.includes('github.com') && entry.response.content.mimeType?.includes('text/html') && entry.response.content.text, @@ -195,7 +158,7 @@ app.get('/page/:key/gitcasso', async (req, res) => { return res.status(404).send('No HTML content found in HAR file') } - let html = mainEntry.response.content.text + let html = mainEntry.response.content.text! // Replace external URLs with local asset URLs html = html.replace( @@ -203,63 +166,69 @@ app.get('/page/:key/gitcasso', async (req, res) => { `/asset/${key}`, ) - // Inject patched content script with location patching - const contentScriptTag = ` - - ` + + // Fetch and patch the content script to remove webextension-polyfill issues + fetch('http://localhost:3000/.output/chrome-mv3-dev/content-scripts/content.js') + .then(response => response.text()) + .then(code => { + console.log('Fetched content script, patching webextension-polyfill...'); + + // Replace the problematic webextension-polyfill error check + const patchedCode = code.replace( + /throw new Error\\("This script should only be loaded in a browser extension\\."/g, + 'console.warn("Webextension-polyfill check bypassed for HAR testing"' + ); + + // Mock necessary APIs before executing + window.chrome = window.chrome || { + runtime: { + getURL: (path) => 'chrome-extension://gitcasso-test/' + path, + onMessage: { addListener: () => {} }, + sendMessage: () => Promise.resolve(), + id: 'gitcasso-test' + } + }; + window.browser = window.chrome; + + // Execute the patched script + const script = document.createElement('script'); + script.textContent = patchedCode; + document.head.appendChild(script); + + console.log('Gitcasso content script loaded with location patching for:', '${urlParts.href}'); + }) + .catch(error => { + console.error('Failed to load and patch content script:', error); + }); + + ` - // Insert script before closing body tag, or at the end if no body tag - if (html.includes('')) { - html = html.replace('', `${contentScriptTag}`) - } else { - html += contentScriptTag + // Insert script before closing body tag, or at the end if no body tag + if (html.includes('')) { + html = html.replace('', `${contentScriptTag}`) + } else { + html += contentScriptTag + } } return res.send(html) @@ -281,7 +250,7 @@ app.get('/asset/:key/*', async (req, res) => { const harData = await loadHar(key) // Find matching asset in HAR - const assetEntry = harData.log.entries.find((entry: any) => { + const assetEntry = harData.log.entries.find((entry) => { const url = new URL(entry.request.url) return url.pathname === `/${assetPath}` || url.pathname.endsWith(`/${assetPath}`) }) @@ -292,13 +261,11 @@ app.get('/asset/:key/*', async (req, res) => { const content = assetEntry.response.content const mimeType = content.mimeType || 'application/octet-stream' - res.set('Content-Type', mimeType) - if (content.encoding === 'base64') { - return res.send(Buffer.from(content.text, 'base64')) + return res.send(Buffer.from(content.text!, 'base64')) } else { - return res.send(content.text || '') + return res.send(content.text!) } } catch (error) { console.error('Error serving asset:', error) From 8f5c55bd73680642d2c2a9c76cead64eb225019d Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 10:55:45 -0700 Subject: [PATCH 3/6] Extract gitcasso injection into its own script. --- browser-extension/tests/har-view.ts | 125 +++++++++++++--------------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index a4fa3bd..1ce1ba1 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url' import express from 'express' import type { Har } from 'har-format' import { PAGES } from './har-index' +import { error } from 'node:console' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const app = express() @@ -139,40 +140,83 @@ app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { try { const key = req.params['key'] as keyof typeof PAGES const mode = req.params['mode'] as 'clean' | 'gitcasso' - if (!(key in PAGES)) { return res.status(400).send('Invalid key - not found in PAGES') } - const harData = await loadHar(key) - // Find the main HTML response + const harData = await loadHar(key) const mainEntry = harData.log.entries.find( (entry) => entry.request.url.includes('github.com') && entry.response.content.mimeType?.includes('text/html') && entry.response.content.text, ) - if (!mainEntry) { return res.status(404).send('No HTML content found in HAR file') } - let html = mainEntry.response.content.text! - // Replace external URLs with local asset URLs + let html = mainEntry.response.content.text! html = html.replace( /https:\/\/(github\.com|assets\.github\.com|avatars\.githubusercontent\.com|user-images\.githubusercontent\.com)/g, `/asset/${key}`, ) - - // If gitcasso mode, inject content script if (mode === 'gitcasso') { - // Get original URL parts for location patching - const urlParts = getUrlParts(key) + html = injectGitcassoScript(key, html) + } + return res.send(html) + } catch (error) { + console.error('Error serving page:', error) + return res.status(500).send('Error loading page') + } +}) + +// Serve assets from HAR file +app.get('/asset/:key/*', async (req, res) => { + try { + const key = req.params.key as keyof typeof PAGES + if (!(key in PAGES)) { + return res.status(400).send('Invalid key - not found in PAGES') + } + const assetPath = (req.params as any)[0] as string + + const harData = await loadHar(key) + + // Find matching asset in HAR + const assetEntry = harData.log.entries.find((entry) => { + const url = new URL(entry.request.url) + return url.pathname === `/${assetPath}` || url.pathname.endsWith(`/${assetPath}`) + }) + + if (!assetEntry) { + return res.status(404).send('Asset not found') + } + + const content = assetEntry.response.content + const mimeType = content.mimeType || 'application/octet-stream' + res.set('Content-Type', mimeType) + if (content.encoding === 'base64') { + return res.send(Buffer.from(content.text!, 'base64')) + } else { + return res.send(content.text!) + } + } catch (error) { + console.error('Error serving asset:', error) + return res.status(404).send('Asset not found') + } +}) - // Inject patched content script with location patching - const contentScriptTag = ` +app.listen(PORT, () => { + console.log(`HAR Page Viewer running at http://localhost:${PORT}`) + console.log('Click the links to view recorded pages') +}) + +function injectGitcassoScript(key: keyof typeof PAGES, html: string) { + const urlParts = getUrlParts(key) + + // Inject patched content script with location patching + const contentScriptTag = ` ` - - // Insert script before closing body tag, or at the end if no body tag - if (html.includes('')) { - html = html.replace('', `${contentScriptTag}`) - } else { - html += contentScriptTag - } - } - - return res.send(html) - } catch (error) { - console.error('Error serving page:', error) - return res.status(500).send('Error loading page') + if (!html.includes('')) { + throw error('No closing body tag, nowhere to put the content script!') } -}) - -// Serve assets from HAR file -app.get('/asset/:key/*', async (req, res) => { - try { - const key = req.params.key as keyof typeof PAGES - if (!(key in PAGES)) { - return res.status(400).send('Invalid key - not found in PAGES') - } - const assetPath = (req.params as any)[0] as string - - const harData = await loadHar(key) - - // Find matching asset in HAR - const assetEntry = harData.log.entries.find((entry) => { - const url = new URL(entry.request.url) - return url.pathname === `/${assetPath}` || url.pathname.endsWith(`/${assetPath}`) - }) - - if (!assetEntry) { - return res.status(404).send('Asset not found') - } - - const content = assetEntry.response.content - const mimeType = content.mimeType || 'application/octet-stream' - res.set('Content-Type', mimeType) - if (content.encoding === 'base64') { - return res.send(Buffer.from(content.text!, 'base64')) - } else { - return res.send(content.text!) - } - } catch (error) { - console.error('Error serving asset:', error) - return res.status(404).send('Asset not found') - } -}) + return html.replace('', `${contentScriptTag}`) +} -app.listen(PORT, () => { - console.log(`HAR Page Viewer running at http://localhost:${PORT}`) - console.log('Click the links to view recorded GitHub pages') -}) From 032e04d2e854cd968610577e22e1ebd6c2142af6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 11:22:36 -0700 Subject: [PATCH 4/6] asset handling is now website-agnostic --- browser-extension/tests/har-view.ts | 51 ++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index 1ce1ba1..a76bc67 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -146,9 +146,15 @@ app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { // Find the main HTML response const harData = await loadHar(key) + const originalUrl = PAGES[key] const mainEntry = harData.log.entries.find( (entry) => - entry.request.url.includes('github.com') && + entry.request.url === originalUrl && + entry.response.content.mimeType?.includes('text/html') && + entry.response.content.text, + ) || harData.log.entries.find( + (entry) => + entry.response.status === 200 && entry.response.content.mimeType?.includes('text/html') && entry.response.content.text, ) @@ -156,12 +162,24 @@ app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { return res.status(404).send('No HTML content found in HAR file') } + // Extract all domains from HAR entries for dynamic replacement + const domains = new Set() + harData.log.entries.forEach(entry => { + try { + const url = new URL(entry.request.url) + domains.add(url.hostname) + } catch { + // Skip invalid URLs + } + }) + // Replace external URLs with local asset URLs let html = mainEntry.response.content.text! - html = html.replace( - /https:\/\/(github\.com|assets\.github\.com|avatars\.githubusercontent\.com|user-images\.githubusercontent\.com)/g, - `/asset/${key}`, - ) + domains.forEach(domain => { + const escapedDomain = domain.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + const regex = new RegExp(`https?://${escapedDomain}`, 'g') + html = html.replace(regex, `/asset/${key}`) + }) if (mode === 'gitcasso') { html = injectGitcassoScript(key, html) } @@ -183,10 +201,27 @@ app.get('/asset/:key/*', async (req, res) => { const harData = await loadHar(key) - // Find matching asset in HAR + // Find matching asset in HAR by full URL comparison const assetEntry = harData.log.entries.find((entry) => { - const url = new URL(entry.request.url) - return url.pathname === `/${assetPath}` || url.pathname.endsWith(`/${assetPath}`) + try { + const url = new URL(entry.request.url) + // First try exact path match + if (url.pathname === `/${assetPath}`) { + return true + } + // Then try path ending match (for nested paths) + if (url.pathname.endsWith(`/${assetPath}`)) { + return true + } + // Handle query parameters - check if path without query matches + const pathWithoutQuery = url.pathname + url.search + if (pathWithoutQuery === `/${assetPath}` || pathWithoutQuery.endsWith(`/${assetPath}`)) { + return true + } + return false + } catch { + return false + } }) if (!assetEntry) { From 2d97bad783ada8e48abff76228a1a302276c99dc Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 11:53:40 -0700 Subject: [PATCH 5/6] biome:fix --- browser-extension/tests/har-view.ts | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index a76bc67..930f10c 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -1,10 +1,10 @@ +import { error } from 'node:console' import fs from 'node:fs/promises' import path from 'node:path' import { fileURLToPath } from 'node:url' import express from 'express' import type { Har } from 'har-format' import { PAGES } from './har-index' -import { error } from 'node:console' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const app = express() @@ -147,24 +147,26 @@ app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { // Find the main HTML response const harData = await loadHar(key) const originalUrl = PAGES[key] - const mainEntry = harData.log.entries.find( - (entry) => - entry.request.url === originalUrl && - entry.response.content.mimeType?.includes('text/html') && - entry.response.content.text, - ) || harData.log.entries.find( - (entry) => - entry.response.status === 200 && - entry.response.content.mimeType?.includes('text/html') && - entry.response.content.text, - ) + const mainEntry = + harData.log.entries.find( + (entry) => + entry.request.url === originalUrl && + entry.response.content.mimeType?.includes('text/html') && + entry.response.content.text, + ) || + harData.log.entries.find( + (entry) => + entry.response.status === 200 && + entry.response.content.mimeType?.includes('text/html') && + entry.response.content.text, + ) if (!mainEntry) { return res.status(404).send('No HTML content found in HAR file') } // Extract all domains from HAR entries for dynamic replacement const domains = new Set() - harData.log.entries.forEach(entry => { + harData.log.entries.forEach((entry) => { try { const url = new URL(entry.request.url) domains.add(url.hostname) @@ -175,7 +177,7 @@ app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { // Replace external URLs with local asset URLs let html = mainEntry.response.content.text! - domains.forEach(domain => { + domains.forEach((domain) => { const escapedDomain = domain.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') const regex = new RegExp(`https?://${escapedDomain}`, 'g') html = html.replace(regex, `/asset/${key}`) @@ -306,4 +308,3 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) { } return html.replace('', `${contentScriptTag}`) } - From b8721ebe1e395cd884ba4a4e10cc25bf271c0af0 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 6 Sep 2025 12:01:49 -0700 Subject: [PATCH 6/6] Couple renames for more consistency. --- .../tests/{test-utils.ts => har-fixture-utils.ts} | 2 +- browser-extension/tests/{fixture-har.ts => har-fixture.ts} | 4 ++-- browser-extension/tests/har-record.ts | 2 +- browser-extension/tests/har-view.ts | 4 +++- browser-extension/tests/{har-index.ts => har/_har-index.ts} | 0 browser-extension/tests/lib/enhancers/github.test.ts | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) rename browser-extension/tests/{test-utils.ts => har-fixture-utils.ts} (98%) rename browser-extension/tests/{fixture-har.ts => har-fixture.ts} (91%) rename browser-extension/tests/{har-index.ts => har/_har-index.ts} (100%) diff --git a/browser-extension/tests/test-utils.ts b/browser-extension/tests/har-fixture-utils.ts similarity index 98% rename from browser-extension/tests/test-utils.ts rename to browser-extension/tests/har-fixture-utils.ts index b4c613c..15faa4d 100644 --- a/browser-extension/tests/test-utils.ts +++ b/browser-extension/tests/har-fixture-utils.ts @@ -3,7 +3,7 @@ import path from 'node:path' import { fileURLToPath } from 'node:url' import type { Har as HarFile } from 'har-format' import { parseHTML } from 'linkedom' -import { PAGES } from './har-index' +import { PAGES } from './har/_har-index' const __dirname = path.dirname(fileURLToPath(import.meta.url)) diff --git a/browser-extension/tests/fixture-har.ts b/browser-extension/tests/har-fixture.ts similarity index 91% rename from browser-extension/tests/fixture-har.ts rename to browser-extension/tests/har-fixture.ts index a2f1904..baf62c4 100644 --- a/browser-extension/tests/fixture-har.ts +++ b/browser-extension/tests/har-fixture.ts @@ -21,8 +21,8 @@ vi.mock('../src/overtype/overtype', () => { }) import { describe as baseDescribe, test as baseTest, expect } from 'vitest' -import type { PAGES } from './har-index' -import { cleanupDOM, setupHarDOM } from './test-utils' +import type { PAGES } from './har/_har-index' +import { cleanupDOM, setupHarDOM } from './har-fixture-utils' export const describe = baseDescribe diff --git a/browser-extension/tests/har-record.ts b/browser-extension/tests/har-record.ts index c229603..86e77c8 100644 --- a/browser-extension/tests/har-record.ts +++ b/browser-extension/tests/har-record.ts @@ -1,7 +1,7 @@ import fs from 'node:fs/promises' import path from 'node:path' import { chromium } from '@playwright/test' -import { PAGES } from './har-index' +import { PAGES } from './har/_har-index' // Convert glob pattern to regex function globToRegex(pattern: string): RegExp { diff --git a/browser-extension/tests/har-view.ts b/browser-extension/tests/har-view.ts index 930f10c..e2b9f4e 100644 --- a/browser-extension/tests/har-view.ts +++ b/browser-extension/tests/har-view.ts @@ -4,7 +4,7 @@ import path from 'node:path' import { fileURLToPath } from 'node:url' import express from 'express' import type { Har } from 'har-format' -import { PAGES } from './har-index' +import { PAGES } from './har/_har-index' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const app = express() @@ -138,7 +138,9 @@ app.get('/', async (_req, res) => { // Serve the main HTML page from HAR app.get('/har/:key/:mode(clean|gitcasso)', async (req, res) => { try { + // biome-ignore lint/complexity/useLiteralKeys: type comes from path string const key = req.params['key'] as keyof typeof PAGES + // biome-ignore lint/complexity/useLiteralKeys: type comes from path string const mode = req.params['mode'] as 'clean' | 'gitcasso' if (!(key in PAGES)) { return res.status(400).send('Invalid key - not found in PAGES') diff --git a/browser-extension/tests/har-index.ts b/browser-extension/tests/har/_har-index.ts similarity index 100% rename from browser-extension/tests/har-index.ts rename to browser-extension/tests/har/_har-index.ts diff --git a/browser-extension/tests/lib/enhancers/github.test.ts b/browser-extension/tests/lib/enhancers/github.test.ts index 24a8602..3952e81 100644 --- a/browser-extension/tests/lib/enhancers/github.test.ts +++ b/browser-extension/tests/lib/enhancers/github.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, usingHar } from '../../fixture-har' +import { describe, expect, usingHar } from '../../har-fixture' // must import fixture **first** for mocks, the `expect` keeps biome from changing sort-order expect