Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 14, 2022
1 parent 31c2b8c commit 4fcce3d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,26 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('400s when attempting to add more than 1K alerts to a case in multiple calls', async () => {
it('400s when attempting to add an alert to a case that already has 1K alerts', async () => {
const alerts = [...Array(1000).keys()].map((num) => `test-${num}`);
const postedCase = await createCase(supertest, postCaseReq);
await createComment({
supertest,
caseId: postedCase.id,
params: { ...postCommentAlertReq, alertId: alerts, index: alerts },
});

await createComment({
supertest,
caseId: postedCase.id,
params: { ...postCommentAlertReq, alertId: 'test-id', index: 'test-index' },
expectedHttpCode: 400,
});
});

it('400s when the case already has alerts and the sum of existing and new alerts exceed 1k', async () => {
const alerts = [...Array(1200).keys()].map((num) => `test-${num}`);
const postedCase = await createCase(supertest, postCaseReq);
await createComment({
supertest,
caseId: postedCase.id,
Expand All @@ -328,12 +345,6 @@ export default ({ getService }: FtrProviderContext): void => {
alertId: alerts.slice(500),
index: alerts.slice(500),
},
});

await createComment({
supertest,
caseId: postedCase.id,
params: postCommentAlertReq,
expectedHttpCode: 400,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,38 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('400s when attempting to add more than 1K alerts in multiple request', async () => {
it('400s when attempting to add an alert to a case that already has 1K alerts', async () => {
const alerts = [...Array(1000).keys()].map((num) => `test-${num}`);
const postedCase = await createCase(supertest, postCaseReq);
await bulkCreateAttachments({
supertest,
caseId: postedCase.id,
params: [
{
...postCommentAlertReq,
alertId: alerts,
index: alerts,
},
],
});

await bulkCreateAttachments({
supertest,
caseId: postedCase.id,
params: [
{
...postCommentAlertReq,
alertId: 'test-id',
index: 'test-index',
},
],
expectedHttpCode: 400,
});
});

it('400s when the case already has alerts and the sum of existing and new alerts exceed 1k', async () => {
const alerts = [...Array(1200).keys()].map((num) => `test-${num}`);
const postedCase = await createCase(supertest, postCaseReq);
await bulkCreateAttachments({
supertest,
caseId: postedCase.id,
Expand All @@ -420,7 +449,6 @@ export default ({ getService }: FtrProviderContext): void => {
index: alerts.slice(0, 500),
},
],
expectedHttpCode: 200,
});

await bulkCreateAttachments({
Expand Down

0 comments on commit 4fcce3d

Please sign in to comment.