Skip to content

Commit

Permalink
Merge pull request #1715 from bcgov/feature/ALCS-1965-2
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
dhaselhan authored May 27, 2024
2 parents 54c4645 + 27476aa commit ee49a04
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 6 deletions.
4 changes: 3 additions & 1 deletion alcs-frontend/src/app/features/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ export class SearchComponent implements OnInit, OnDestroy {
}

onReset() {
this.searchForm.reset();
this.searchForm.reset({
portalStatus: [],
});

if (this.fileTypeFilterDropDownComponent) {
this.fileTypeFilterDropDownComponent.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('InboxApplicationService', () => {
>;

const mockSearchRequestDto: InboxRequestDto = {
fileNumber: '100000',
portalStatusCodes: ['A'],
name: 'D',
pid: 'E',
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('InboxApplicationService', () => {
});

it('should successfully build a query using all search parameters defined', async () => {
mockApplicationRepository.find.mockResolvedValue([]);
mockApplicationRepository.createQueryBuilder.mockReturnValue(mockQuery);
mockApplicationSubmissionRepository.createQueryBuilder.mockReturnValue(
mockQuery,
Expand All @@ -98,6 +100,7 @@ describe('InboxApplicationService', () => {
);

expect(result).toEqual({ data: [], total: 0 });
expect(mockApplicationRepository.find).toHaveBeenCalledTimes(1);
expect(mockApplicationRepository.createQueryBuilder).toHaveBeenCalledTimes(
1,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ export class InboxApplicationService {
const promises: Promise<{ fileNumber: string }[]>[] = [];
let didSearch = false;

if (searchDto.fileNumber) {
didSearch = true;
const promise = APP_SEARCH_FILTERS.addFileNumberResults(
searchDto,
this.applicationRepository,
);
promises.push(promise);
}

if (searchDto.portalStatusCodes && searchDto.portalStatusCodes.length > 0) {
didSearch = true;
const promise = APP_SEARCH_FILTERS.addPortalStatusResults(
Expand Down
4 changes: 4 additions & 0 deletions services/apps/alcs/src/portal/inbox/inbox.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export class InboxRequestDto {
@IsOptional()
filterBy?: string;

@IsString()
@IsOptional()
fileNumber?: string;

@IsString()
@IsOptional()
governmentFileNumber?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('InboxNoticeOfIntentService', () => {
let mockRedisService: DeepMocked<RedisService>;

const mockSearchDto: InboxRequestDto = {
fileNumber: '100000',
portalStatusCodes: ['A'],
governmentFileNumber: 'B',
name: 'D',
Expand Down Expand Up @@ -88,7 +89,7 @@ describe('InboxNoticeOfIntentService', () => {
);

expect(result).toEqual({ data: [], total: 0 });
expect(mockNOIRepository.find).toHaveBeenCalledTimes(1);
expect(mockNOIRepository.find).toHaveBeenCalledTimes(2);
expect(mockNOISubRepository.createQueryBuilder).toHaveBeenCalledTimes(3);
expect(mockQuery.andWhere).toHaveBeenCalledTimes(3);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ export class InboxNoticeOfIntentService {
const promises: Promise<{ fileNumber: string }[]>[] = [];
let didSearch = false;

if (searchDto.fileNumber) {
didSearch = true;
const promise = NOI_SEARCH_FILTERS.addFileNumberResults(
searchDto,
this.noiRepository,
);
promises.push(promise);
}

if (searchDto.portalStatusCodes && searchDto.portalStatusCodes.length > 0) {
didSearch = true;
const promise = NOI_SEARCH_FILTERS.addPortalStatusResults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('InboxNotificationService', () => {
let mockRedisService: DeepMocked<RedisService>;

const mockSearchDto: InboxRequestDto = {
fileNumber: '100000',
portalStatusCodes: ['A'],
governmentFileNumber: 'B',
name: 'D',
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('InboxNotificationService', () => {
const result = await service.search(mockSearchDto, '', '', '');

expect(result).toEqual({ data: [], total: 0 });
expect(mockNotificationRepository.find).toHaveBeenCalledTimes(1);
expect(mockNotificationRepository.find).toHaveBeenCalledTimes(2);
expect(
mockNotificationSubmissionRepository.createQueryBuilder,
).toHaveBeenCalledTimes(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ export class InboxNotificationService {
const promises: Promise<{ fileNumber: string }[]>[] = [];
let didSearch = false;

if (searchDto.fileNumber) {
didSearch = true;
const promise = NOTIFICATION_SEARCH_FILTERS.addFileNumberResults(
searchDto,
this.notificationRepository,
);
promises.push(promise);
}

if (searchDto.portalStatusCodes && searchDto.portalStatusCodes.length > 0) {
didSearch = true;
const promise = NOTIFICATION_SEARCH_FILTERS.addPortalStatusResults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { formatStringToPostgresSearchStringArrayWithWildCard } from '../search-h

export const APP_SEARCH_FILTERS = {
addFileNumberResults: (
searchDto: SearchRequestDto,
searchDto: SearchRequestDto | InboxRequestDto,
applicationRepository: Repository<Application>,
) => {
return applicationRepository.find({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formatStringToPostgresSearchStringArrayWithWildCard } from '../search-h

export const NOI_SEARCH_FILTERS = {
addFileNumberResults: (
searchDto: SearchRequestDto,
searchDto: SearchRequestDto | InboxRequestDto,
noiRepository: Repository<NoticeOfIntent>,
) => {
return noiRepository.find({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formatStringToPostgresSearchStringArrayWithWildCard } from '../search-h

export const NOTIFICATION_SEARCH_FILTERS = {
addFileNumberResults: (
searchDto: SearchRequestDto,
searchDto: SearchRequestDto | InboxRequestDto,
notificationRepository: Repository<Notification>,
) => {
return notificationRepository.find({
Expand Down

0 comments on commit ee49a04

Please sign in to comment.