You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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
36
35
37
36
## How it works
38
37
@@ -76,46 +75,52 @@ Those `Spot` values get bundled up with the `HTMLTextAreaElement` itself into an
76
75
77
76
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.
78
77
79
-
## Testing
78
+
## Test corpus
80
79
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
83
86
84
-
### Test Corpus
87
+
This corpus of pages is used to power snapshot tests and interactive dev environments.
85
88
86
-
We maintain a corpus of test pages in two formats for testing the browser extension:
89
+
### Viewing corpus
87
90
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
89
98
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
102
103
103
-
#### HTML Corpus (Manual)
104
+
###Adding HTML to the corpus (Manual)
104
105
105
106
- 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
109
109
1. Navigate to the desired page state (click buttons, expand textareas, etc.)
110
110
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
112
112
4. Add an entry to `tests/corpus/_corpus-index.ts` with `type: 'html'` and a description of the captured state
113
113
5. Feel free to contribute these if you want, but be mindful that they will be part of our immutable git history
114
114
115
-
#### Viewing Corpus Files
115
+
###Adding HAR to the corpus (Automated)
116
116
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
0 commit comments