Skip to content

Commit 519a014

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

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

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

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,180 @@ describe('github', () => {
175175
]
176176
`)
177177
})
178+
withCorpus('gh_new_issue').it('should create the correct spot object', async () => {
179+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
180+
[
181+
{
182+
"for": "id=feedback name=feedback className=form-control width-full mb-2 overtype-input",
183+
"spot": {
184+
"domain": "github.com",
185+
"slug": "diffplug/selfie",
186+
"type": "GH_ISSUE_NEW_COMMENT",
187+
"unique_key": "github.com:diffplug/selfie:new",
188+
},
189+
"title": "New Issue",
190+
"upperDecoration": <React.Fragment>
191+
<span>
192+
New Issue
193+
</span>
194+
<span
195+
className="font-mono text-muted-foreground text-sm"
196+
>
197+
198+
diffplug/selfie
199+
200+
</span>
201+
</React.Fragment>,
202+
},
203+
]
204+
`)
205+
})
206+
withCorpus('gh_new_issue').it('should create the correct spot object', async () => {
207+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
208+
[
209+
{
210+
"for": "id=feedback name=feedback className=form-control width-full mb-2 overtype-input",
211+
"spot": {
212+
"domain": "github.com",
213+
"slug": "diffplug/selfie",
214+
"type": "GH_ISSUE_NEW_COMMENT",
215+
"unique_key": "github.com:diffplug/selfie:new",
216+
},
217+
"title": "New Issue",
218+
"upperDecoration": <React.Fragment>
219+
<span>
220+
New Issue
221+
</span>
222+
<span
223+
className="font-mono text-muted-foreground text-sm"
224+
>
225+
226+
diffplug/selfie
227+
228+
</span>
229+
</React.Fragment>,
230+
},
231+
]
232+
`)
233+
})
234+
withCorpus('gh_issue_edit').it('should create the correct spot object', async () => {
235+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
236+
[
237+
{
238+
"for": "id=:rc3: name=null className=prc-Textarea-TextArea-13q4j focus-visible overtype-input",
239+
"spot": {
240+
"domain": "github.com",
241+
"number": 56,
242+
"slug": "diffplug/gitcasso",
243+
"title": "TODO_TITLE",
244+
"type": "GH_ISSUE_ADD_COMMENT",
245+
"unique_key": "github.com:diffplug/gitcasso:56",
246+
},
247+
"title": "TITLE_TODO",
248+
"upperDecoration": <React.Fragment>
249+
<span
250+
className="flex h-4 w-4 flex-shrink-0 items-center justify-center"
251+
>
252+
<IssueOpenedIcon
253+
size={16}
254+
/>
255+
</span>
256+
#
257+
56
258+
<a
259+
className="truncate hover:underline"
260+
href="https://github.com/diffplug/gitcasso"
261+
>
262+
diffplug/gitcasso
263+
</a>
264+
</React.Fragment>,
265+
},
266+
{
267+
"for": "id=:ra7: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
268+
"spot": {
269+
"domain": "github.com",
270+
"number": 56,
271+
"slug": "diffplug/gitcasso",
272+
"title": "TODO_TITLE",
273+
"type": "GH_ISSUE_ADD_COMMENT",
274+
"unique_key": "github.com:diffplug/gitcasso:56",
275+
},
276+
"title": "TITLE_TODO",
277+
"upperDecoration": <React.Fragment>
278+
<span
279+
className="flex h-4 w-4 flex-shrink-0 items-center justify-center"
280+
>
281+
<IssueOpenedIcon
282+
size={16}
283+
/>
284+
</span>
285+
#
286+
56
287+
<a
288+
className="truncate hover:underline"
289+
href="https://github.com/diffplug/gitcasso"
290+
>
291+
diffplug/gitcasso
292+
</a>
293+
</React.Fragment>,
294+
},
295+
]
296+
`)
297+
})
298+
withCorpus('gh_pr_edit').it('should create the correct spot object', async () => {
299+
expect(enhancements(document, window)).toMatchInlineSnapshot(`
300+
[
301+
{
302+
"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",
303+
"spot": {
304+
"domain": "github.com",
305+
"number": NaN,
306+
"slug": "diffplug/gitcasso",
307+
"title": "TODO_TITLE",
308+
"type": "GH_EDIT_COMMENT",
309+
"unique_key": "github.com:diffplug/gitcasso:NaN",
310+
},
311+
"title": "TITLE_TODO",
312+
"upperDecoration": <React.Fragment>
313+
<span
314+
className="font-mono text-muted-foreground text-sm"
315+
>
316+
diffplug/gitcasso
317+
</span>
318+
<span
319+
className="ml-2 font-medium"
320+
>
321+
PR #
322+
NaN
323+
</span>
324+
</React.Fragment>,
325+
},
326+
{
327+
"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",
328+
"spot": {
329+
"domain": "github.com",
330+
"number": 58,
331+
"slug": "diffplug/gitcasso",
332+
"title": "TODO_TITLE",
333+
"type": "GH_PR_ADD_COMMENT",
334+
"unique_key": "github.com:diffplug/gitcasso:58",
335+
},
336+
"title": "TITLE_TODO",
337+
"upperDecoration": <React.Fragment>
338+
<span
339+
className="font-mono text-muted-foreground text-sm"
340+
>
341+
diffplug/gitcasso
342+
</span>
343+
<span
344+
className="ml-2 font-medium"
345+
>
346+
PR #
347+
58
348+
</span>
349+
</React.Fragment>,
350+
},
351+
]
352+
`)
353+
})
178354
})

0 commit comments

Comments
 (0)