@@ -3,14 +3,14 @@ import {
33 mockGitHubEnterpriseServerAccount ,
44} from '../../../__mocks__/account-mocks' ;
55import type { Link } from '../../../types' ;
6- import type {
7- DiscussionAuthor ,
8- Notification ,
9- Repository ,
10- User ,
11- } from '../../../typesGitHub' ;
6+ import type { Notification , Repository , User } from '../../../typesGitHub' ;
7+ import { makeFragmentData } from '../graphql/generated/fragment-masking' ;
128import type { FetchDiscussionsQuery } from '../graphql/generated/graphql' ;
13- import type { GitHubGraphQLResponse } from '../types' ;
9+ import {
10+ CommentFieldsFragmentDoc ,
11+ DiscussionCommentFieldsFragmentDoc ,
12+ DiscussionFieldsFragmentDoc ,
13+ } from '../graphql/generated/graphql' ;
1414
1515export const mockNotificationUser : User = {
1616 login : 'octocat' ,
@@ -374,72 +374,105 @@ export const mockEnterpriseNotifications: Notification[] = [
374374 } ,
375375] ;
376376
377- const mockDiscussionAuthor : DiscussionAuthor = {
378- login : 'comment-user' ,
379- url : 'https://github.com/comment-user' as Link ,
380- avatar_url : 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
381- type : 'User' ,
377+ const mockDiscussionAuthor = {
378+ __typename : 'User' as const ,
379+ ' $fragmentRefs' : {
380+ AuthorFields_User_Fragment : {
381+ __typename : 'User' as const ,
382+ login : 'comment-user' ,
383+ url : 'https://github.com/comment-user' as Link ,
384+ avatar_url :
385+ 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
386+ type : 'User' as const ,
387+ } ,
388+ } ,
382389} ;
383390
384- const mockDiscussionReplier : DiscussionAuthor = {
385- login : 'reply-user' ,
386- url : 'https://github.com/reply-user' as Link ,
387- avatar_url : 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
388- type : 'User' ,
391+ const mockDiscussionReplier = {
392+ __typename : 'User' as const ,
393+ ' $fragmentRefs' : {
394+ AuthorFields_User_Fragment : {
395+ __typename : 'User' as const ,
396+ login : 'reply-user' ,
397+ url : 'https://github.com/reply-user' as Link ,
398+ avatar_url :
399+ 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
400+ type : 'User' as const ,
401+ } ,
402+ } ,
389403} ;
390404
391- export const mockDiscussionComments : DiscussionComments = {
405+ const mockDiscussionComments = {
392406 nodes : [
393- {
394- databaseId : 2258799 ,
395- createdAt : '2017-02-20T17:51:57Z' ,
396- author : mockDiscussionAuthor ,
397- replies : {
398- nodes : [
399- {
400- databaseId : 2300902 ,
401- createdAt : '2017-05-20T17:51:57Z' ,
402- author : mockDiscussionReplier ,
403- } ,
404- ] ,
407+ makeFragmentData (
408+ {
409+ __typename : 'DiscussionComment' as const ,
410+ databaseId : 2258799 ,
411+ createdAt : '2017-02-20T17:51:57Z' ,
412+ author : mockDiscussionAuthor ,
413+ replies : {
414+ __typename : 'DiscussionCommentConnection' as const ,
415+ nodes : [
416+ makeFragmentData (
417+ {
418+ __typename : 'DiscussionComment' as const ,
419+ databaseId : 2300902 ,
420+ createdAt : '2017-05-20T17:51:57Z' ,
421+ author : mockDiscussionReplier ,
422+ } ,
423+ CommentFieldsFragmentDoc ,
424+ ) ,
425+ ] ,
426+ } ,
405427 } ,
406- } ,
428+ DiscussionCommentFieldsFragmentDoc ,
429+ ) ,
407430 ] ,
408431 totalCount : 2 ,
409432} ;
410433
411- export const mockDiscussionLabels : DiscussionLabels = {
434+ const mockDiscussionLabels = {
435+ __typename : 'LabelConnection' as const ,
412436 nodes : [
413437 {
438+ __typename : 'Label' as const ,
414439 name : 'enhancement' ,
415440 } ,
416441 ] ,
417442} ;
418443
419- export const mockGraphQLResponse : GitHubGraphQLResponse < FetchDiscussionsQuery > =
420- {
421- data : {
422- search : {
423- nodes : [
424- {
425- number : 123 ,
426- title : '1.16.0' ,
427- isAnswered : false ,
428- stateReason : 'OPEN' ,
429- url : 'https://github.com/gitify-app/notifications-test/discussions/612' as Link ,
430- author : {
431- login : 'discussion-creator' ,
432- url : 'https://github.com/discussion-creator' as Link ,
433- avatar_url :
434- 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
435- type : 'User' ,
444+ export const mockGraphQLResponse : FetchDiscussionsQuery = {
445+ search : {
446+ __typename : 'SearchResultItemConnection' ,
447+ nodes : [
448+ makeFragmentData (
449+ {
450+ __typename : 'Discussion' as const ,
451+ number : 123 ,
452+ title : '1.16.0' ,
453+ isAnswered : false ,
454+ stateReason : null ,
455+ url : 'https://github.com/gitify-app/notifications-test/discussions/612' as Link ,
456+ author : {
457+ __typename : 'User' as const ,
458+ ' $fragmentRefs' : {
459+ AuthorFields_User_Fragment : {
460+ __typename : 'User' as const ,
461+ login : 'discussion-creator' ,
462+ url : 'https://github.com/discussion-creator' as Link ,
463+ avatar_url :
464+ 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link ,
465+ type : 'User' as const ,
466+ } ,
436467 } ,
437- comments : mockDiscussionComments ,
438- labels : mockDiscussionLabels ,
439468 } ,
440- ] ,
441- } ,
442- } ,
443- } ;
469+ comments : mockDiscussionComments ,
470+ labels : mockDiscussionLabels ,
471+ } ,
472+ DiscussionFieldsFragmentDoc ,
473+ ) ,
474+ ] ,
475+ } ,
476+ } ;
444477
445478export const mockSingleNotification : Notification = mockGitHubNotifications [ 0 ] ;
0 commit comments