Skip to content

Commit cf2d3dd

Browse files
committed
Claude's first pass.
1 parent 9195392 commit cf2d3dd

File tree

11 files changed

+237
-153
lines changed

11 files changed

+237
-153
lines changed

browser-extension/README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,42 @@ When the `textarea` gets removed from the page, the `TextareaRegistry` is notifi
6969
## Testing
7070

7171
- `npm run playground` gives you a test environment where you can tinker with the popup with various test data, supports hot reload
72-
- `npm run har:view` gives you recordings of various web pages which you can see with and without enhancement by the browser extension
73-
74-
### Recording new HAR files
75-
76-
- the har recordings live in `tests/har`, they are complete recordings of the network requests of a single page load
77-
- you can add or change URLs in `tests/har-index.ts`
78-
- `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens
79-
- login manually, then close the browser
80-
- ***these cookies are very sensitive! we only run this script using a test account that has no permissions or memberships to anything, recommend you do the same!***
81-
- `pnpm run har:record` this records new snapshots using those auth tokens (it needs args, run it with no args for docs)
82-
- DO NOT COMMIT AND PUSH NEW OR CHANGED `har` files!
83-
- we try to sanitize these (see `har-record.ts` for details) but there may be important PII in them
84-
- if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account
85-
- IF YOUR PR CHANGES OR ADDS HAR FILES WE WILL CLOSE IT. Ask for HAR files and we'll be happy to generate clean ones you can test against.
72+
- `npm run corpus:view` gives you recordings of various web pages which you can see with and without enhancement by the browser extension
73+
74+
### Test Corpus
75+
76+
We maintain a corpus of test pages in two formats for testing the browser extension:
77+
78+
#### HAR Corpus (Automated)
79+
80+
- For testing initial page loads and network requests
81+
- HAR recordings live in `tests/corpus/har/`, complete recordings of the network requests of a single page load
82+
- You can add or change URLs in `tests/corpus/_corpus-index.ts`
83+
- **Recording new HAR files:**
84+
- `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens
85+
- login manually, then close the browser
86+
- ***these cookies are very sensitive! we only run this script using a test account that has no permissions or memberships to anything, recommend you do the same!***
87+
- `pnpm run corpus:record:har` records new HAR files using those auth tokens (it needs args, run it with no args for docs)
88+
- DO NOT COMMIT AND PUSH NEW OR CHANGED HAR files!
89+
- we try to sanitize these (see `har-record.ts` for details) but there may be important PII in them
90+
- if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account
91+
- IF YOUR PR CHANGES OR ADDS HAR FILES WE WILL CLOSE IT. Ask for HAR files and we'll be happy to generate clean ones you can test against.
92+
93+
#### HTML Corpus (Manual)
94+
95+
- For testing post-interaction states (e.g., expanded textareas, modal dialogs, dynamic content)
96+
- HTML snapshots live in `tests/corpus/html/`, manually captured using SingleFile browser extension
97+
- All assets are inlined in a single HTML file by SingleFile
98+
- **Creating new HTML corpus files:**
99+
1. Navigate to the desired page state (click buttons, expand textareas, etc.)
100+
2. Use SingleFile browser extension to save the complete page
101+
3. Save the `.html` file to `tests/corpus/html/` with a descriptive name
102+
4. Add an entry to `tests/corpus/_corpus-index.ts` with `type: 'html'` and a description of the captured state
103+
104+
#### Viewing Corpus Files
105+
106+
- Run `pnpm run corpus:view` to start the test server at http://localhost:3001
107+
- Select any corpus file to view in two modes:
108+
- **Clean**: Original page without extension
109+
- **Gitcasso**: Page with extension injected for testing
110+
- Both HAR and HTML corpus types are supported

browser-extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
"test": "vitest run",
6363
"playground": "vite --config vite.playground.config.ts",
6464
"playground:build": "vite build --config vite.playground.config.ts",
65-
"har:record": "tsx tests/har-record.ts",
66-
"har:view": "tsx tests/har-view.ts"
65+
"corpus:record:har": "tsx tests/har-record.ts",
66+
"corpus:view": "tsx tests/corpus-view.ts"
6767
},
6868
"type": "module",
6969
"version": "0.0.1"

browser-extension/src/lib/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export type LogLevel = (typeof LOG_LEVELS)[number]
99
export const CONFIG = {
1010
ADDED_OVERTYPE_CLASS: 'gitcasso-overtype',
1111
EXTENSION_NAME: 'gitcasso', // decorates logs
12-
LOG_LEVEL: 'INFO' satisfies LogLevel,
12+
LOG_LEVEL: 'DEBUG' satisfies LogLevel,
1313
MODE: 'PROD' satisfies ModeType,
1414
} as const

0 commit comments

Comments
 (0)