Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions __tests__/github.test.ts

This file was deleted.

36 changes: 36 additions & 0 deletions __tests__/transitions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {expect, test} from '@jest/globals'
import {issueStatusKey, parseUniqueId, prRowStatusKey} from '../src/transitions'

const ev = (action: string, pr: any = {}): any => ({action, pull_request: pr})
const review = (state: string): any => ({action: 'submitted', review: {state}, pull_request: {}})

test('prRowStatusKey maps PR events to the row status', () => {
expect(prRowStatusKey(ev('opened', {draft: false}))).toBe('open')
expect(prRowStatusKey(ev('opened', {draft: true}))).toBe('draft')
expect(prRowStatusKey(ev('converted_to_draft'))).toBe('draft')
expect(prRowStatusKey(ev('ready_for_review', {draft: false}))).toBe('open')
expect(prRowStatusKey(ev('reopened', {draft: false}))).toBe('open')
expect(prRowStatusKey(ev('closed', {merged: true}))).toBe('merged')
expect(prRowStatusKey(ev('closed', {merged: false}))).toBe('closed')
expect(prRowStatusKey(review('changes_requested'))).toBeNull()
})

test('issueStatusKey maps PR events to the issue status', () => {
expect(issueStatusKey(ev('opened', {draft: false}))).toBe('in_pr')
expect(issueStatusKey(ev('opened', {draft: true}))).toBeNull()
expect(issueStatusKey(ev('ready_for_review', {draft: false}))).toBe('in_pr')
expect(issueStatusKey(ev('reopened', {draft: false}))).toBe('in_pr')
expect(issueStatusKey(ev('reopened', {draft: true}))).toBeNull()
expect(issueStatusKey(ev('closed', {merged: true}))).toBe('for_qa')
expect(issueStatusKey(ev('closed', {merged: false}))).toBeNull()
expect(issueStatusKey(review('changes_requested'))).toBe('fixes_required')
expect(issueStatusKey(review('approved'))).toBeNull()
expect(issueStatusKey(review('commented'))).toBeNull()
})

test('parseUniqueId extracts the issue number', () => {
expect(parseUniqueId('body\nNotion: ISSUE-21360')).toBe(21360)
expect(parseUniqueId('see TASK-42 here')).toBe(42)
expect(parseUniqueId('nothing here')).toBeNull()
expect(parseUniqueId(undefined)).toBeNull()
})
13 changes: 5 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Notion Issue Sync
description: Invokes a provided Make web-hook for syncing the state of an issue linked to the active PR
name: Notion PR Status Sync
description: On PR lifecycle events, update the PR row in the Notion Pull Requests DB and the linked issue's Status (opened→In PR, changes-requested→Fixes Required, merged→For QA when the last PR merges).
inputs:
token:
notion_token:
required: true
description: 'Read-scoped GitHub token'
event:
required: true
description: 'Should be toJson(github.event) for extracting PR/review state'
description: Notion internal-integration token, shared with the Tech Issues + Pull Requests databases.
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
Loading
Loading