Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name parameterize business hour functions #738

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
194 changes: 97 additions & 97 deletions src/utils/businessHours.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,149 +97,149 @@ describe('businessHours tests', function () {

for (let i = 0; i < 7; i++) {
it(`should calculate TTT SLO violation for ${testTimestamps[i].day}`, async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
testTimestamps[i].timestamp
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: testTimestamps[i].timestamp,
});
expect(result).toEqual(triageResults[i]);
});

it(`should calculate TTR SLO violation for ${testTimestamps[i].day}`, async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
testTimestamps[i].timestamp
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: testTimestamps[i].timestamp,
});
expect(result).toEqual(routingResults[i]);
});
}

it('should handle case when offices is undefined', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Undefined',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-12-18T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Undefined',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-12-18T00:00:00.000Z',
});
expect(result).toEqual('2023-12-20T01:00:00.000Z');
});

it('should handle case when offices is null', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Null',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-12-18T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Null',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-12-18T00:00:00.000Z',
});
expect(result).toEqual('2023-12-20T01:00:00.000Z');
});

it('should handle the last day of the month for TTR', async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-01-31T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-01-31T00:00:00.000Z',
});
expect(result).toEqual('2023-02-01T00:00:00.000Z');
});

it('should handle the last day of the year for TTR', async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
'2022-12-31T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2022-12-31T00:00:00.000Z',
});
expect(result).toEqual('2023-01-04T01:00:00.000Z');
});

describe('holiday tests', function () {
it('should calculate TTT SLO violation for Christmas', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-12-24T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-12-24T00:00:00.000Z',
});
// 2023-12-24 is Sunday, 2023-12-25/2022-12-26 are holidays
expect(result).toEqual('2024-01-04T01:00:00.000Z');
});

it('should calculate TTR SLO violation for Christmas', async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-12-24T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-12-24T00:00:00.000Z',
});
// 2023-12-24 is Sunday, 2023-12-25/2022-12-26 are holidays
expect(result).toEqual('2024-01-03T01:00:00.000Z');
});

it('should not include holiday in TTR if at least one office is still open', async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'Test',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-10-02T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'Test',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-10-02T00:00:00.000Z',
});
expect(result).toEqual('2023-10-03T00:00:00.000Z');
});

it('should triage on the same day if two office timezones do not overlap', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Non-Overlapping Timezone',
'routing-repo',
GETSENTRY_ORG.slug,
'2023-10-02T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Non-Overlapping Timezone',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2023-10-02T00:00:00.000Z',
});
expect(result).toEqual('2023-10-03T00:00:00.000Z');
});

it('should calculate weekends properly for friday in sfo, weekend in vie', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'Non-Overlapping Timezone',
'routing-repo',
GETSENTRY_ORG.slug,
'2022-12-17T00:00:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'Non-Overlapping Timezone',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2022-12-17T00:00:00.000Z',
});
expect(result).toEqual('2022-12-20T00:00:00.000Z');
});

it('should route properly when product area is subscribed to sfo, vie, and yyz', async function () {
const result = await calculateTimeToRespondBy(
MAX_ROUTE_DAYS,
'All-Timezones',
'routing-repo',
GETSENTRY_ORG.slug,
'2022-12-20T15:30:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_ROUTE_DAYS,
productArea: 'All-Timezones',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2022-12-20T15:30:00.000Z',
});
expect(result).toEqual('2022-12-20T23:30:00.000Z');
});

it('should triage properly when product area is subscribed to sfo, vie, and yyz', async function () {
const result = await calculateTimeToRespondBy(
MAX_TRIAGE_DAYS,
'All-Timezones',
'routing-repo',
GETSENTRY_ORG.slug,
'2022-12-20T15:30:00.000Z'
);
const result = await calculateTimeToRespondBy({
numDays: MAX_TRIAGE_DAYS,
productArea: 'All-Timezones',
repo: 'routing-repo',
org: GETSENTRY_ORG.slug,
testTimestamp: '2022-12-20T15:30:00.000Z',
});
expect(result).toEqual('2022-12-21T14:30:00.000Z');
});
});
Expand Down Expand Up @@ -497,7 +497,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Other';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(1);
});
it('should correctly calculate business hours over multiple days', function () {
Expand All @@ -507,7 +507,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Other';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(9);
});
it('should correctly calculate business hours over holiday', function () {
Expand All @@ -517,7 +517,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Other';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(1);
});
it('should correctly account for weekends when calculating business hours', function () {
Expand All @@ -527,7 +527,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Other';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(2);
});
it('should correctly calculate business hours for issues with non overlapping timezones', function () {
Expand All @@ -537,7 +537,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Non-Overlapping Timezone';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(25);
});
it('should correctly calculate business hours for issues with overlapping timezones', function () {
Expand All @@ -547,7 +547,7 @@ describe('businessHours tests', function () {
const org = 'getsentry';
const productArea = 'Overlapping Timezone';
expect(
getBusinessHoursLeft(triageBy, now, repo, org, productArea)
getBusinessHoursLeft({ triageBy, now, repo, org, productArea })
).toEqual(15);
});
});
Expand Down
Loading
Loading