Skip to content

Commit 6edeb5c

Browse files
committed
refactor: tests
Signed-off-by: Adam Setch <[email protected]>
1 parent 7f17bb0 commit 6edeb5c

File tree

10 files changed

+774
-664
lines changed

10 files changed

+774
-664
lines changed

src/renderer/utils/api/client.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import {
2323
type FetchDiscussionByNumberQuery,
2424
FetchIssueByNumberDocument,
2525
type FetchIssueByNumberQuery,
26-
FetchPullByNumberDocument,
27-
type FetchPullByNumberQuery,
26+
FetchPullRequestByNumberDocument,
27+
type FetchPullRequestByNumberQuery,
2828
} from './graphql/generated/graphql';
2929
import { apiRequestAuth, performGraphQLRequest } from './request';
3030
import {
@@ -205,6 +205,7 @@ export async function fetchIssueByNumber(
205205
name: notification.repository.name,
206206
number: number,
207207
firstLabels: 100,
208+
lastComments: 1,
208209
},
209210
);
210211
}
@@ -214,19 +215,22 @@ export async function fetchIssueByNumber(
214215
*/
215216
export async function fetchPullByNumber(
216217
notification: Notification,
217-
): Promise<ExecutionResult<FetchPullByNumberQuery>> {
218+
): Promise<ExecutionResult<FetchPullRequestByNumberQuery>> {
218219
const url = getGitHubGraphQLUrl(notification.account.hostname);
219220
const number = getNumberFromUrl(notification.subject.url);
220221

221222
return performGraphQLRequest(
222223
url.toString() as Link,
223224
notification.account.token,
224-
FetchPullByNumberDocument,
225+
FetchPullRequestByNumberDocument,
225226
{
226227
owner: notification.repository.owner.login,
227228
name: notification.repository.name,
228229
number: number,
229230
firstLabels: 100,
231+
firstClosingIssues: 100,
232+
lastComments: 1,
233+
lastReviews: 100,
230234
},
231235
);
232236
}

src/renderer/utils/api/graphql/generated/gql.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import * as types from './graphql';
1717
type Documents = {
1818
"fragment AuthorFields on Actor {\n login\n html_url: url\n avatar_url: avatarUrl\n type: __typename\n}": typeof types.AuthorFieldsFragmentDoc,
1919
"query FetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n url\n}": typeof types.FetchDiscussionByNumberDocument,
20-
"query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": typeof types.FetchIssueByNumberDocument,
21-
"query FetchPullByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: 100) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: 50) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": typeof types.FetchPullByNumberDocument,
20+
"query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": typeof types.FetchIssueByNumberDocument,
21+
"query FetchPullRequestByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int, $lastComments: Int, $lastReviews: Int, $firstClosingIssues: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: $lastReviews) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: $firstClosingIssues) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": typeof types.FetchPullRequestByNumberDocument,
2222
};
2323
const documents: Documents = {
2424
"fragment AuthorFields on Actor {\n login\n html_url: url\n avatar_url: avatarUrl\n type: __typename\n}": types.AuthorFieldsFragmentDoc,
2525
"query FetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n url\n}": types.FetchDiscussionByNumberDocument,
26-
"query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": types.FetchIssueByNumberDocument,
27-
"query FetchPullByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: 100) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: 50) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": types.FetchPullByNumberDocument,
26+
"query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": types.FetchIssueByNumberDocument,
27+
"query FetchPullRequestByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int, $lastComments: Int, $lastReviews: Int, $firstClosingIssues: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: $lastReviews) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: $firstClosingIssues) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}": types.FetchPullRequestByNumberDocument,
2828
};
2929

3030
/**
@@ -38,11 +38,11 @@ export function graphql(source: "query FetchDiscussionByNumber($owner: String!,
3838
/**
3939
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
4040
*/
41-
export function graphql(source: "query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}"): typeof import('./graphql').FetchIssueByNumberDocument;
41+
export function graphql(source: "query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n issue(number: $number) {\n __typename\n number\n title\n url\n state\n stateReason\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}"): typeof import('./graphql').FetchIssueByNumberDocument;
4242
/**
4343
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
4444
*/
45-
export function graphql(source: "query FetchPullByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: 1) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: 100) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: 50) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}"): typeof import('./graphql').FetchPullByNumberDocument;
45+
export function graphql(source: "query FetchPullRequestByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int, $lastComments: Int, $lastReviews: Int, $firstClosingIssues: Int) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n __typename\n number\n title\n url\n state\n merged\n isDraft\n isInMergeQueue\n milestone {\n ...MilestoneFields\n }\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n url\n author {\n ...AuthorFields\n }\n }\n }\n reviews(last: $lastReviews) {\n totalCount\n nodes {\n state\n author {\n login\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n closingIssuesReferences(first: $firstClosingIssues) {\n nodes {\n number\n }\n }\n }\n }\n}\n\nfragment MilestoneFields on Milestone {\n state\n title\n}"): typeof import('./graphql').FetchPullRequestByNumberDocument;
4646

4747

4848
export function graphql(source: string) {

src/renderer/utils/api/graphql/generated/graphql.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35955,6 +35955,7 @@ export type FetchIssueByNumberQueryVariables = Exact<{
3595535955
owner: Scalars['String']['input'];
3595635956
name: Scalars['String']['input'];
3595735957
number: Scalars['Int']['input'];
35958+
lastComments?: InputMaybe<Scalars['Int']['input']>;
3595835959
firstLabels?: InputMaybe<Scalars['Int']['input']>;
3595935960
}>;
3596035961

@@ -35975,15 +35976,18 @@ export type FetchIssueByNumberQuery = { __typename?: 'Query', repository?: { __t
3597535976

3597635977
export type MilestoneFieldsFragment = { __typename?: 'Milestone', state: MilestoneState, title: string };
3597735978

35978-
export type FetchPullByNumberQueryVariables = Exact<{
35979+
export type FetchPullRequestByNumberQueryVariables = Exact<{
3597935980
owner: Scalars['String']['input'];
3598035981
name: Scalars['String']['input'];
3598135982
number: Scalars['Int']['input'];
3598235983
firstLabels?: InputMaybe<Scalars['Int']['input']>;
35984+
lastComments?: InputMaybe<Scalars['Int']['input']>;
35985+
lastReviews?: InputMaybe<Scalars['Int']['input']>;
35986+
firstClosingIssues?: InputMaybe<Scalars['Int']['input']>;
3598335987
}>;
3598435988

3598535989

35986-
export type FetchPullByNumberQuery = { __typename?: 'Query', repository?: { __typename?: 'Repository', pullRequest?: { __typename: 'PullRequest', number: number, title: string, url: any, state: PullRequestState, merged: boolean, isDraft: boolean, isInMergeQueue: boolean, milestone?: { __typename?: 'Milestone', state: MilestoneState, title: string } | null, author?:
35990+
export type FetchPullRequestByNumberQuery = { __typename?: 'Query', repository?: { __typename?: 'Repository', pullRequest?: { __typename: 'PullRequest', number: number, title: string, url: any, state: PullRequestState, merged: boolean, isDraft: boolean, isInMergeQueue: boolean, milestone?: { __typename?: 'Milestone', state: MilestoneState, title: string } | null, author?:
3598735991
| { __typename?: 'Bot', login: string, html_url: any, avatar_url: any, type: 'Bot' }
3598835992
| { __typename?: 'EnterpriseUserAccount', login: string, html_url: any, avatar_url: any, type: 'EnterpriseUserAccount' }
3598935993
| { __typename?: 'Mannequin', login: string, html_url: any, avatar_url: any, type: 'Mannequin' }
@@ -36097,7 +36101,7 @@ fragment CommentFields on DiscussionComment {
3609736101
url
3609836102
}`) as unknown as TypedDocumentString<FetchDiscussionByNumberQuery, FetchDiscussionByNumberQueryVariables>;
3609936103
export const FetchIssueByNumberDocument = new TypedDocumentString(`
36100-
query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {
36104+
query FetchIssueByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $firstLabels: Int) {
3610136105
repository(owner: $owner, name: $name) {
3610236106
issue(number: $number) {
3610336107
__typename
@@ -36112,7 +36116,7 @@ export const FetchIssueByNumberDocument = new TypedDocumentString(`
3611236116
author {
3611336117
...AuthorFields
3611436118
}
36115-
comments(last: 1) {
36119+
comments(last: $lastComments) {
3611636120
totalCount
3611736121
nodes {
3611836122
url
@@ -36139,8 +36143,8 @@ fragment MilestoneFields on Milestone {
3613936143
state
3614036144
title
3614136145
}`) as unknown as TypedDocumentString<FetchIssueByNumberQuery, FetchIssueByNumberQueryVariables>;
36142-
export const FetchPullByNumberDocument = new TypedDocumentString(`
36143-
query FetchPullByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int) {
36146+
export const FetchPullRequestByNumberDocument = new TypedDocumentString(`
36147+
query FetchPullRequestByNumber($owner: String!, $name: String!, $number: Int!, $firstLabels: Int, $lastComments: Int, $lastReviews: Int, $firstClosingIssues: Int) {
3614436148
repository(owner: $owner, name: $name) {
3614536149
pullRequest(number: $number) {
3614636150
__typename
@@ -36157,7 +36161,7 @@ export const FetchPullByNumberDocument = new TypedDocumentString(`
3615736161
author {
3615836162
...AuthorFields
3615936163
}
36160-
comments(last: 1) {
36164+
comments(last: $lastComments) {
3616136165
totalCount
3616236166
nodes {
3616336167
url
@@ -36166,7 +36170,7 @@ export const FetchPullByNumberDocument = new TypedDocumentString(`
3616636170
}
3616736171
}
3616836172
}
36169-
reviews(last: 100) {
36173+
reviews(last: $lastReviews) {
3617036174
totalCount
3617136175
nodes {
3617236176
state
@@ -36180,7 +36184,7 @@ export const FetchPullByNumberDocument = new TypedDocumentString(`
3618036184
name
3618136185
}
3618236186
}
36183-
closingIssuesReferences(first: 50) {
36187+
closingIssuesReferences(first: $firstClosingIssues) {
3618436188
nodes {
3618536189
number
3618636190
}
@@ -36197,4 +36201,4 @@ export const FetchPullByNumberDocument = new TypedDocumentString(`
3619736201
fragment MilestoneFields on Milestone {
3619836202
state
3619936203
title
36200-
}`) as unknown as TypedDocumentString<FetchPullByNumberQuery, FetchPullByNumberQueryVariables>;
36204+
}`) as unknown as TypedDocumentString<FetchPullRequestByNumberQuery, FetchPullRequestByNumberQueryVariables>;

src/renderer/utils/api/graphql/issue.graphql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ query FetchIssueByNumber(
22
$owner: String!
33
$name: String!
44
$number: Int!
5+
$lastComments: Int
56
$firstLabels: Int
67
) {
78
repository(owner: $owner, name: $name) {
@@ -18,7 +19,7 @@ query FetchIssueByNumber(
1819
author {
1920
...AuthorFields
2021
}
21-
comments(last: 1) {
22+
comments(last: $lastComments) {
2223
totalCount
2324
nodes {
2425
url

0 commit comments

Comments
 (0)