Skip to content

Commit

Permalink
Merge pull request #6741 from shikshalokam/release-4.0.0
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
rajeevsathish authored Jun 17, 2021
2 parents 70603d1 + e60cec5 commit 3c64243
Show file tree
Hide file tree
Showing 21 changed files with 1,095 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
export const profileData = {
block: "27b28dcc-e11f-48a0-ac3f-613a0992da5a",
district: "f3e5b768-9008-4073-baf5-1dffc3c12b0b",
role: "DEO",
state: "1222633c-bef9-4be8-a42d-edffa5a9c7ab",
};

export const TargetEntityType = {
status: 200,
result: {
_id: "5fd098e2e049735a86b748b7",
entityType: "district",
entityName: "ANANTAPUR",
},
responseCode: "OK",
};

export const searchData = {
message: "Entities fetched successfull",
status: 200,
result: [
{
data: [
{
_id: "5fd1f4a0e84a88170cfb0495",
name: "MPPS MALAPANAGUDI, D_AP-D012, 28220100101",
externalId: "28220100101",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb0496",
name: "MPPS H.S.THANDA, D_AP-D012, 28220100202",
externalId: "28220100202",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb0497",
name: "MPPS H.SIDDAPURAM, D_AP-D012, 28220100203",
externalId: "28220100203",
addressLine1: "",
districtName: "D_AP-D012",
selected: true,
},
{
_id: "5fd1f4a0e84a88170cfb0498",
name: "ZPHS H.SIDDAPURAM, D_AP-D012, 28220100204",
externalId: "28220100204",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb0499",
name: "MPPS SCCOL OBULAPURAM, D_AP-D012, 28220100301",
externalId: "28220100301",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb049a",
name: "MPUPS OBULAPURAM, D_AP-D012, 28220100302",
externalId: "28220100302",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb049b",
name: "MPUPS (URDU) D.HIREHAL, D_AP-D012, 28220100402",
externalId: "28220100402",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb049c",
name: "MPPS HIREHAL FORT, D_AP-D012, 28220100403",
externalId: "28220100403",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb049d",
name: "MPPS KURBACOL D HIREHAL, D_AP-D012, 28220100404",
externalId: "28220100404",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
{
_id: "5fd1f4a0e84a88170cfb049e",
name: "ZPHS D.HIREHAL, D_AP-D012, 28220100406",
externalId: "28220100406",
addressLine1: "",
districtName: "D_AP-D012",
selected: false,
},
],
count: 3673,
},
],
responseCode: "OK",
};

export const SearchEvent = {
addressLine1: "",
districtName: "D_AP-D012",
externalId: "28220100101",
isSelected: false,
name: "MPPS MALAPANAGUDI, D_AP-D012, 28220100101",
preSelected: false,
selected: true,
_id: "5fd1f4a0e84a88170cfb0495",
};

export const finalEntityService = [
{
_id: "5fd1f4a0e84a88170cfb0495",
name: "MPPS MALAPANAGUDI, D_AP-D012, 28220100101",
externalId: "28220100101",
addressLine1: "",
districtName: "D_AP-D012",
selected: true,
preSelected: false,
},
{
_id: "5fd1f4a0e84a88170cfb0496",
name: "MPPS H.S.THANDA, D_AP-D012, 28220100202",
externalId: "28220100202",
addressLine1: "",
districtName: "D_AP-D012",
selected: true,
preSelected: false,
},
{
_id: "5fd1f4a0e84a88170cfb0497",
name: "MPPS H.SIDDAPURAM, D_AP-D012, 28220100203",
externalId: "28220100203",
addressLine1: "",
districtName: "D_AP-D012",
selected: true,
preSelected: false,
},
];

export const SubmitResult = {
message: "Updated successfully.",
status: 200,
responseCode: "OK",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import {
async,
ComponentFixture,
TestBed,
tick,
fakeAsync,
flush,
} from "@angular/core/testing";
import { ObservationService, KendraService, CoreModule } from "@sunbird/core";
import {
ConfigService,
ResourceService,
SharedModule,
ILoaderMessage,
INoResultMessage,
} from "@sunbird/shared";
import { ObservationUtilService } from "../../service";
import { debounceTime, map } from "rxjs/operators";
import { AddEntityComponent } from "./add-entity.component";
import { configureTestSuite } from "@sunbird/test-util";
import { HttpClientTestingModule } from "@angular/common/http/testing";
import { SuiModule } from "ng2-semantic-ui";
import { RouterTestingModule } from "@angular/router/testing";
import { Router } from "@angular/router";
import { NO_ERRORS_SCHEMA } from "@angular/core";
import {
profileData,
TargetEntityType,
searchData,
SearchEvent,
SubmitResult,
finalEntityService,
} from "./add-entity.component.spec.data";
import {
throwError as observableThrowError,
of
} from "rxjs";

describe("AddEntityComponent", () => {
let component: AddEntityComponent;
let fixture: ComponentFixture<AddEntityComponent>;
let observationUtilService, observationService, kendraService;
class RouterStub {
navigate = jasmine.createSpy("navigate");
}

const resourceBundle = {};

configureTestSuite();
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule.forRoot(),
CoreModule,
HttpClientTestingModule,
SuiModule,
RouterTestingModule,
],
declarations: [AddEntityComponent],
providers: [
ObservationUtilService,
{ provide: Router, useClass: RouterStub },
{ provide: ResourceService, useValue: resourceBundle },
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AddEntityComponent);
component = fixture.componentInstance;
observationUtilService = TestBed.get(ObservationUtilService);
observationService = TestBed.get(ObservationService);
kendraService = TestBed.get(KendraService);
component.searchQuery = "";
component.payload = {};
});

it("should create", () => {
expect(component).toBeTruthy();
});

it("should call ngonInit()", () => {
spyOn(component, "ngOnInit").and.callThrough();
component.ngOnInit();
expect(component.ngOnInit).toHaveBeenCalled();
});

it("should call ObservationUtilService - getProfileData", () => {
spyOn(observationUtilService, "getProfileDataList").and.callFake(() => {
return Promise.resolve(profileData);
});
component.payload=profileData;
spyOn(component, "getProfileData").and.callThrough();
component.getProfileData();
expect(component.getProfileData).toHaveBeenCalled();
expect(component.payload).toBe(profileData);
});

it("should call the getTargettedEntityType() on error", () => {
spyOn(kendraService, "post").and.returnValue(observableThrowError("error"));
spyOn(component, "getTargettedEntityType").and.callThrough();
component.getTargettedEntityType();
expect(component.getTargettedEntityType).toHaveBeenCalled();
});

it("should call the getTargettedEntityType() on success", () => {
spyOn(kendraService, "post").and.returnValue(of(TargetEntityType));
spyOn(observationService, "post").and.returnValue(of(searchData));
spyOn(component, "getTargettedEntityType").and.callThrough();
component.getTargettedEntityType();
expect(component.getTargettedEntityType).toHaveBeenCalled();
expect(component.targetEntity).toBe(TargetEntityType.result);
expect(component.entities.length).toBeGreaterThanOrEqual(0);
expect(component.count).toBe(searchData.result[0].count)
});

it("should call the getTargettedEntityType() on search failed", () => {
spyOn(kendraService, "post").and.returnValue(of(TargetEntityType));
spyOn(observationService, "post").and.returnValue(
observableThrowError("error")
);
spyOn(component, "getTargettedEntityType").and.callThrough();
component.getTargettedEntityType();
expect(component.getTargettedEntityType).toHaveBeenCalled();
expect(component.targetEntity).toBe(TargetEntityType.result);
expect(component.entities.length).toBeGreaterThanOrEqual(0);
});

it("should call the searchEntity()", () => {
component.page = 1;
component.entities = [];
spyOn(kendraService, "post").and.returnValue(of(TargetEntityType));
spyOn(observationService, "post").and.returnValue(of(searchData));
component.getTargettedEntityType();
spyOn(component, "searchEntity").and.callThrough();
component.searchEntity();
expect(component.searchEntity).toHaveBeenCalled();
expect(component.targetEntity).toBe(TargetEntityType.result);
expect(component.entities.length).toBeGreaterThanOrEqual(0);
expect(component.count).toBe(searchData.result[0].count)
});

it("should call the loadMore()", () => {
spyOn(kendraService, "post").and.returnValue(of(TargetEntityType));
spyOn(observationService, "post").and.returnValue(of(searchData));
component.getTargettedEntityType();
spyOn(component, "loadMore").and.callThrough();
component.loadMore();
expect(component.loadMore).toHaveBeenCalled();
expect(component.targetEntity).toBe(TargetEntityType.result);
expect(component.entities.length).toBeGreaterThanOrEqual(0);
expect(component.count).toBe(searchData.result[0].count)
});

it("should call the selectEntity() if selected is true", () => {
component.selectEntity(SearchEvent);
spyOn(component, "selectEntity").and.callThrough();
});

it("should call the selectEntity() if selected is false", () => {
SearchEvent.selected = false;
component.selectEntity(SearchEvent);
spyOn(component, "selectEntity").and.callThrough();
});

it("should call the submit() on success", () => {
component.entities = finalEntityService;
component.payload = profileData;
component.showDownloadModal = false;
component.modal = {
approve:()=>{}
}
spyOn(observationService, "post").and.returnValue(of(SubmitResult));
spyOn(component, "submit").and.callThrough();
component.submit();
expect(component.submit).toHaveBeenCalled();
expect(SubmitResult.status).toBe(200);
});
});




Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h4> {{resourceService.frmelmnts?.lbl?.instanceName}} </h4>
</div>
<!--/Header-->
<!--Content-->
<div class="sb-modal-content content">
<div class="sb-modal-content content" *ngIf="submission?.title">

<input type="text" [(ngModel)]="submission.title" class="edit-sub-input">
</div>
Expand All @@ -18,7 +18,7 @@ <h4> {{resourceService.frmelmnts?.lbl?.instanceName}} </h4>
</button>
<div class="w-10"></div>
<button type="button" class="ui sb-btn sb-btn-sm sb-btn-primary text-uppercase flex-basis-1" type="submit"
(click)="submit()" [disabled]="!submission.title" [ngClass]="{'sb-btn-disabled' : !submission.title}">
(click)="submit()" [disabled]="!submission?.title" [ngClass]="{'sb-btn-disabled' : !submission?.title}">
{{resourceService.frmelmnts?.btn?.update}}
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const Submission ={
createdAt: "2021-06-14T08:10:47.388Z",
entityExternalId: "28220100203",
entityId: "5fd1f4a0e84a88170cfb0497",
entityType: "school",
evidencesStatus: [{
code: "OB",
name: "Observation",
status: "notstarted"
}],
isRubricDriven: false,
observationId: "60bdabda4d5bea24ac0a5c69",
observationName: "Infrastructure Assessment- Toilets & Urinals",
ratingCompletedAt: "",
scoringSystem: null,
status: "started",
submissionDate: "",
submissionNumber: 5,
title: "Observation 5",
updatedAt: "2021-06-14T08:10:47.388Z",
_id: "60c70f07944a3a53d9256010"
}
Loading

0 comments on commit 3c64243

Please sign in to comment.