From f5e92cccae5eaa77ca0686c19a08496b9061d2ce Mon Sep 17 00:00:00 2001
From: Janki Salvi <117571355+js-jankisalvi@users.noreply.github.com>
Date: Wed, 19 Jul 2023 15:18:13 +0200
Subject: [PATCH] add clesedAt to sortField

---
 x-pack/plugins/cases/common/api/cases/case.test.ts       | 9 +++++++++
 x-pack/plugins/cases/common/api/cases/case.ts            | 1 +
 x-pack/plugins/cases/docs/openapi/bundled.json           | 1 +
 x-pack/plugins/cases/docs/openapi/bundled.yaml           | 1 +
 .../docs/openapi/components/parameters/sortField.yaml    | 1 +
 5 files changed, 13 insertions(+)

diff --git a/x-pack/plugins/cases/common/api/cases/case.test.ts b/x-pack/plugins/cases/common/api/cases/case.test.ts
index a249fb86e084e..06a3484ce97ad 100644
--- a/x-pack/plugins/cases/common/api/cases/case.test.ts
+++ b/x-pack/plugins/cases/common/api/cases/case.test.ts
@@ -389,6 +389,15 @@ describe('Case', () => {
       });
     });
 
+    it('succeeds with closedAt as sortField', () => {
+      const query = CasesFindRequestRt.decode({ ...defaultRequest, sortField: 'closedAt' });
+
+      expect(query).toStrictEqual({
+        _tag: 'Right',
+        right: { ...defaultRequest, sortField: 'closedAt', page: 1, perPage: 10 },
+      });
+    });
+
     it('succeeds with severity as sortField', () => {
       const query = CasesFindRequestRt.decode({ ...defaultRequest, sortField: 'severity' });
 
diff --git a/x-pack/plugins/cases/common/api/cases/case.ts b/x-pack/plugins/cases/common/api/cases/case.ts
index 1a530fa3d1211..5deab7f5ca0e3 100644
--- a/x-pack/plugins/cases/common/api/cases/case.ts
+++ b/x-pack/plugins/cases/common/api/cases/case.ts
@@ -215,6 +215,7 @@ const CasesFindRequestSortFieldsRt = rt.keyof({
   category: null,
   createdAt: null,
   updatedAt: null,
+  closedAt: null,
   status: null,
   severity: null,
 });
diff --git a/x-pack/plugins/cases/docs/openapi/bundled.json b/x-pack/plugins/cases/docs/openapi/bundled.json
index 2308009473a9d..3ff6564699cf6 100644
--- a/x-pack/plugins/cases/docs/openapi/bundled.json
+++ b/x-pack/plugins/cases/docs/openapi/bundled.json
@@ -3986,6 +3986,7 @@
           "enum": [
             "createdAt",
             "updatedAt",
+            "closedAt",
             "title",
             "category",
             "status",
diff --git a/x-pack/plugins/cases/docs/openapi/bundled.yaml b/x-pack/plugins/cases/docs/openapi/bundled.yaml
index c55ddebf091b2..be8e2da0462e8 100644
--- a/x-pack/plugins/cases/docs/openapi/bundled.yaml
+++ b/x-pack/plugins/cases/docs/openapi/bundled.yaml
@@ -2430,6 +2430,7 @@ components:
         enum:
           - createdAt
           - updatedAt
+          - closedAt
           - title
           - category
           - status
diff --git a/x-pack/plugins/cases/docs/openapi/components/parameters/sortField.yaml b/x-pack/plugins/cases/docs/openapi/components/parameters/sortField.yaml
index 7cc1b3cbe14c1..9df834cf9f5ac 100644
--- a/x-pack/plugins/cases/docs/openapi/components/parameters/sortField.yaml
+++ b/x-pack/plugins/cases/docs/openapi/components/parameters/sortField.yaml
@@ -6,6 +6,7 @@ schema:
   enum:
     - createdAt
     - updatedAt
+    - closedAt
     - title
     - category
     - status