Skip to content

feat: Integrate PR #3 fixes and add bulk update state name fix #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SvenMeyer
Copy link

This PR integrates the changes from jgadbois's Pull Request #3 (#3) into the main branch.

PR #3 includes:

  • Fix for Personal Access Token (PAT) authentication.
  • Ability to search issues by full identifier (e.g., TEAM-123).
  • Attempted fix for bulk issue updates using state names.
  • Code structure for OAuth flow (untested).

This PR also includes an additional commit that fixes a bug in PR #3's implementation of bulk updates using state names (resolving team.states.find is not a function).

This effectively replaces the previous main branch history with the more comprehensive fixes and features from PR #3, plus the necessary correction.

@ocasta181
Copy link
Collaborator

Hey @SvenMeyer

Apologies for the delay in responding here.

Had you tried running the automated tests? This appears to break a few:

andrin@Andrins-MacBook-Pro linear-mcp % npm test

> linear-mcp@1.0.0 test
> jest

 PASS  src/__tests__/auth.integration.test.ts
 PASS  src/__tests__/auth.test.ts
 FAIL  src/__tests__/graphql-client.test.ts
  ● Console

    console.error
      Failed to update issue issue-1

      135 |         } else {
      136 |           overallSuccess = false;
    > 137 |           console.error(`Failed to update issue ${id}`);
          |                   ^
      138 |         }
      139 |       } catch (error) {
      140 |         overallSuccess = false;

      at LinearGraphQLClient.updateIssues (src/graphql/client.ts:137:19)
      at Object.<anonymous> (src/__tests__/graphql-client.test.ts:434:44)

    console.error
      Error updating issue issue-2: Error: GraphQL operation failed: Cannot read properties of undefined (reading 'data')
          at LinearGraphQLClient.execute (/Users/andrin/Code/linear-mcp/src/graphql/client.ts:50:15)
          at processTicksAndRejections (node:internal/process/task_queues:105:5)
          at LinearGraphQLClient.updateIssues (/Users/andrin/Code/linear-mcp/src/graphql/client.ts:129:24)
          at Object.<anonymous> (/Users/andrin/Code/linear-mcp/src/__tests__/graphql-client.test.ts:434:44)

      139 |       } catch (error) {
      140 |         overallSuccess = false;
    > 141 |         console.error(`Error updating issue ${id}:`, error);
          |                 ^
      142 |       }
      143 |     }
      144 |

      at LinearGraphQLClient.updateIssues (src/graphql/client.ts:141:17)
      at Object.<anonymous> (src/__tests__/graphql-client.test.ts:434:44)

    console.error
      Error updating issue issue-1: Error: GraphQL operation failed: Update failed
          at LinearGraphQLClient.execute (/Users/andrin/Code/linear-mcp/src/graphql/client.ts:50:15)
          at processTicksAndRejections (node:internal/process/task_queues:105:5)
          at LinearGraphQLClient.updateIssues (/Users/andrin/Code/linear-mcp/src/graphql/client.ts:129:24)
          at Object.<anonymous> (/Users/andrin/Code/linear-mcp/src/__tests__/graphql-client.test.ts:452:7)

      139 |       } catch (error) {
      140 |         overallSuccess = false;
    > 141 |         console.error(`Error updating issue ${id}:`, error);
          |                 ^
      142 |       }
      143 |     }
      144 |

      at LinearGraphQLClient.updateIssues (src/graphql/client.ts:141:17)
      at Object.<anonymous> (src/__tests__/graphql-client.test.ts:452:7)

  ● LinearGraphQLClient › Bulk Operations › should update multiple issues with a single mutation

    expect(received).toEqual(expected) // deep equality

    - Expected  - 15
    + Received  +  2

      Object {
        "issueUpdate": Object {
    -     "issues": Array [
    -       Object {
    -         "id": "issue-1",
    -         "identifier": "TEST-1",
    -         "title": "Updated Issue 1",
    -         "url": "https://linear.app/test/issue/TEST-1",
    -       },
    -       Object {
    -         "id": "issue-2",
    -         "identifier": "TEST-2",
    -         "title": "Updated Issue 2",
    -         "url": "https://linear.app/test/issue/TEST-2",
    -       },
    -     ],
    -     "success": true,
    +     "issues": Array [],
    +     "success": false,
        },
      }

      434 |       const result: UpdateIssuesResponse = await graphqlClient.updateIssues(ids, updateInput);
      435 |
    > 436 |       expect(result).toEqual(mockResponse.data);
          |                      ^
      437 |       // Verify single mutation call
      438 |       expect(mockRawRequest).toHaveBeenCalledTimes(1);
      439 |       expect(mockRawRequest).toHaveBeenCalledWith(

      at Object.<anonymous> (src/__tests__/graphql-client.test.ts:436:22)

  ● LinearGraphQLClient › Bulk Operations › should handle update errors

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: {"issueUpdate": {"issues": [], "success": false}}

      450 |
      451 |       const updateInput: UpdateIssueInput = { stateId: 'state-2' };
    > 452 |       await expect(
          |                   ^
      453 |         graphqlClient.updateIssues(['issue-1'], updateInput)
      454 |       ).rejects.toThrow('GraphQL operation failed: Update failed');
      455 |     });

      at expect (node_modules/expect/build/index.js:113:15)
      at Object.<anonymous> (src/__tests__/graphql-client.test.ts:452:19)

Test Suites: 1 failed, 2 passed, 3 total
Tests:       2 failed, 3 skipped, 33 passed, 38 total
Snapshots:   0 total
Time:        1.49 s
Ran all test suites.

When run from main I get:

andrin@Andrins-MacBook-Pro linear-mcp % npm test                

> linear-mcp@1.0.0 test
> jest

 PASS  src/__tests__/auth.integration.test.ts
 PASS  src/__tests__/auth.test.ts
 PASS  src/__tests__/graphql-client.test.ts

Test Suites: 3 passed, 3 total
Tests:       3 skipped, 35 passed, 38 total
Snapshots:   0 total
Time:        1.348 s, estimated 2 s
Ran all test suites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants