$kind: http-request
description: Get list of all wards
url: "{{csmisUrl}}/location/wards"
method: GET
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.be.an('object');
          pm.expect(responseData).to.include.all.keys('uid', 'postCode', 'districtUid', 'wardName', 'wardCode');
      });



      pm.test("WardName and wardCode are non-empty strings", function () {
        const responseData = pm.response.json();
        
        pm.expect(responseData).to.be.an('object');
        responseData.data.forEach(function(ward) {
          pm.expect(ward.wardName).to.be.a('string').and.to.have.lengthOf.at.least(1, "WardName should not be empty");
          pm.expect(ward.wardCode).to.be.a('string').and.to.have.lengthOf.at.least(1, "WardCode should not be empty");
        });
      });



      pm.test("Data array is present and contains at least one element",
      function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          pm.expect(responseData.data).to.exist.and.to.be.an('array').that.is.not.empty;
      });



      pm.test("Message is an empty string", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData.message).to.equal("");
      });
    language: text/javascript
order: 3000
