Skip to content

Commit 525ab07

Browse files
committed
Update dev instructions a bit.
1 parent 3ec2141 commit 525ab07

2 files changed

Lines changed: 51 additions & 46 deletions

File tree

CONTRIBUTING.md

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@ This extension ***must never transmit any data outside the browser***.
1616

1717
## Developer quickstart
1818

19-
### Hotreload development
20-
2119
- `pnpm install`
22-
- `pnpm dev`
23-
- open [`chrome://extensions`](chrome://extensions)
24-
- toggle **Developer mode** (top-right)
25-
- click "Load unpacked" (far left)
26-
- `.output/chrome-mv3-dev`
27-
- if you can't find `.output`, it's probably hidden, `command+shift+period` will show it
28-
- click the puzzle icon next to the url bar, then pin the Gitcasso icon
29-
30-
### Testing and quality
31-
- `pnpm biome` - runs `biome check` (lint & formatting)
32-
- `pnpm biome:fix` - fixes most of what `biome check` finds
33-
- `pnpm typecheck` - typechecking
34-
- `pnpm test` - vitest
35-
- `pnpm test -u` - updates all snapshots
20+
- to update the popup:
21+
- `pnpm playground` gives react hotreload environment
22+
- to improve comment detection and metadata extraction:
23+
- `pnpm corpus` gives dev environment for gitcasso's behavior on specific pages and page states
24+
- to open a PR:
25+
- `pnpm precommit` fixes formatting and lints (biome), runs typechecking and tests
26+
- no worries if some intermediate commits don't pass
27+
- to run the entire end-to-end browser extension with [WXT](https://wxt.dev/) hotreload:
28+
- `pnpm dev`
29+
- open [`chrome://extensions`](chrome://extensions)
30+
- toggle **Developer mode** (top-right)
31+
- click "Load unpacked" (far left)
32+
- `.output/chrome-mv3-dev`
33+
- if you can't find `.output`, it's probably hidden, `command+shift+period` will show it
34+
- click the puzzle icon next to the url bar, then pin the Gitcasso icon
3635

3736
## How it works
3837

@@ -76,46 +75,52 @@ Those `Spot` values get bundled up with the `HTMLTextAreaElement` itself into an
7675

7776
When the `textarea` gets removed from the page, the `TextareaRegistry` is notified so that the `CommentSpot` can be marked as abandoned or submitted as appropriate.
7877

79-
## Testing
78+
## Test corpus
8079

81-
- `pnpm playground` gives you a test environment where you can tinker with the popup with various test data, supports hot reload
82-
- `pnpm corpus` gives you recordings of various web pages which you can see with and without enhancement by the browser extension
80+
We maintain a corpus of test pages in two formats for testing the browser extension:
81+
- `html` created by the [SingleFile](https://chromewebstore.google.com/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle) browser extension
82+
- allows snapshotting the DOM at an intermediate step in the user's experience
83+
- most interactivity will be broken
84+
- `har` recording of all network traffic of an initial pageload
85+
- limited to initial page load, but most interactivity will work
8386

84-
### Test Corpus
87+
This corpus of pages is used to power snapshot tests and interactive dev environments.
8588

86-
We maintain a corpus of test pages in two formats for testing the browser extension:
89+
### Viewing corpus
8790

88-
#### HAR Corpus (Automated)
91+
- **DISABLE GITCASSO IN YOUR BROWSER!!**
92+
- Run `pnpm corpus` to start the test server at http://localhost:3001
93+
- Select any corpus file to view in two modes:
94+
- **Clean**: Original unaltered page
95+
- **Gitcasso**: Page with extension injected for testing
96+
- it shows all data Gitcasso is extracting (if any)
97+
- click the rebuild button to test changes to the Gitcasso source
8998

90-
- For testing initial page loads and network requests
91-
- HAR recordings live in `tests/corpus/*.har`, complete recordings of the network requests of a single page load
92-
- You can add or change URLs in `tests/corpus/_corpus-index.ts`
93-
- **Recording new HAR files:**
94-
- `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens
95-
- login manually, then close the browser
96-
- ***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!***
97-
- `pnpm corpus:har:record` records new HAR files using those auth tokens (it needs args, run it with no args for docs)
98-
- DO NOT COMMIT AND PUSH NEW OR CHANGED HAR files!
99-
- we try to sanitize these (see `corpus-har-record.ts` for details) but there may be important PII in them
100-
- if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account
101-
- 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.
99+
### Unit testing against corpus
100+
101+
- `gh-detection.test.ts` does snapshot testing on the data which gitcasso extracts
102+
- `gh-ui.test.ts` does snapshot testing on the popup table decoration for all data extracted from the snapshots
102103

103-
#### HTML Corpus (Manual)
104+
### Adding HTML to the corpus (Manual)
104105

105106
- For testing post-interaction states (e.g., expanded textareas, modal dialogs, dynamic content)
106-
- HTML snapshots live in `tests/corpus/*.html`, manually captured using SingleFile browser extension
107-
- All assets are inlined in a single HTML file by SingleFile
108-
- **Creating new HTML corpus files:**
107+
- HTML snapshots live in `tests/corpus/*.html`, manually captured using SingleFile
108+
- how-to
109109
1. Navigate to the desired page state (click buttons, expand textareas, etc.)
110110
2. Use SingleFile browser extension to save the complete page
111-
3. Save the `.html` file to `tests/corpus/html/` with a descriptive name
111+
3. Save the `.html` file to `tests/corpus/` with a descriptive slug
112112
4. Add an entry to `tests/corpus/_corpus-index.ts` with `type: 'html'` and a description of the captured state
113113
5. Feel free to contribute these if you want, but be mindful that they will be part of our immutable git history
114114

115-
#### Viewing Corpus Files
115+
### Adding HAR to the corpus (Automated)
116116

117-
- Run `pnpm corpus` to start the test server at http://localhost:3001
118-
- Select any corpus file to view in two modes:
119-
- **Clean**: Original page without extension
120-
- **Gitcasso**: Page with extension injected for testing
121-
- Both HAR and HTML corpus types are supported
117+
- For testing initial page loads and network requests
118+
- HAR recordings live in `tests/corpus/*.har`, complete recordings of the network requests of a single page load
119+
- how-to
120+
- update `tests/corpus/_corpus-index.ts` with a descriptive slug and URL which you want to add
121+
- `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens
122+
- login manually, then close the browser
123+
- ***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!***
124+
- `pnpm corpus:har:record {slug}` records new HAR files using those auth tokens (it needs args, run it with no args for docs)
125+
- **CONTRIBUTING THESE IS RISKY!**
126+
- we try to sanitize these (see `corpus-har-record.ts` for details) but there may be important PII in them, which is why we only use a test account

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"build": "pnpm run build:overtype && wxt build",
5656
"build:dev": "pnpm run build:overtype && wxt build --mode development",
5757
"build:firefox": "wxt build -b firefox",
58-
"precommit": "npm run biome:fix && npm run typecheck && npm run test",
58+
"precommit": "pnpm biome:fix && pnpm typecheck && pnpm test",
5959
"typecheck": "tsc --noEmit",
6060
"dev": "wxt",
6161
"dev:firefox": "wxt -b firefox",

0 commit comments

Comments
 (0)