Skip to content

Commit 604d68a

Browse files
authored
test: api.items.add-draft-with-invalid-date (#139)
in preparation of #136
1 parent b48e962 commit 604d68a

5 files changed

Lines changed: 563 additions & 0 deletions

File tree

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
[
2+
{
3+
"query": "\n query getProjectCoreData($owner: String!, $number: Int!) {\n userOrOrganization: repositoryOwner(login: $owner) {\n ... on ProjectV2Owner {\n projectV2(number: $number) {\n \n id\n title\n url\n databaseId\n fields(first: 50) {\n nodes {\n ... on ProjectV2FieldCommon {\n id\n dataType\n name\n }\n ... on ProjectV2SingleSelectField {\n options {\n id\n name\n }\n }\n ... on ProjectV2IterationField {\n configuration {\n iterations {\n title\n duration\n startDate\n }\n completedIterations {\n title\n duration\n startDate\n }\n duration\n startDay\n }\n }\n }\n }\n\n }\n }\n }\n }\n",
4+
"variables": {
5+
"owner": "github-project-fixtures",
6+
"number": 2
7+
},
8+
"response": {
9+
"status": 200,
10+
"url": "https://api.github.com/graphql",
11+
"headers": {
12+
"access-control-allow-origin": "*",
13+
"access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
14+
"content-encoding": "gzip",
15+
"content-security-policy": "default-src 'none'",
16+
"content-type": "application/json; charset=utf-8",
17+
"date": "Thu, 05 Oct 2023 04:35:44 GMT",
18+
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
19+
"server": "GitHub.com",
20+
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
21+
"transfer-encoding": "chunked",
22+
"vary": "Accept-Encoding, Accept, X-Requested-With",
23+
"x-content-type-options": "nosniff",
24+
"x-frame-options": "deny",
25+
"x-github-media-type": "github.v3; format=json",
26+
"x-github-request-id": "E162:88D1:45E4EE:490B6D:651E3D20",
27+
"x-ratelimit-limit": "5000",
28+
"x-ratelimit-remaining": "4977",
29+
"x-ratelimit-reset": "1696484061",
30+
"x-ratelimit-resource": "graphql",
31+
"x-ratelimit-used": "23",
32+
"x-xss-protection": "0"
33+
},
34+
"data": {
35+
"data": {
36+
"userOrOrganization": {
37+
"projectV2": {
38+
"id": "PVT_1",
39+
"title": "@gr2m's Test Fixtures",
40+
"url": "https://github.com/orgs/github-project-fixtures/projects/2",
41+
"databaseId": 1001,
42+
"fields": {
43+
"nodes": [
44+
{
45+
"id": "PVTF_1",
46+
"dataType": "TITLE",
47+
"name": "Title"
48+
},
49+
{
50+
"id": "PVTF_2",
51+
"dataType": "ASSIGNEES",
52+
"name": "Assignees"
53+
},
54+
{
55+
"id": "PVTSSF_1",
56+
"dataType": "SINGLE_SELECT",
57+
"name": "Status",
58+
"options": [
59+
{
60+
"id": "f75ad846",
61+
"name": "Todo"
62+
},
63+
{
64+
"id": "47fc9ee4",
65+
"name": "In Progress"
66+
},
67+
{
68+
"id": "98236657",
69+
"name": "Done"
70+
}
71+
]
72+
},
73+
{
74+
"id": "PVTF_3",
75+
"dataType": "LABELS",
76+
"name": "Labels"
77+
},
78+
{
79+
"id": "PVTF_4",
80+
"dataType": "LINKED_PULL_REQUESTS",
81+
"name": "Linked pull requests"
82+
},
83+
{
84+
"id": "PVTF_5",
85+
"dataType": "REVIEWERS",
86+
"name": "Reviewers"
87+
},
88+
{
89+
"id": "PVTF_6",
90+
"dataType": "REPOSITORY",
91+
"name": "Repository"
92+
},
93+
{
94+
"id": "PVTF_7",
95+
"dataType": "MILESTONE",
96+
"name": "Milestone"
97+
},
98+
{
99+
"id": "PVTF_8",
100+
"dataType": "TEXT",
101+
"name": "Text"
102+
},
103+
{
104+
"id": "PVTF_9",
105+
"dataType": "NUMBER",
106+
"name": "Number"
107+
},
108+
{
109+
"id": "PVTF_10",
110+
"dataType": "DATE",
111+
"name": "Date"
112+
},
113+
{
114+
"id": "PVTSSF_2",
115+
"dataType": "SINGLE_SELECT",
116+
"name": "Single select",
117+
"options": [
118+
{
119+
"id": "b92ebdaa",
120+
"name": "One"
121+
},
122+
{
123+
"id": "8a0f266e",
124+
"name": "Two"
125+
},
126+
{
127+
"id": "7ec185b4",
128+
"name": "Three"
129+
}
130+
]
131+
},
132+
{
133+
"id": "PVTIF_1",
134+
"dataType": "ITERATION",
135+
"name": "Iteration",
136+
"configuration": {
137+
"iterations": [],
138+
"completedIterations": [
139+
{
140+
"title": "Iteration 3",
141+
"duration": 14,
142+
"startDate": "2022-08-05"
143+
},
144+
{
145+
"title": "Iteration 2",
146+
"duration": 14,
147+
"startDate": "2022-07-22"
148+
},
149+
{
150+
"title": "Iteration 1",
151+
"duration": 14,
152+
"startDate": "2022-07-08"
153+
}
154+
],
155+
"duration": 14,
156+
"startDay": 5
157+
}
158+
}
159+
]
160+
}
161+
}
162+
}
163+
}
164+
}
165+
}
166+
},
167+
{
168+
"query": "\n mutation addProjectV2DraftIssue($projectId: ID!, $title: String!, $body: String, $assigneeIds: [ID!]) {\n addProjectV2DraftIssue(input: {projectId: $projectId, title: $title, body: $body, assigneeIds: $assigneeIds}) {\n projectItem {\n \n id\n createdAt\n type\n isArchived\n \n content {\n ... on DraftIssue {\n id\n title\n createdAt\n updatedAt\n author: creator {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n }\n ... on Issue {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n closedAt\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n }\n ... on PullRequest {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n closedAt\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n merged\n }\n }\n\n fieldValues(first: 20) {\n nodes {\n __typename\n ... on ProjectV2ItemFieldDateValue {\n date\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldIterationValue {\n title\n iterationId\n startDate\n duration\n field {\n ... on ProjectV2IterationField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldNumberValue {\n number\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldSingleSelectValue {\n optionId\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldTextValue {\n text\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n }\n }\n\n }\n }\n }\n",
169+
"variables": {
170+
"projectId": "PVT_1",
171+
"title": "test"
172+
},
173+
"response": {
174+
"status": 200,
175+
"url": "https://api.github.com/graphql",
176+
"headers": {
177+
"access-control-allow-origin": "*",
178+
"access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
179+
"content-encoding": "gzip",
180+
"content-security-policy": "default-src 'none'",
181+
"content-type": "application/json; charset=utf-8",
182+
"date": "Thu, 05 Oct 2023 04:35:45 GMT",
183+
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
184+
"server": "GitHub.com",
185+
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
186+
"transfer-encoding": "chunked",
187+
"vary": "Accept-Encoding, Accept, X-Requested-With",
188+
"x-content-type-options": "nosniff",
189+
"x-frame-options": "deny",
190+
"x-github-media-type": "github.v3; format=json",
191+
"x-github-request-id": "E162:88D1:45E5CB:490C4B:651E3D20",
192+
"x-ratelimit-limit": "5000",
193+
"x-ratelimit-remaining": "4976",
194+
"x-ratelimit-reset": "1696484061",
195+
"x-ratelimit-resource": "graphql",
196+
"x-ratelimit-used": "24",
197+
"x-xss-protection": "0"
198+
},
199+
"data": {
200+
"data": {
201+
"addProjectV2DraftIssue": {
202+
"projectItem": {
203+
"id": "PVTI_1",
204+
"createdAt": "2022-02-02T12:00:00Z",
205+
"type": "DRAFT_ISSUE",
206+
"isArchived": false,
207+
"content": {
208+
"id": "DI_1",
209+
"title": "test",
210+
"createdAt": "2022-02-02T12:00:00Z",
211+
"updatedAt": "2022-02-02T12:00:00Z",
212+
"author": {
213+
"login": "gh-project-fixtures"
214+
},
215+
"assignees": {
216+
"nodes": []
217+
}
218+
},
219+
"fieldValues": {
220+
"nodes": [
221+
{
222+
"__typename": "ProjectV2ItemFieldTextValue",
223+
"text": "test",
224+
"field": {
225+
"id": "PVTF_1"
226+
}
227+
}
228+
]
229+
}
230+
}
231+
}
232+
}
233+
}
234+
}
235+
},
236+
{
237+
"query": "\n mutation setItemProperties($projectId: ID!, $itemId: ID!) {\n \n date: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLQw\", value: {date: \"<invalid>\"}}) {\n projectV2Item { \n id\n createdAt\n type\n isArchived\n \n content {\n ... on DraftIssue {\n id\n title\n createdAt\n updatedAt\n author: creator {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n }\n ... on Issue {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n closedAt\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n }\n ... on PullRequest {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n closedAt\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n merged\n }\n }\n\n fieldValues(first: 20) {\n nodes {\n __typename\n ... on ProjectV2ItemFieldDateValue {\n date\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldIterationValue {\n title\n iterationId\n startDate\n duration\n field {\n ... on ProjectV2IterationField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldNumberValue {\n number\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldSingleSelectValue {\n optionId\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldTextValue {\n text\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n }\n }\n }\n }\n \n }\n ",
238+
"variables": {
239+
"projectId": "PVT_1",
240+
"itemId": "PVTI_1"
241+
},
242+
"response": {
243+
"status": 200,
244+
"url": "https://api.github.com/graphql",
245+
"headers": {
246+
"access-control-allow-origin": "*",
247+
"access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
248+
"content-encoding": "gzip",
249+
"content-security-policy": "default-src 'none'",
250+
"content-type": "application/json; charset=utf-8",
251+
"date": "Thu, 05 Oct 2023 04:35:46 GMT",
252+
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
253+
"server": "GitHub.com",
254+
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
255+
"transfer-encoding": "chunked",
256+
"vary": "Accept-Encoding, Accept, X-Requested-With",
257+
"x-content-type-options": "nosniff",
258+
"x-frame-options": "deny",
259+
"x-github-media-type": "github.v3; format=json",
260+
"x-github-request-id": "E162:88D1:45E69E:490D25:651E3D21",
261+
"x-ratelimit-limit": "5000",
262+
"x-ratelimit-remaining": "4976",
263+
"x-ratelimit-reset": "1696484061",
264+
"x-ratelimit-resource": "graphql",
265+
"x-ratelimit-used": "24",
266+
"x-xss-protection": "0"
267+
},
268+
"data": {
269+
"errors": [
270+
{
271+
"path": [
272+
"mutation setItemProperties",
273+
"date",
274+
"input",
275+
"value",
276+
"date"
277+
],
278+
"extensions": {
279+
"code": "argumentLiteralsIncompatible",
280+
"typeName": "InputObject",
281+
"argumentName": "date"
282+
},
283+
"locations": [
284+
{
285+
"line": 4,
286+
"column": 143
287+
}
288+
],
289+
"message": "Argument 'date' on InputObject 'ProjectV2FieldValue' has an invalid value (\"<invalid>\"). Expected type 'Date'."
290+
}
291+
]
292+
}
293+
}
294+
}
295+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @ts-check
2+
3+
/**
4+
* Prepare state in order to record fixtures for test.js. Returns array of arguments that will be passed
5+
* passed as `test(project, ...arguments)`.
6+
*
7+
* @param {import("@octokit/openapi-types").components["schemas"]["repository"]} repository
8+
* @param {import("@octokit/core").Octokit} octokit
9+
* @param {import("../../..").default<{text: string, number: number, date: string, singleSelect: "One" | "Two" | "Three"}>} project
10+
*
11+
* @returns {Promise<[]>}
12+
*/
13+
export async function prepare(repository, octokit, project) {
14+
// no preparation is needed
15+
return [];
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @ts-check
2+
3+
/**
4+
* @param {import("../../..").default} project
5+
*/
6+
export function test(project) {
7+
return project.items.addDraft({ title: "test" }, { date: "<invalid>" }).then(
8+
() => {
9+
throw new Error("Expected error");
10+
},
11+
(error) => ({
12+
error,
13+
// humanMessage: error.toHumanMessage(),
14+
})
15+
);
16+
}

0 commit comments

Comments
 (0)