$kind: http-request
description: |-
  Get list of all Regions

   **On Success**
      
      ``` Json
        { 
            "statusCode": 8000, 
            "data": [
                      {
                          "uid": "b9b9ebe8-63d8-420e-ae38-ab4a72948518",
                          "regionName": "Pwani",
                          "regionCode": "PWN"
                      }
            ],
            "message": "Success"
        }
url: "{{csmisUrl}}/supervision/financial-report/pageable"
method: POST
body:
  type: json
  content: "{\r

    \  \"pageNo\": 0,\r

    \  \"pageSize\": 100\r

    }"
scripts:
  - type: afterResponse
    code: >-
      pm.test("Response status code is 200", function () {
          pm.expect(pm.response.code).to.equal(200);
      });



      pm.test("Response has the required fields", function () {
          const responseData = pm.response.json();

          pm.expect(responseData).to.have.property('statusCode');
          pm.expect(responseData).to.have.property('data');
          pm.expect(responseData).to.have.property('message');
      });



      pm.test("Validate the data object within the response", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          pm.expect(responseData.data).to.exist.and.to.be.an('array');
          responseData.data.forEach(function(item) {
              pm.expect(item).to.have.property('uid').that.is.a('string');
              pm.expect(item).to.have.property('regionName').that.is.a('string');
              pm.expect(item).to.have.property('regionCode').that.is.a('string');
          });
      });



      pm.test("Data array is present and contains the expected number of
      elements", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.have.property('data').that.is.an('array').with.lengthOf(1);
      });



      pm.test("Validate data properties", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          
          responseData.data.forEach(function(region) {
              pm.expect(region.uid).to.be.a('string').and.to.have.lengthOf.at.least(1, "uid should be a non-empty string");
              pm.expect(region.regionName).to.be.a('string').and.to.have.lengthOf.at.least(1, "regionName should be a non-empty string");
              pm.expect(region.regionCode).to.be.a('string').and.to.have.lengthOf.at.least(1, "regionCode should be a non-empty string");
          });
      });
    language: text/javascript
examples: ./.resources/Get Financial Reports.resources/examples
order: 6000
