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
63 changes: 43 additions & 20 deletions src/renderer/utils/notifications/handlers/checkSuite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
});

Expand All @@ -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',
});
});

Expand All @@ -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',
});
});

Expand All @@ -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',
});
});

Expand All @@ -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',
});
});

Expand All @@ -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',
});
});

Expand Down Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/utils/notifications/handlers/checkSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function getCheckSuiteStatus(
}
}

export function getCheckSuiteUrl(notification: GitifyNotification): Link {
function getCheckSuiteUrl(notification: GitifyNotification): Link {
const filters = [];

const checkSuiteAttributes = getCheckSuiteAttributes(notification);
Expand All @@ -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) {
Expand Down
51 changes: 36 additions & 15 deletions src/renderer/utils/notifications/handlers/workflowRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
});

Expand Down Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/utils/notifications/handlers/workflowRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading