gr2m / github-project

JavaScript SDK for GitHub's new Projects
ISC License
35 stars 10 forks source link

Handle iterations field #94

Closed blombard closed 1 year ago

blombard commented 1 year ago

Please avoid duplicates

What’s missing?

The iteration field is a special field not handled for now by this package.

Why?

For now when I do project.items.get the iteration field is always undefined. And when I try to do project.items.update with an iteration field, I always get an error.

Alternatives you tried

/

Would you be interested in contributing the feature?

gr2m commented 1 year ago

Thanks for the issue and the pull request!

Could you share a code snippet that I can use to test your changes? We should update the tests to cover your changes. But it might be tricky for iteration fields as they change based on date ... 🤔

blombard commented 1 year ago

I found an open-source project so you could test easily: https://github.com/orgs/carbon-design-system/projects/39/views/12 But it would be easier if this repo had a project I guess.

import GitHubProject from "github-project";

const project = new GitHubProject({
  owner: "carbon-design-system",
  number: 39,
  token: "ghp_qDGF...",
  fields: {
    Sprint: "Sprint",  // Sprint is the iteration name in this case
  },
});

const item = await project.items.get('PVTI_lADOAYA3Ss1Nv84AOX-b');
console.log(item);

const updatedItem = await project.items.update('id', { Sprint: 'Sprint 42'}); // Sprint is the iteration name in this case
console.log(updatedItem);

The first console.log would return:

{
  type: 'ISSUE',
  id: 'PVTI_lADOAYA3Ss1Nv84AOX-b',
  fields: {
    title: '[a11y]: focus not visible when clicking on combobox toggle',
    status: '✅  Done',
    Sprint: undefined
  },
  content: {
    ...
  }
}

And now

{
  type: 'ISSUE',
  id: 'PVTI_lADOAYA3Ss1Nv84AOX-b',
  fields: {
    title: '[a11y]: focus not visible when clicking on combobox toggle',
    status: '✅  Done',
    Sprint: 'Sprint 53'
  },
  content: {
    ...
  }
}
gr2m commented 1 year ago

But it would be easier if this repo had a project I guess.

https://github.com/orgs/github-project-fixtures/projects, I can invite you to it so you can create a test project there or amend the existing one, and record fixtures for #95 as described here: https://github.com/gr2m/github-project/blob/main/CONTRIBUTING.md#recording-fixtures-for-testing. Would that work?

blombard commented 1 year ago

Yes you can invite me and I'll try to follow the instructions 😅

gr2m commented 1 year ago

Invitation is out. Here are the credentials you'll need for the automation to work: https://github.com/orgs/github-project-fixtures/teams/contributors/discussions/1

blombard commented 1 year ago

I recorded fixtures for #95 and everything works. Code coverage is still 100%.

I added the iteration field to:

And created:

Should I take the time to add the iteration field to all tests when possible or is that enough?