diff --git a/src/renderer/utils/notifications/handlers/checkSuite.test.ts b/src/renderer/utils/notifications/handlers/checkSuite.test.ts index f34ce78e7..d8a94bc3c 100644 --- a/src/renderer/utils/notifications/handlers/checkSuite.test.ts +++ b/src/renderer/utils/notifications/handlers/checkSuite.test.ts @@ -27,7 +27,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'CANCELLED', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3ACANCELLED+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Acancelled+branch%3Amain', }); }); @@ -46,7 +46,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'FAILURE', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3AFAILURE+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain', }); }); @@ -65,7 +65,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'FAILURE', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3AFAILURE+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain', }); }); @@ -84,7 +84,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'FAILURE', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3AFAILURE+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain', }); }); @@ -103,7 +103,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'SKIPPED', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3ASKIPPED+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Askipped+branch%3Amain', }); }); @@ -122,7 +122,7 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { state: 'SUCCESS', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3ASUCCESS+branch%3Amain', + 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Asuccess+branch%3Amain', }); }); @@ -219,20 +219,43 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { }); }); - it('defaultUrl', () => { - const mockHtmlUrl = - 'https://github.com/gitify-app/notifications-test' as Link; - - expect( - checkSuiteHandler.defaultUrl({ - subject: { - title: 'Some notification', - }, - repository: { - htmlUrl: mockHtmlUrl, - }, - } as GitifyNotification), - ).toEqual(`${mockHtmlUrl}/actions`); + describe('defaultUrl', () => { + it('unknown checksuite attributes', () => { + const mockHtmlUrl = + 'https://github.com/gitify-app/notifications-test' as Link; + + expect( + checkSuiteHandler.defaultUrl({ + subject: { + title: 'Some notification', + type: 'CheckSuite', + }, + repository: { + htmlUrl: mockHtmlUrl, + }, + } as GitifyNotification), + ).toEqual(`${mockHtmlUrl}/actions`); + }); + + it('checksuite attributes', () => { + const mockHtmlUrl = + 'https://github.com/gitify-app/notifications-test' as Link; + + expect( + checkSuiteHandler.defaultUrl({ + subject: { + title: 'Lint workflow run failed for main branch', + type: 'CheckSuite', + state: 'FAILURE', + }, + repository: { + htmlUrl: mockHtmlUrl, + }, + } as GitifyNotification), + ).toEqual( + `${mockHtmlUrl}/actions?query=workflow%3A%22Lint%22+is%3Afailure+branch%3Amain`, + ); + }); }); describe('getCheckSuiteState', () => { diff --git a/src/renderer/utils/notifications/handlers/checkSuite.ts b/src/renderer/utils/notifications/handlers/checkSuite.ts index 16c433947..e4b81d442 100644 --- a/src/renderer/utils/notifications/handlers/checkSuite.ts +++ b/src/renderer/utils/notifications/handlers/checkSuite.ts @@ -128,7 +128,7 @@ function getCheckSuiteStatus( } } -export function getCheckSuiteUrl(notification: GitifyNotification): Link { +function getCheckSuiteUrl(notification: GitifyNotification): Link { const filters = []; const checkSuiteAttributes = getCheckSuiteAttributes(notification); @@ -140,7 +140,7 @@ export function getCheckSuiteUrl(notification: GitifyNotification): Link { } if (checkSuiteAttributes?.status) { - filters.push(`is:${checkSuiteAttributes.status}`); + filters.push(`is:${checkSuiteAttributes.status.toLowerCase()}`); } if (checkSuiteAttributes?.branchName) { diff --git a/src/renderer/utils/notifications/handlers/workflowRun.test.ts b/src/renderer/utils/notifications/handlers/workflowRun.test.ts index 969605daa..8c16afc9f 100644 --- a/src/renderer/utils/notifications/handlers/workflowRun.test.ts +++ b/src/renderer/utils/notifications/handlers/workflowRun.test.ts @@ -22,7 +22,7 @@ describe('renderer/utils/notifications/handlers/workflowRun.ts', () => { state: 'WAITING', user: undefined, htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=is%3AWAITING', + 'https://github.com/gitify-app/notifications-test/actions?query=is%3Awaiting', }); }); @@ -68,20 +68,41 @@ describe('renderer/utils/notifications/handlers/workflowRun.ts', () => { ); }); - it('defaultUrl', () => { - const mockHtmlUrl = - 'https://github.com/gitify-app/notifications-test' as Link; - - expect( - workflowRunHandler.defaultUrl({ - subject: { - title: 'Some notification', - }, - repository: { - htmlUrl: mockHtmlUrl, - }, - } as GitifyNotification), - ).toEqual(`${mockHtmlUrl}/actions`); + describe('defaultUrl', () => { + it('unknown workflow attributes', () => { + const mockHtmlUrl = + 'https://github.com/gitify-app/notifications-test' as Link; + + expect( + workflowRunHandler.defaultUrl({ + subject: { + title: 'Some notification', + type: 'WorkflowRun', + }, + repository: { + htmlUrl: mockHtmlUrl, + }, + } as GitifyNotification), + ).toEqual(`${mockHtmlUrl}/actions`); + }); + + it('workflow attributes', () => { + const mockHtmlUrl = + 'https://github.com/gitify-app/notifications-test' as Link; + + expect( + workflowRunHandler.defaultUrl({ + subject: { + title: 'someone requested your review to deploy to an environment', + type: 'WorkflowRun', + state: 'WAITING', + }, + repository: { + htmlUrl: mockHtmlUrl, + }, + } as GitifyNotification), + ).toEqual(`${mockHtmlUrl}/actions?query=is%3Awaiting`); + }); }); describe('getWorkflowRunAttributes', () => { diff --git a/src/renderer/utils/notifications/handlers/workflowRun.ts b/src/renderer/utils/notifications/handlers/workflowRun.ts index 3ba9cbe63..8458361f3 100644 --- a/src/renderer/utils/notifications/handlers/workflowRun.ts +++ b/src/renderer/utils/notifications/handlers/workflowRun.ts @@ -85,13 +85,13 @@ function getWorkflowRunStatus( } } -export function getWorkflowRunUrl(notification: GitifyNotification): Link { +function getWorkflowRunUrl(notification: GitifyNotification): Link { const filters = []; const workflowRunAttributes = getWorkflowRunAttributes(notification); if (workflowRunAttributes?.status) { - filters.push(`is:${workflowRunAttributes.status}`); + filters.push(`is:${workflowRunAttributes.status.toLowerCase()}`); } return actionsURL(notification.repository.htmlUrl, filters);