Repository navigation
feat: enhance attendants management with pull request metadata and au… - #8
Conversation
…to-merge functionality
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR enhances the admin attendants save flow to update attendants via a dedicated work branch + pull request, returning pull request metadata (URL/number), and optionally requesting auto-merge, so the admin UI can surface the PR and status messaging.
Changes:
- Refactors
updateAttendantsInRepositoryto ensure a work branch exists, write attendants there, open/reuse a PR, and optionally request auto-merge via GitHub GraphQL. - Extends the admin API response and admin UI to display PR metadata and more detailed save status messaging.
- Adds/updates unit tests for the new PR + auto-merge behavior and updates
.env.examplewith new GitHub-related settings.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/attendants-store.js |
Implements work-branch writes, PR creation/reuse, and auto-merge request; returns PR metadata to callers. |
app/api/admin/attendants/route.js |
Adds PR/branch/auto-merge metadata fields to the PUT response payload. |
components/admin/managers/admin-service-manager.js |
Displays PR link and updates success toast messaging based on PR/auto-merge status. |
tests/unit/lib/attendants-store.test.js |
New unit tests covering branch creation, PR reuse/creation, unchanged handling, and auto-merge failures. |
tests/unit/api/admin-attendants-route.test.js |
Extends API route tests to validate the expanded response contract. |
.env.example |
Documents new env vars for work branch + auto-merge behavior and updated token permissions hint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| function getGitHubRefUrl(config, branch) { | ||
| const encodedBranch = encodeGitHubPath(branch); |
There was a problem hiding this comment.
getGitHubRefUrl() is using encodeGitHubPath() which intentionally un-escapes %2F back to /. That behavior is correct for the Contents API path, but it breaks the Git ref endpoint when branch names contain / (e.g. bot/attendants-admin should be requested as heads/bot%2Fattendants-admin). As written, GitHub will likely return 404 and the work-branch creation flow won’t work for slash-containing branch names. Use a dedicated encoder for refs/branch names (do not unescape %2F) or build the ref URL with encodeURIComponent(branch) (without the %2F replacement).
| const encodedBranch = encodeGitHubPath(branch); | |
| const encodedBranch = encodeURIComponent(branch); |
| const createPullRequestCall = fetchMock.mock.calls.find( | ||
| ([url, options]) => String(url).endsWith("/pulls") && options?.method === "POST", | ||
| ); | ||
| expect(createPullRequestCall).toBeTruthy(); | ||
| expect(JSON.parse(createPullRequestCall[1].body)).toMatchObject({ | ||
| head: "bot/attendants-admin", | ||
| base: "main", | ||
| }); |
There was a problem hiding this comment.
The tests cover the slash-containing work branch (bot/attendants-admin) but don’t assert that the Git ref fetch uses the correctly URL-encoded branch name (i.e. bot%2Fattendants-admin). Adding an explicit expectation on the first fetch call URL would prevent regressions in the ref URL encoding logic.
- preserve cart interactions made before localStorage hydration completes - make checkout smoke wait for item-in-cart confirmation before navigating
- retry add-to-cart until cart storage reflects item - assert increase button visibility explicitly before click
…to-merge functionality