Skip to content

Commit

Permalink
[Cases] Case action: Handle closed cases (#172709)
Browse files Browse the repository at this point in the history
## Summary

Depends on: #171754

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
cnasikas and kibanamachine authored Dec 20, 2023
1 parent c095b48 commit f6491cb
Show file tree
Hide file tree
Showing 10 changed files with 804 additions and 197 deletions.
306 changes: 251 additions & 55 deletions packages/kbn-check-mappings-update-cli/current_fields.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '../../../common/constants';
import { mockCases } from '../../mocks';
import { createCasesClientMock, createCasesClientMockArgs } from '../mocks';
import { update } from './update';
import { bulkUpdate } from './bulk_update';

describe('update', () => {
const cases = {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('update', () => {
});

it('notifies an assignee', async () => {
await update(cases, clientArgs, casesClientMock);
await bulkUpdate(cases, clientArgs, casesClientMock);

expect(clientArgs.services.notificationService.bulkNotifyAssignees).toHaveBeenCalledWith([
{
Expand All @@ -72,7 +72,7 @@ describe('update', () => {
expect.assertions(2);

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('update', () => {
],
});

await expect(update(cases, clientArgs, casesClientMock)).rejects.toThrow(
await expect(bulkUpdate(cases, clientArgs, casesClientMock)).rejects.toThrow(
'Failed to update case, ids: [{"id":"mock-id-1","version":"WzAsMV0="}]: Error: All update fields are identical to current version.'
);

Expand All @@ -130,7 +130,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('update', () => {
saved_objects: [{ ...mockCases[0], attributes: { assignees: [{ uid: '1' }] } }],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand All @@ -273,7 +273,7 @@ describe('update', () => {

it('should throw an error when an invalid field is included in the request payload', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -297,7 +297,7 @@ describe('update', () => {
const assignees = Array(MAX_ASSIGNEES_PER_CASE + 1).fill({ uid: 'foo' });

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -355,7 +355,7 @@ describe('update', () => {

it('does not update the category if the length is too long', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -375,7 +375,7 @@ describe('update', () => {

it('throws error if category is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -395,7 +395,7 @@ describe('update', () => {

it('throws error if category is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -414,7 +414,7 @@ describe('update', () => {
});

it('should trim category', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -489,7 +489,7 @@ describe('update', () => {

it('throws error if the title is too long', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -510,7 +510,7 @@ describe('update', () => {

it('throws error if title is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -530,7 +530,7 @@ describe('update', () => {

it('throws error if title is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -549,7 +549,7 @@ describe('update', () => {
});

it('should trim title', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -628,7 +628,7 @@ describe('update', () => {
.toString();

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -648,7 +648,7 @@ describe('update', () => {

it('throws error if description is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -668,7 +668,7 @@ describe('update', () => {

it('throws error if description is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -687,7 +687,7 @@ describe('update', () => {
});

it('should trim description', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -888,7 +888,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -910,7 +910,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -930,7 +930,7 @@ describe('update', () => {
const tags = Array(MAX_TAGS_PER_CASE + 1).fill('foo');

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -954,7 +954,7 @@ describe('update', () => {
.toString();

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -974,7 +974,7 @@ describe('update', () => {

it('throws error if tag is empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -994,7 +994,7 @@ describe('update', () => {

it('throws error if tag is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1013,7 +1013,7 @@ describe('update', () => {
});

it('should trim tags', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1104,7 +1104,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1154,7 +1154,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1205,7 +1205,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1225,7 +1225,7 @@ describe('update', () => {

it('throws with duplicated customFields keys', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1256,7 +1256,7 @@ describe('update', () => {

it('throws when customFields keys are not present in configuration', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1287,7 +1287,7 @@ describe('update', () => {

it('throws error when custom fields are missing', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1313,7 +1313,7 @@ describe('update', () => {

it('throws when the customField types dont match the configuration', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1355,7 +1355,7 @@ describe('update', () => {

it(`throws an error when trying to update more than ${MAX_CASES_TO_UPDATE} cases`, async () => {
await expect(
update(
bulkUpdate(
{
cases: Array(MAX_CASES_TO_UPDATE + 1).fill({
id: mockCases[0].id,
Expand All @@ -1373,7 +1373,7 @@ describe('update', () => {

it('throws an error when trying to update zero cases', async () => {
await expect(
update(
bulkUpdate(
{
cases: [],
},
Expand Down Expand Up @@ -1416,7 +1416,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1445,7 +1445,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down
Loading

0 comments on commit f6491cb

Please sign in to comment.