Skip to content

Commit

Permalink
Merge pull request #35 from PagerDuty/next
Browse files Browse the repository at this point in the history
release: 0.4.4
  • Loading branch information
t1agob authored Mar 1, 2024
2 parents 44e5600 + cb952f8 commit 70c905c
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 3 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/backend-common": "^0.19.9",
"@backstage/backend-common": "^0.19.10",
"@backstage/config": "^1.1.1",
"@backstage/plugin-scaffolder-node": "^0.2.8",
"@material-ui/core": "^4.12.4",
Expand Down
65 changes: 65 additions & 0 deletions src/apis/pagerduty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,71 @@ describe("PagerDuty API", () => {
expect(fetch).toHaveBeenCalledTimes(1);
});

it.each(testInputs)("should return relevant users from escalation policy level 1 even if another level is returned first", async () => {
const escalationPolicyId = "12345";
const expectedResponse = [
{
id: "userId1",
name: "John Doe",
email: "john.doe@email.com",
avatar_url: "https://example.pagerduty.com/avatars/123",
html_url: "https://example.pagerduty.com/users/123",
summary: "John Doe",
}
];

const mockAPIResponse = {
"oncalls": [
{
"user": {
"id": "userId3",
"summary": "Jane Doe",
"name": "Jane Doe",
"email": "jane.does@email.com",
"avatar_url": "https://example.pagerduty.com/avatars/123",
"html_url": "https://example.pagerduty.com/users/123",
},
"escalation_level": 3
},
{
"user": {
"id": expectedResponse[0].id,
"summary": expectedResponse[0].summary,
"name": expectedResponse[0].name,
"email": expectedResponse[0].email,
"avatar_url": expectedResponse[0].avatar_url,
"html_url": expectedResponse[0].html_url,
},
"escalation_level": 1
},
{
"user": {
"id": "userId2",
"summary": "James Doe",
"name": "James Doe",
"email": "james.does@email.com",
"avatar_url": "https://example.pagerduty.com/avatars/123",
"html_url": "https://example.pagerduty.com/users/123",
},
"escalation_level": 2
}
]
};

global.fetch = jest.fn(() =>
Promise.resolve({
status: 200,
json: () => Promise.resolve(mockAPIResponse)
})
) as jest.Mock;

const result = await getOncallUsers(escalationPolicyId);

expect(result).toEqual(expectedResponse);
expect(result.length).toEqual(1);
expect(fetch).toHaveBeenCalledTimes(1);
});

it.each(testInputs)("should return list of users ordered by name ASC from other escalation levels when level 1 is empty", async () => {
const escalationPolicyId = "12345";
const expectedResponse = [
Expand Down
2 changes: 1 addition & 1 deletion src/apis/pagerduty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export async function getOncallUsers(escalationPolicy: string): Promise<PagerDut
});

const oncallsFiltered = oncallsSorted.filter((oncall) => {
return oncall.escalation_level === result.oncalls[0].escalation_level;
return oncall.escalation_level === oncallsSorted[0].escalation_level;
});

usersItem = [...oncallsFiltered]
Expand Down
70 changes: 69 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,74 @@ __metadata:
languageName: node
linkType: hard

"@backstage/backend-common@npm:^0.19.10":
version: 0.19.10
resolution: "@backstage/backend-common@npm:0.19.10"
dependencies:
"@aws-sdk/abort-controller": ^3.347.0
"@aws-sdk/client-s3": ^3.350.0
"@aws-sdk/credential-providers": ^3.350.0
"@aws-sdk/types": ^3.347.0
"@backstage/backend-app-api": ^0.5.8
"@backstage/backend-dev-utils": ^0.1.2
"@backstage/backend-plugin-api": ^0.6.7
"@backstage/cli-common": ^0.1.13
"@backstage/config": ^1.1.1
"@backstage/config-loader": ^1.5.3
"@backstage/errors": ^1.2.3
"@backstage/integration": ^1.7.2
"@backstage/integration-aws-node": ^0.1.8
"@backstage/types": ^1.1.1
"@google-cloud/storage": ^6.0.0
"@keyv/memcache": ^1.3.5
"@keyv/redis": ^2.5.3
"@kubernetes/client-node": 0.19.0
"@manypkg/get-packages": ^1.1.3
"@octokit/rest": ^19.0.3
"@types/cors": ^2.8.6
"@types/dockerode": ^3.3.0
"@types/express": ^4.17.6
"@types/luxon": ^3.0.0
"@types/webpack-env": ^1.15.2
archiver: ^5.0.2
base64-stream: ^1.0.0
compression: ^1.7.4
concat-stream: ^2.0.0
cors: ^2.8.5
dockerode: ^3.3.1
express: ^4.17.1
express-promise-router: ^4.1.0
fs-extra: 10.1.0
git-url-parse: ^13.0.0
helmet: ^6.0.0
isomorphic-git: ^1.23.0
jose: ^4.6.0
keyv: ^4.5.2
knex: ^3.0.0
lodash: ^4.17.21
logform: ^2.3.2
luxon: ^3.0.0
minimatch: ^5.0.0
mysql2: ^2.2.5
node-fetch: ^2.6.7
p-limit: ^3.1.0
pg: ^8.11.3
raw-body: ^2.4.1
tar: ^6.1.12
uuid: ^8.3.2
winston: ^3.2.1
winston-transport: ^4.5.0
yauzl: ^2.10.0
yn: ^4.0.0
peerDependencies:
pg-connection-string: ^2.3.0
peerDependenciesMeta:
pg-connection-string:
optional: true
checksum: 3a26a80963c6109f34b9dcd72f38f9ee4d31556cb137c7c0860d7708a7ba79ef5914b7d00d43dd01a71974e03a5a421cc95102a490aafb3b747af8fd52cbaec3
languageName: node
linkType: hard

"@backstage/backend-common@npm:^0.19.9":
version: 0.19.9
resolution: "@backstage/backend-common@npm:0.19.9"
Expand Down Expand Up @@ -4740,7 +4808,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@pagerduty/backstage-plugin-backend@workspace:."
dependencies:
"@backstage/backend-common": ^0.19.9
"@backstage/backend-common": ^0.19.10
"@backstage/cli": ^0.24.0
"@backstage/config": ^1.1.1
"@backstage/plugin-scaffolder-node": ^0.2.8
Expand Down

0 comments on commit 70c905c

Please sign in to comment.