-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test:
api.items.add-draft-with-invalid-date
(#139)
in preparation of #136
- Loading branch information
Showing
5 changed files
with
563 additions
and
0 deletions.
There are no files selected for viewing
295 changes: 295 additions & 0 deletions
295
test/recorded/api.items.add-draft-with-invalid-date/fixtures.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,295 @@ | ||
[ | ||
{ | ||
"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", | ||
"variables": { | ||
"owner": "github-project-fixtures", | ||
"number": 2 | ||
}, | ||
"response": { | ||
"status": 200, | ||
"url": "https://api.github.com/graphql", | ||
"headers": { | ||
"access-control-allow-origin": "*", | ||
"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", | ||
"content-encoding": "gzip", | ||
"content-security-policy": "default-src 'none'", | ||
"content-type": "application/json; charset=utf-8", | ||
"date": "Thu, 05 Oct 2023 04:35:44 GMT", | ||
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", | ||
"server": "GitHub.com", | ||
"strict-transport-security": "max-age=31536000; includeSubdomains; preload", | ||
"transfer-encoding": "chunked", | ||
"vary": "Accept-Encoding, Accept, X-Requested-With", | ||
"x-content-type-options": "nosniff", | ||
"x-frame-options": "deny", | ||
"x-github-media-type": "github.v3; format=json", | ||
"x-github-request-id": "E162:88D1:45E4EE:490B6D:651E3D20", | ||
"x-ratelimit-limit": "5000", | ||
"x-ratelimit-remaining": "4977", | ||
"x-ratelimit-reset": "1696484061", | ||
"x-ratelimit-resource": "graphql", | ||
"x-ratelimit-used": "23", | ||
"x-xss-protection": "0" | ||
}, | ||
"data": { | ||
"data": { | ||
"userOrOrganization": { | ||
"projectV2": { | ||
"id": "PVT_1", | ||
"title": "@gr2m's Test Fixtures", | ||
"url": "https://github.com/orgs/github-project-fixtures/projects/2", | ||
"databaseId": 1001, | ||
"fields": { | ||
"nodes": [ | ||
{ | ||
"id": "PVTF_1", | ||
"dataType": "TITLE", | ||
"name": "Title" | ||
}, | ||
{ | ||
"id": "PVTF_2", | ||
"dataType": "ASSIGNEES", | ||
"name": "Assignees" | ||
}, | ||
{ | ||
"id": "PVTSSF_1", | ||
"dataType": "SINGLE_SELECT", | ||
"name": "Status", | ||
"options": [ | ||
{ | ||
"id": "f75ad846", | ||
"name": "Todo" | ||
}, | ||
{ | ||
"id": "47fc9ee4", | ||
"name": "In Progress" | ||
}, | ||
{ | ||
"id": "98236657", | ||
"name": "Done" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "PVTF_3", | ||
"dataType": "LABELS", | ||
"name": "Labels" | ||
}, | ||
{ | ||
"id": "PVTF_4", | ||
"dataType": "LINKED_PULL_REQUESTS", | ||
"name": "Linked pull requests" | ||
}, | ||
{ | ||
"id": "PVTF_5", | ||
"dataType": "REVIEWERS", | ||
"name": "Reviewers" | ||
}, | ||
{ | ||
"id": "PVTF_6", | ||
"dataType": "REPOSITORY", | ||
"name": "Repository" | ||
}, | ||
{ | ||
"id": "PVTF_7", | ||
"dataType": "MILESTONE", | ||
"name": "Milestone" | ||
}, | ||
{ | ||
"id": "PVTF_8", | ||
"dataType": "TEXT", | ||
"name": "Text" | ||
}, | ||
{ | ||
"id": "PVTF_9", | ||
"dataType": "NUMBER", | ||
"name": "Number" | ||
}, | ||
{ | ||
"id": "PVTF_10", | ||
"dataType": "DATE", | ||
"name": "Date" | ||
}, | ||
{ | ||
"id": "PVTSSF_2", | ||
"dataType": "SINGLE_SELECT", | ||
"name": "Single select", | ||
"options": [ | ||
{ | ||
"id": "b92ebdaa", | ||
"name": "One" | ||
}, | ||
{ | ||
"id": "8a0f266e", | ||
"name": "Two" | ||
}, | ||
{ | ||
"id": "7ec185b4", | ||
"name": "Three" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "PVTIF_1", | ||
"dataType": "ITERATION", | ||
"name": "Iteration", | ||
"configuration": { | ||
"iterations": [], | ||
"completedIterations": [ | ||
{ | ||
"title": "Iteration 3", | ||
"duration": 14, | ||
"startDate": "2022-08-05" | ||
}, | ||
{ | ||
"title": "Iteration 2", | ||
"duration": 14, | ||
"startDate": "2022-07-22" | ||
}, | ||
{ | ||
"title": "Iteration 1", | ||
"duration": 14, | ||
"startDate": "2022-07-08" | ||
} | ||
], | ||
"duration": 14, | ||
"startDay": 5 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"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", | ||
"variables": { | ||
"projectId": "PVT_1", | ||
"title": "test" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"url": "https://api.github.com/graphql", | ||
"headers": { | ||
"access-control-allow-origin": "*", | ||
"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", | ||
"content-encoding": "gzip", | ||
"content-security-policy": "default-src 'none'", | ||
"content-type": "application/json; charset=utf-8", | ||
"date": "Thu, 05 Oct 2023 04:35:45 GMT", | ||
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", | ||
"server": "GitHub.com", | ||
"strict-transport-security": "max-age=31536000; includeSubdomains; preload", | ||
"transfer-encoding": "chunked", | ||
"vary": "Accept-Encoding, Accept, X-Requested-With", | ||
"x-content-type-options": "nosniff", | ||
"x-frame-options": "deny", | ||
"x-github-media-type": "github.v3; format=json", | ||
"x-github-request-id": "E162:88D1:45E5CB:490C4B:651E3D20", | ||
"x-ratelimit-limit": "5000", | ||
"x-ratelimit-remaining": "4976", | ||
"x-ratelimit-reset": "1696484061", | ||
"x-ratelimit-resource": "graphql", | ||
"x-ratelimit-used": "24", | ||
"x-xss-protection": "0" | ||
}, | ||
"data": { | ||
"data": { | ||
"addProjectV2DraftIssue": { | ||
"projectItem": { | ||
"id": "PVTI_1", | ||
"createdAt": "2022-02-02T12:00:00Z", | ||
"type": "DRAFT_ISSUE", | ||
"isArchived": false, | ||
"content": { | ||
"id": "DI_1", | ||
"title": "test", | ||
"createdAt": "2022-02-02T12:00:00Z", | ||
"updatedAt": "2022-02-02T12:00:00Z", | ||
"author": { | ||
"login": "gh-project-fixtures" | ||
}, | ||
"assignees": { | ||
"nodes": [] | ||
} | ||
}, | ||
"fieldValues": { | ||
"nodes": [ | ||
{ | ||
"__typename": "ProjectV2ItemFieldTextValue", | ||
"text": "test", | ||
"field": { | ||
"id": "PVTF_1" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"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 ", | ||
"variables": { | ||
"projectId": "PVT_1", | ||
"itemId": "PVTI_1" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"url": "https://api.github.com/graphql", | ||
"headers": { | ||
"access-control-allow-origin": "*", | ||
"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", | ||
"content-encoding": "gzip", | ||
"content-security-policy": "default-src 'none'", | ||
"content-type": "application/json; charset=utf-8", | ||
"date": "Thu, 05 Oct 2023 04:35:46 GMT", | ||
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", | ||
"server": "GitHub.com", | ||
"strict-transport-security": "max-age=31536000; includeSubdomains; preload", | ||
"transfer-encoding": "chunked", | ||
"vary": "Accept-Encoding, Accept, X-Requested-With", | ||
"x-content-type-options": "nosniff", | ||
"x-frame-options": "deny", | ||
"x-github-media-type": "github.v3; format=json", | ||
"x-github-request-id": "E162:88D1:45E69E:490D25:651E3D21", | ||
"x-ratelimit-limit": "5000", | ||
"x-ratelimit-remaining": "4976", | ||
"x-ratelimit-reset": "1696484061", | ||
"x-ratelimit-resource": "graphql", | ||
"x-ratelimit-used": "24", | ||
"x-xss-protection": "0" | ||
}, | ||
"data": { | ||
"errors": [ | ||
{ | ||
"path": [ | ||
"mutation setItemProperties", | ||
"date", | ||
"input", | ||
"value", | ||
"date" | ||
], | ||
"extensions": { | ||
"code": "argumentLiteralsIncompatible", | ||
"typeName": "InputObject", | ||
"argumentName": "date" | ||
}, | ||
"locations": [ | ||
{ | ||
"line": 4, | ||
"column": 143 | ||
} | ||
], | ||
"message": "Argument 'date' on InputObject 'ProjectV2FieldValue' has an invalid value (\"<invalid>\"). Expected type 'Date'." | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] |
16 changes: 16 additions & 0 deletions
16
test/recorded/api.items.add-draft-with-invalid-date/prepare.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @ts-check | ||
|
||
/** | ||
* Prepare state in order to record fixtures for test.js. Returns array of arguments that will be passed | ||
* passed as `test(project, ...arguments)`. | ||
* | ||
* @param {import("@octokit/openapi-types").components["schemas"]["repository"]} repository | ||
* @param {import("@octokit/core").Octokit} octokit | ||
* @param {import("../../..").default<{text: string, number: number, date: string, singleSelect: "One" | "Two" | "Three"}>} project | ||
* | ||
* @returns {Promise<[]>} | ||
*/ | ||
export async function prepare(repository, octokit, project) { | ||
// no preparation is needed | ||
return []; | ||
} |
16 changes: 16 additions & 0 deletions
16
test/recorded/api.items.add-draft-with-invalid-date/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @ts-check | ||
|
||
/** | ||
* @param {import("../../..").default} project | ||
*/ | ||
export function test(project) { | ||
return project.items.addDraft({ title: "test" }, { date: "<invalid>" }).then( | ||
() => { | ||
throw new Error("Expected error"); | ||
}, | ||
(error) => ({ | ||
error, | ||
// humanMessage: error.toHumanMessage(), | ||
}) | ||
); | ||
} |
Oops, something went wrong.