Skip to content

Commit

Permalink
Merge branch 'refs/heads/staging' into 1374-modify-the-way-chats-are-…
Browse files Browse the repository at this point in the history
…displayed-in-case-display-grouping-by-candidatenot-candidate

# Conflicts:
#	ui/admin-portal/src/app/components/candidate-opp/view-candidate-opp/view-candidate-opp.component.spec.ts
  • Loading branch information
john committed Sep 23, 2024
2 parents d703d51 + 4dbab28 commit a09bce7
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ import {AuthorizationService} from "../../../services/authorization.service";
import {LocalStorageModule, LocalStorageService} from "angular-2-local-storage";
import {CandidateOpportunityService} from "../../../services/candidate-opportunity.service";
import {SalesforceService} from "../../../services/salesforce.service";
import {CountryService} from "../../../services/country.service";
import {PartnerService} from "../../../services/partner.service";
import {CandidateOpportunity} from "../../../model/candidate-opportunity";
import {FormBuilder, FormsModule, ReactiveFormsModule} from "@angular/forms";
import {LOCALE_ID, SimpleChange} from "@angular/core";
import {of} from "rxjs";
import {MockJob} from "../../../MockData/MockJob";
import {HttpClientTestingModule} from "@angular/common/http/testing";
import {QuillModule} from "ngx-quill";
import {TranslateModule} from "@ngx-translate/core";
import {NgbModule} from "@ng-bootstrap/ng-bootstrap";
import {CommonModule} from "@angular/common";
import {mockCandidateOpportunity} from "../../../MockData/MockCandidateOpportunity";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
OpportunityStageNextStepComponent
} from "../../util/opportunity-stage-next-step/opportunity-stage-next-step.component";
import {RouterLinkStubDirective} from "../../login/login.component.spec";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('ViewCandidateOppFromUrlComponent', () => {
let component: ViewCandidateOppFromUrlComponent;
Expand All @@ -36,7 +37,8 @@ describe('ViewCandidateOppFromUrlComponent', () => {
{ provide: CandidateOpportunityService, useValue: spyOpportunityService },
{ provide: AuthenticationService, useValue: mockAuthService },

]
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "../../util/opportunity-stage-next-step/opportunity-stage-next-step.component";
import {MockJobChat} from "../../../MockData/MockJobChat";
import {ChatReadStatusComponent} from "../../chat/chat-read-status/chat-read-status.component";

import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";
describe('ViewCandidateOppComponent', () => {
let component: ViewCandidateOppComponent;
let fixture: ComponentFixture<ViewCandidateOppComponent>;
Expand All @@ -40,7 +40,8 @@ describe('ViewCandidateOppComponent', () => {
{ provide: CandidateOpportunityService, useValue: mockCandidateOpportunityService },
{ provide: AuthenticationService, useValue: mockAuthService },
{ provide: ChatService, useValue: chatService }
]
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
mockAuthService.getLoggedInUser.and.returnValue({ partner: new MockPartner()});
chatService.getOrCreate.and.returnValue(of(new MockJobChat()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {NgSelectModule} from "@ng-select/ng-select";
import {CandidateService} from "../../../../services/candidate.service";
import {AvailImmediateReason, YesNo} from "../../../../model/candidate";
import {AutosaveStatusComponent} from "../../../util/autosave-status/autosave-status.component";
import {MockCandidate} from "../../../../MockData/MockCandidate";

describe('AvailImmediateComponent', () => {
let component: AvailImmediateComponent;
Expand All @@ -45,6 +46,7 @@ describe('AvailImmediateComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(AvailImmediateComponent);
component = fixture.componentInstance;
component.entity= new MockCandidate();
component.candidateIntakeData = {
availImmediate: YesNo.Yes,
availImmediateJobOps: 'Software Development',
Expand All @@ -61,7 +63,7 @@ describe('AvailImmediateComponent', () => {
const availImmediateReasonControl = component.form.get('availImmediateReason');
const availImmediateNotesControl = component.form.get('availImmediateNotes');

expect(availImmediateControl.value).toBe('Yes');
expect(availImmediateControl.value).toBe(YesNo.Yes);
expect(availImmediateJobOpsControl.value).toBe('Software Development');
expect(availImmediateReasonControl.value).toBe(AvailImmediateReason.Health);
expect(availImmediateNotesControl.value).toBe('Some additional notes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ describe('HostEntryLegallyComponent', () => {
it('should initialize the form with candidate data', () => {
const expectedLegallyOption: EnumOption[] = [
{ key: 'Yes', stringValue: 'Yes' },
{ key: 'No', stringValue: 'No' }
{ key: 'No', stringValue: 'No' },
{ key: 'NoResponse', stringValue: 'NoResponse' },
];

const expectedEnterLegally = YesNo.Yes; // Assuming default value for testing

expect(component.form.get('hostEntryLegally').value).toBe(expectedEnterLegally);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {UpdatedByComponent} from "../../../util/user/updated-by/updated-by.compo
import {ShareableDocsComponent} from "../shareable-docs/shareable-docs.component";
import {UserPipe} from "../../../util/user/user.pipe";
import {NgSelectModule} from "@ng-select/ng-select";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('ViewCandidateAttachmentComponent', () => {
let component: ViewCandidateAttachmentComponent;
Expand All @@ -44,7 +45,8 @@ describe('ViewCandidateAttachmentComponent', () => {
FormBuilder,
{ provide: CandidateAttachmentService, useValue: spy },
NgbModal
]
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {ViewCandidateEducationComponent} from "../../education/view-candidate-ed
import {HttpClientTestingModule} from "@angular/common/http/testing";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {NgSelectModule} from "@ng-select/ng-select";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('CandidateEducationTabComponent', () => {
let component: CandidateEducationTabComponent;
Expand All @@ -32,7 +33,8 @@ describe('CandidateEducationTabComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HttpClientTestingModule,FormsModule,ReactiveFormsModule, NgSelectModule],
declarations: [CandidateEducationTabComponent,ViewCandidateCertificationComponent,ViewCandidateEducationComponent]
declarations: [CandidateEducationTabComponent,ViewCandidateCertificationComponent,ViewCandidateEducationComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {HttpClientTestingModule} from "@angular/common/http/testing";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {NgSelectModule} from "@ng-select/ng-select";
import {ViewCandidateAccountComponent} from "../../account/view-candidate-account.component";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('CandidateGeneralTabComponent', () => {
let component: CandidateGeneralTabComponent;
Expand All @@ -33,7 +34,8 @@ describe('CandidateGeneralTabComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HttpClientTestingModule,FormsModule,ReactiveFormsModule, NgSelectModule],
declarations: [ CandidateGeneralTabComponent,ViewCandidateLanguageComponent,ViewCandidateAccountComponent,ViewCandidateRegistrationComponent,ViewCandidateContactComponent ]
declarations: [ CandidateGeneralTabComponent,ViewCandidateLanguageComponent,ViewCandidateAccountComponent,ViewCandidateRegistrationComponent,ViewCandidateContactComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {VisaCheckAuComponent} from "./visa-check-au.component";
import {ComponentFixture, TestBed} from "@angular/core/testing";
import {NgbAccordionModule, NgbModal} from "@ng-bootstrap/ng-bootstrap";
import {LocalStorageModule, LocalStorageService} from "angular-2-local-storage";
import {NO_ERRORS_SCHEMA} from "@angular/core";
import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core";
import {MockCandidate} from "../../../../../../MockData/MockCandidate";
import {CandidateVisa, CandidateVisaJobCheck} from "../../../../../../model/candidate";
import {HttpClientTestingModule} from "@angular/common/http/testing";
Expand All @@ -41,7 +41,7 @@ describe('VisaCheckAuComponent', () => {
{ provide: NgbModal, useValue: {} },
{ provide: LocalStorageService, useValue: {} }
],
schemas: [NO_ERRORS_SCHEMA]
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import {VisaCheckCaComponent} from "./visa-check-ca.component";
import {ComponentFixture, TestBed} from "@angular/core/testing";
import {NO_ERRORS_SCHEMA} from "@angular/core";
import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core";
import {MockCandidate} from "../../../../../../MockData/MockCandidate";
import {
mockCandidateIntakeData
Expand All @@ -31,7 +31,7 @@ describe('VisaCheckCaComponent', () => {
await TestBed.configureTestingModule({
imports: [NgbAccordionModule],
declarations: [VisaCheckCaComponent],
schemas: [NO_ERRORS_SCHEMA]
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from "../../../../visa/visa-job-assessments/relocating-dependants/relocating-dependants.component";
import {RouterLinkStubDirective} from "../../../../../login/login.component.spec";
import {DependantsComponent} from "../../../../intake/dependants/dependants.component";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('VisaCheckUkComponent', () => {
let component: VisaCheckUkComponent;
Expand All @@ -42,7 +43,8 @@ describe('VisaCheckUkComponent', () => {
await TestBed.configureTestingModule({
declarations: [VisaCheckUkComponent,AutosaveStatusComponent,VisaJobCheckUkComponent,CandidateVisaJobComponent,RelocatingDependantsComponent,RouterLinkStubDirective,DependantsComponent],
imports: [NgSelectModule,FormsModule,ReactiveFormsModule,HttpClientTestingModule,NgbAccordionModule,LocalStorageModule.forRoot({})],
providers: [FormBuilder]
providers: [FormBuilder],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {Candidate} from "../../../model/candidate";
import {SavedList} from "../../../model/saved-list";
import {MockSavedList} from "../../../MockData/MockSavedList";
import {MockPartner} from "../../../MockData/MockPartner";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('ViewCandidateComponent', () => {
let component: ViewCandidateComponent;
Expand Down Expand Up @@ -79,7 +80,8 @@ describe('ViewCandidateComponent', () => {
}, { provide: NgbModal, useValue: mockModalService },
{ provide: LocalStorageService, useValue: mockLocalStorageService },
{ provide: AuthenticationService, useValue: mockAuthenticationService }
]
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
mockActivatedRoute = TestBed.inject(ActivatedRoute);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('CandidatesWithChatComponent', () => {

component.onCandidateSelected(mockCandidate);

expect(window.scrollY).toBe(-1);
expect(window.scrollY).toBeLessThanOrEqual( 0);
});

it('should attempt to fetch the chat with the right parameters when a candidate is selected', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {JobOppIntake} from "../../../../../model/job-opp-intake";
import {MockJobOppIntake} from "../../../../../MockData/MockJobOppIntake";
import {HttpClientModule} from "@angular/common/http";
import {TranslateModule} from "@ngx-translate/core";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('JobIntakeTabComponent', () => {
let component: JobIntakeTabComponent;
Expand All @@ -32,7 +33,8 @@ describe('JobIntakeTabComponent', () => {
{ provide: AuthenticationService, useValue: authServiceSpyObj },
{ provide: JobService, useValue: jobServiceObj },
FormBuilder
]
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ describe('SelectListComponent', () => {
expect(component.replace).toBeFalse();
expect(component.changeStatuses).toBeFalse();
});
//
it('should load lists on initialization', fakeAsync(() => {
const mockLists = [MockSavedList];
savedListServiceSpy.search.and.returnValue(of(mockLists));

component.ngOnInit();
tick(); // Wait for observable to resolve

expect(savedListServiceSpy.search).toHaveBeenCalled();
expect(component.lists).toEqual(mockLists);
expect(component.loading).toBeFalse();
}));

it('should handle error while loading lists', fakeAsync(() => {
const errorMessage = 'Error loading lists';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {MockSavedSearch} from "../../../MockData/MockSavedSearch";
import {MockSavedList} from "../../../MockData/MockSavedList";
import {LocalStorageService} from "angular-2-local-storage";
import {CandidateSourceCacheService} from "../../../services/candidate-source-cache.service";
import {SavedSearch} from "../../../model/saved-search";

describe('CandidateSourceComponent', () => {
let component: CandidateSourceComponent;
Expand Down Expand Up @@ -150,20 +151,40 @@ describe('CandidateSourceComponent', () => {
});

it('should fetch extended saved search when seeMore is true', () => {
// Arrange: Set seeMore to true
component.seeMore = true;

// Mock the saved search service to return a MockSavedSearch
savedSearchService.get.and.returnValue(of(new MockSavedSearch()));

// Create a MockCandidateSource that already includes savedSearchType
const mockCandidateSource = new MockCandidateSource();
mockCandidateSource['savedSearchType'] = 'MockSavedSearch'; // Already included in the mock definition

// Set the candidateSource on the component
component.candidateSource = mockCandidateSource;

// Act: Simulate the ngOnChanges lifecycle hook
component.ngOnChanges({
candidateSource: {
currentValue: { id: 1 } as CandidateSource,
previousValue: { id: 2 } as CandidateSource,
firstChange: false,
isFirstChange: () => false,
currentValue: mockCandidateSource, // use mockCandidateSource directly
previousValue: { id: 2 } as CandidateSource, // previous candidate source (optional detail)
firstChange: false, // it's not the first change
isFirstChange: () => false, // function that returns false
},
});

// Assert: Check that the savedSearchService was called with correct arguments
expect(savedSearchService.get).toHaveBeenCalledWith(1, DtoType.EXTENDED);
});

it('should handle errors when fetching saved search', () => {
// Create a MockCandidateSource that already includes savedSearchType
const mockCandidateSource = new MockCandidateSource();
mockCandidateSource['savedSearchType'] = 'MockSavedSearch'; // Already included in the mock definition

// Set the candidateSource on the component
component.candidateSource = mockCandidateSource;
component.seeMore = true;
savedSearchService.get.and.returnValue(throwError('Error'));
component.ngOnChanges({
Expand Down Expand Up @@ -192,7 +213,13 @@ describe('CandidateSourceComponent', () => {
});

it('should fetch saved search on init', () => {
expect(component.seeMore).toBeUndefined();

const mockCandidateSource = new MockCandidateSource();
mockCandidateSource['savedSearchType'] = 'MockSavedSearch'; // Already included in the mock definition

// Set the candidateSource on the component
component.candidateSource = mockCandidateSource;
component.seeMore = true;
savedSearchService.get.and.returnValue(of(new MockSavedSearch()));
component.ngOnChanges({
candidateSource: {
Expand All @@ -202,7 +229,7 @@ describe('CandidateSourceComponent', () => {
isFirstChange: () => true,
},
});
expect(savedSearchService.get).toHaveBeenCalledWith(1, DtoType.FULL);
expect(savedSearchService.get).toHaveBeenCalledWith(1, DtoType.EXTENDED);
});

it('should not call the API if data is already loaded', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ describe('JoblinkComponent', () => {

it('should initialize correctly', () => {
component.jobId = 1;
component.currentJobName = 'New JOB';
component.currentJobName = 'XYZ';

component.ngOnChanges({});

expect(component.searchHeading).toBe('Change job association');
expect(component.currentJobName).toBe('NEW JOB');
});

it('should emit job selection correctly', (done) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ describe('CandidateFieldService', () => {
});
});

describe('get displayableFieldsMap', () => {
it('should return a map of displayable fields', () => {
const fieldsMap = service.displayableFieldsMap;
expect(fieldsMap.size).toBeGreaterThan(0);
});
});


describe('getFieldsFromPaths', () => {
it('should return fields based on provided paths', () => {
const paths = ['gender'];
Expand Down

0 comments on commit a09bce7

Please sign in to comment.