|
|
@@ -21,8 +21,7 @@ const projectGraphqlData = ({
|
|
|
startDate = null,
|
|
|
startDateField = true,
|
|
|
startDateType = 'DATE',
|
|
|
- startDateIsIssueField = true,
|
|
|
- startDateIssueField = true,
|
|
|
+ startDateIsIssueField = false,
|
|
|
} = {}) => ({
|
|
|
organization: {
|
|
|
projectV2: {
|
|
|
@@ -34,11 +33,10 @@ const projectGraphqlData = ({
|
|
|
...(startDateField
|
|
|
? [
|
|
|
{
|
|
|
- id: 'start-date-project-field-id',
|
|
|
- name: 'Start date',
|
|
|
+ id: 'start-date-field-id',
|
|
|
+ name: 'Start Date',
|
|
|
dataType: startDateType,
|
|
|
isIssueField: startDateIsIssueField,
|
|
|
- issueField: startDateIssueField ? { id: 'start-date-issue-field-id' } : null,
|
|
|
},
|
|
|
]
|
|
|
: []),
|
|
|
@@ -56,8 +54,7 @@ const projectGraphqlData = ({
|
|
|
id: 'item-id',
|
|
|
project: { id: 'project-id' },
|
|
|
fieldValueByName: { name: 'Inbox', optionId: 'inbox-option-id' },
|
|
|
- startDateValue:
|
|
|
- startDate === null ? null : { issueFieldValue: { value: startDate } },
|
|
|
+ startDateValue: startDate === null ? null : { date: startDate },
|
|
|
},
|
|
|
]
|
|
|
: [],
|
|
|
@@ -269,27 +266,29 @@ test('initializes every referenced Issue only for a PR opened event', async () =
|
|
|
assert.equal(writes.length, 3)
|
|
|
})
|
|
|
|
|
|
-test('writes an empty Issue Start date with the configured field', async (t) => {
|
|
|
+test('writes an empty Project Start Date with the configured field', async (t) => {
|
|
|
const requests = mockGraphql(t, (request) => {
|
|
|
if (request.query.includes('query(')) return projectGraphqlData()
|
|
|
- return { updateIssueFieldValue: { issue: { id: 'issue-id' } } }
|
|
|
+ return { updateProjectV2ItemFieldValue: { projectV2Item: { id: 'item-id' } } }
|
|
|
})
|
|
|
|
|
|
await initializeIssueStartDate(42, '2026-08-28')
|
|
|
|
|
|
assert.equal(requests.length, 2)
|
|
|
assert.match(requests[0].query, /isIssueField/)
|
|
|
- assert.match(requests[0].query, /ProjectV2ItemIssueFieldValue/)
|
|
|
- assert.match(requests[1].query, /updateIssueFieldValue/)
|
|
|
- assert.match(requests[1].query, /issueField: \{fieldId: \$fieldId, dateValue: \$date\}/)
|
|
|
+ assert.doesNotMatch(requests[0].query, /issueField\s*\{/)
|
|
|
+ assert.match(requests[0].query, /ProjectV2ItemFieldDateValue/)
|
|
|
+ assert.match(requests[1].query, /updateProjectV2ItemFieldValue/)
|
|
|
+ assert.match(requests[1].query, /value: \{date: \$date\}/)
|
|
|
assert.deepEqual(requests[1].variables, {
|
|
|
- issueId: 'issue-id',
|
|
|
- fieldId: 'start-date-issue-field-id',
|
|
|
+ projectId: 'project-id',
|
|
|
+ itemId: 'item-id',
|
|
|
+ fieldId: 'start-date-field-id',
|
|
|
date: '2026-08-28',
|
|
|
})
|
|
|
})
|
|
|
|
|
|
-test('preserves an existing Issue Start date', async (t) => {
|
|
|
+test('preserves an existing Project Start Date', async (t) => {
|
|
|
const requests = mockGraphql(t, () => projectGraphqlData({ startDate: '2026-08-01' }))
|
|
|
|
|
|
await initializeIssueStartDate(42, '2026-08-28')
|
|
|
@@ -297,13 +296,13 @@ test('preserves an existing Issue Start date', async (t) => {
|
|
|
assert.equal(requests.length, 1)
|
|
|
})
|
|
|
|
|
|
-test('adds a referenced Issue to the Project before setting Start date', async (t) => {
|
|
|
+test('adds a referenced Issue to the Project before setting Start Date', async (t) => {
|
|
|
const requests = mockGraphql(t, (request) => {
|
|
|
if (request.query.includes('query(')) return projectGraphqlData({ projectItem: false })
|
|
|
if (request.query.includes('addProjectV2ItemById')) {
|
|
|
return { addProjectV2ItemById: { item: { id: 'new-item-id' } } }
|
|
|
}
|
|
|
- return { updateIssueFieldValue: { issue: { id: 'issue-id' } } }
|
|
|
+ return { updateProjectV2ItemFieldValue: { projectV2Item: { id: 'new-item-id' } } }
|
|
|
})
|
|
|
|
|
|
await initializeIssueStartDate(42, '2026-08-28')
|
|
|
@@ -311,30 +310,26 @@ test('adds a referenced Issue to the Project before setting Start date', async (
|
|
|
assert.equal(requests.length, 3)
|
|
|
assert.deepEqual(requests[1].variables, { projectId: 'project-id', contentId: 'issue-id' })
|
|
|
assert.deepEqual(requests[2].variables, {
|
|
|
- issueId: 'issue-id',
|
|
|
- fieldId: 'start-date-issue-field-id',
|
|
|
+ projectId: 'project-id',
|
|
|
+ itemId: 'new-item-id',
|
|
|
+ fieldId: 'start-date-field-id',
|
|
|
date: '2026-08-28',
|
|
|
})
|
|
|
})
|
|
|
|
|
|
-test('rejects a missing, non-Date, or Project-local Start date field', async (t) => {
|
|
|
+test('rejects a missing, non-Date, or Issue-level Start Date field', async (t) => {
|
|
|
let response = projectGraphqlData({ startDateField: false })
|
|
|
const requests = mockGraphql(t, () => response)
|
|
|
|
|
|
- await assert.rejects(initializeIssueStartDate(42, '2026-08-28'), /Project 缺少 Start date 字段/)
|
|
|
+ await assert.rejects(initializeIssueStartDate(42, '2026-08-28'), /Project 缺少 Start Date 字段/)
|
|
|
response = projectGraphqlData({ startDateType: 'TEXT' })
|
|
|
- await assert.rejects(initializeIssueStartDate(42, '2026-08-28'), /Start date 字段必须为 Date/)
|
|
|
- response = projectGraphqlData({ startDateIsIssueField: false })
|
|
|
+ await assert.rejects(initializeIssueStartDate(42, '2026-08-28'), /Start Date 字段必须为 Date/)
|
|
|
+ response = projectGraphqlData({ startDateIsIssueField: true })
|
|
|
await assert.rejects(
|
|
|
initializeIssueStartDate(42, '2026-08-28'),
|
|
|
- /Start date 字段必须为 Issue Date 字段/,
|
|
|
+ /Start Date 字段必须为 Project Date 字段/,
|
|
|
)
|
|
|
- response = projectGraphqlData({ startDateIssueField: false })
|
|
|
- await assert.rejects(
|
|
|
- initializeIssueStartDate(42, '2026-08-28'),
|
|
|
- /Start date 字段必须为 Issue Date 字段/,
|
|
|
- )
|
|
|
- assert.equal(requests.length, 4)
|
|
|
+ assert.equal(requests.length, 3)
|
|
|
})
|
|
|
|
|
|
test('does not treat pull request references as Issue associations', () => {
|