Skip to content

Commit d9f6798

Browse files
committed
Add tests for the editing case.
1 parent da245bc commit d9f6798

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

browser-extension/tests/lib/enhancers/github.test.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,124 @@ describe('github', () => {
175175
]
176176
`)
177177
})
178+
withCorpus('gh_issue_edit').it('should create the correct spot object', async () => {
179+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
180+
[
181+
{
182+
"for": "id=:rc3: name=null className=prc-Textarea-TextArea-13q4j focus-visible overtype-input",
183+
"spot": {
184+
"domain": "github.com",
185+
"number": 56,
186+
"slug": "diffplug/gitcasso",
187+
"title": "TODO_TITLE",
188+
"type": "GH_ISSUE_ADD_COMMENT",
189+
"unique_key": "github.com:diffplug/gitcasso:56",
190+
},
191+
"title": "TITLE_TODO",
192+
"upperDecoration": <React.Fragment>
193+
<span
194+
className="flex h-4 w-4 flex-shrink-0 items-center justify-center"
195+
>
196+
<IssueOpenedIcon
197+
size={16}
198+
/>
199+
</span>
200+
#
201+
56
202+
<a
203+
className="truncate hover:underline"
204+
href="https://github.com/diffplug/gitcasso"
205+
>
206+
diffplug/gitcasso
207+
</a>
208+
</React.Fragment>,
209+
},
210+
{
211+
"for": "id=:ra7: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
212+
"spot": {
213+
"domain": "github.com",
214+
"number": 56,
215+
"slug": "diffplug/gitcasso",
216+
"title": "TODO_TITLE",
217+
"type": "GH_ISSUE_ADD_COMMENT",
218+
"unique_key": "github.com:diffplug/gitcasso:56",
219+
},
220+
"title": "TITLE_TODO",
221+
"upperDecoration": <React.Fragment>
222+
<span
223+
className="flex h-4 w-4 flex-shrink-0 items-center justify-center"
224+
>
225+
<IssueOpenedIcon
226+
size={16}
227+
/>
228+
</span>
229+
#
230+
56
231+
<a
232+
className="truncate hover:underline"
233+
href="https://github.com/diffplug/gitcasso"
234+
>
235+
diffplug/gitcasso
236+
</a>
237+
</React.Fragment>,
238+
},
239+
]
240+
`)
241+
})
242+
withCorpus('gh_pr_edit').it('should create the correct spot object', async () => {
243+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
244+
[
245+
{
246+
"for": "id=issue-3429313834-body name=pull_request[body] className=js-comment-field js-paste-markdown js-task-list-field js-quick-submit js-size-to-fit size-to-fit js-session-resumable CommentBox-input FormControl-textarea js-saved-reply-shortcut-comment-field focus-visible overtype-input",
247+
"spot": {
248+
"domain": "github.com",
249+
"number": NaN,
250+
"slug": "diffplug/gitcasso",
251+
"title": "TODO_TITLE",
252+
"type": "GH_EDIT_COMMENT",
253+
"unique_key": "github.com:diffplug/gitcasso:NaN",
254+
},
255+
"title": "TITLE_TODO",
256+
"upperDecoration": <React.Fragment>
257+
<span
258+
className="font-mono text-muted-foreground text-sm"
259+
>
260+
diffplug/gitcasso
261+
</span>
262+
<span
263+
className="ml-2 font-medium"
264+
>
265+
PR #
266+
NaN
267+
</span>
268+
</React.Fragment>,
269+
},
270+
{
271+
"for": "id=new_comment_field name=comment[body] className=js-comment-field js-paste-markdown js-task-list-field js-quick-submit FormControl-textarea CommentBox-input js-size-to-fit size-to-fit js-session-resumable js-saved-reply-shortcut-comment-field overtype-input",
272+
"spot": {
273+
"domain": "github.com",
274+
"number": 58,
275+
"slug": "diffplug/gitcasso",
276+
"title": "TODO_TITLE",
277+
"type": "GH_PR_ADD_COMMENT",
278+
"unique_key": "github.com:diffplug/gitcasso:58",
279+
},
280+
"title": "TITLE_TODO",
281+
"upperDecoration": <React.Fragment>
282+
<span
283+
className="font-mono text-muted-foreground text-sm"
284+
>
285+
diffplug/gitcasso
286+
</span>
287+
<span
288+
className="ml-2 font-medium"
289+
>
290+
PR #
291+
58
292+
</span>
293+
</React.Fragment>,
294+
},
295+
]
296+
`)
297+
})
178298
})

0 commit comments

Comments
 (0)