Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implementing SR checkbox functionality #239

Merged
merged 17 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/src/app/dto/changeAuditEntity.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export class ChangeAuditEntityDTO {

@Field()
srAction: string;

@Field(() => Boolean, { nullable: true })
srValue: boolean;
}

@ObjectType()
Expand All @@ -18,4 +21,7 @@ export class ChangeAuditObjectTypeDTO {

@Field()
srAction: string;

@Field()
srValue: boolean;
}
53 changes: 50 additions & 3 deletions backend/src/app/dto/landHistory.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { ResponseDto } from './response/response.dto';
import { LandHistories } from '../entities/landHistories.entity';
import { ChangeAuditObjectTypeDTO } from './changeAuditEntity.dto';
import { LandUseCd } from '../entities/landUseCd.entity';
import { Sites } from '../entities/sites.entity';

@ObjectType()
export class LandHistoryResponse extends ResponseDto {
@Field(() => [LandHistories], { defaultValue: [] })
data: LandHistories[];
@Field(() => [LandHistoriesDTO], { defaultValue: [] })
data: LandHistoriesDTO[];
}

@ObjectType()
class LandHistoriesDTO extends ChangeAuditObjectTypeDTO {
@Field()
siteId: string;

@Field()
guid: string;

@Field()
lutCode: string;

@Field({ nullable: true })
note: string | null;

@Field()
whoCreated: string;

@Field({ nullable: true })
whoUpdated: string | null;

@Field()
whenCreated: Date;

@Field({ nullable: true })
whenUpdated: Date | null;

@Field()
rwmFlag: number;

@Field()
rwmNoteFlag: number;

@Field({ nullable: true })
siteProfile: string | null;

@Field({ nullable: true })
profileDateReceived: Date | null;

@Field(() => LandUseCd)
landUse: LandUseCd;

@Field(() => Sites)
site: Sites;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('AssociatedSiteResolver', () => {
note: 'Note 1',
srAction: 'pending',
userAction: 'pending',
srValue: false,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('DocumentResolver', () => {
filePath: '',
srAction: 'pending',
userAction: 'pending',
srValue: false,
},
];
const expectedResult: DocumentResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('LandHistoryResolver', () => {

describe('getLandHistoriesForSite', () => {
it('should return land histories when found', async () => {
const mockLandHistories = [new LandHistories()];
const mockLandHistories = [{ ...new LandHistories(), srValue: true }];

const showPending = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('NotationResolver', () => {
requirementReceivedDate: new Date('2024-07-10'),
srAction: 'pending',
userAction: 'pending',
srValue: false,
notationParticipant: [
{
eventParticId: 'GUID001',
Expand All @@ -85,6 +86,7 @@ describe('NotationResolver', () => {
srAction: 'pending',
userAction: 'pending',
eventId: '',
srValue: false,
},
{
eventParticId: 'GUID002',
Expand All @@ -94,6 +96,7 @@ describe('NotationResolver', () => {
srAction: 'pending',
userAction: 'pending',
eventId: '',
srValue: false,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('ParticipantResolver', () => {
siteId: '1',
srAction: 'pending',
userAction: 'pending',
srValue: false,
},
];
(
Expand Down
1 change: 1 addition & 0 deletions backend/src/app/resolvers/site/site.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
FetchSiteDetail,
FetchSiteResponse,
SaveSiteDetailsResponse,
SearchSiteResponse,
} from '../../dto/response/genericResponse';
import { Sites } from '../../entities/sites.entity';
import { SiteService } from '../../services/site/site.service';
Expand Down
97 changes: 0 additions & 97 deletions backend/src/app/resolvers/site/sitePublic.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,103 +87,6 @@ describe('SiteResolver', () => {
jest.clearAllMocks();
});

describe('searchSites', () => {
it('should call siteService.searchSites with the provided searchParam and no filter conditions', () => {
const searchParam = 'example';
const page = 1;
const pageSize = 1;
const filters = {};
siteResolver.searchSites(searchParam, page, pageSize, filters);
expect(siteService.searchSites).toHaveBeenCalledWith(
searchParam,
page,
pageSize,
filters,
);
});

it('site search matches a search parameter and no filter conditions', async () => {
const searchParam = '123';
const page = 1;
const pageSize = 1;
const filters = {};
const expectedFilteredSites = new SearchSiteResponse();
expectedFilteredSites.sites = [];
expectedFilteredSites.sites.push(sampleSites[0]); // Only Site 1 matches the searchParam
expectedFilteredSites.page = 1;
expectedFilteredSites.pageSize = 1;
expectedFilteredSites.count = 1;

(siteService.searchSites as jest.Mock).mockResolvedValue(
expectedFilteredSites,
);

const result: SearchSiteResponse = await siteResolver.searchSites(
searchParam,
page,
pageSize,
filters,
);

expect(siteService.searchSites).toHaveBeenCalledWith(
searchParam,
page,
pageSize,
filters,
);
expect(result).toEqual(expectedFilteredSites);
});

/*it('site search matches a search parameter with filter conditions', async () => {
const searchParam = '123';
const page = 1;
const pageSize = 1;
const expectedFilteredSites = new SearchSiteResponse();
expectedFilteredSites.sites = [];
expectedFilteredSites.sites.push(sampleSites[0]); // Only Site 1 matches the searchParam
expectedFilteredSites.page = 1;
expectedFilteredSites.pageSize = 1;
expectedFilteredSites.count = 1;

(siteService.searchSites as jest.Mock).mockResolvedValue(expectedFilteredSites);

const result: SearchSiteResponse = await siteResolver.searchSites(searchParam, page, pageSize);

expect(siteService.searchSites).toHaveBeenCalledWith(searchParam, page, pageSize, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
expect(result).toEqual(expectedFilteredSites);
});*/

it('site search has no matches with the search parameter and no filter conditions', async () => {
const searchParam = 'example';
const page = 1;
const pageSize = 1;
const filters = {};
const expectedFilteredSites = new SearchSiteResponse();
expectedFilteredSites.sites = [];
expectedFilteredSites.page = 1;
expectedFilteredSites.pageSize = 1;
expectedFilteredSites.count = 0;
(siteService.searchSites as jest.Mock).mockResolvedValue(
expectedFilteredSites,
);

const result: SearchSiteResponse = await siteResolver.searchSites(
searchParam,
page,
pageSize,
filters,
);

expect(siteService.searchSites).toHaveBeenCalledWith(
searchParam,
page,
pageSize,
filters,
);
expect(result).toEqual(expectedFilteredSites);
});
});

describe('findSiteBySiteId', () => {
it('should call siteService.findSiteBySiteId with the provided siteId', () => {
const siteId = '123';
Expand Down
6 changes: 4 additions & 2 deletions backend/src/app/resolvers/site/sitePublic.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Args, Field, InputType, Int, Query, Resolver } from '@nestjs/graphql';
import { Unprotected } from 'nest-keycloak-connect';
import { AuthenticatedUser, Unprotected } from 'nest-keycloak-connect';
import {
FetchSiteDetail,
SaveSiteDetailsResponse,
Expand Down Expand Up @@ -79,7 +79,7 @@ export class SiteFilters {
* Resolver for Region
*/
@Resolver(() => Sites)
@Unprotected()
@Unprotected(false)
export class SitePublicResolver {
constructor(
private readonly siteService: SiteService,
Expand All @@ -100,6 +100,7 @@ export class SitePublicResolver {
*/
@Query(() => SearchSiteResponse, { name: 'searchSites' })
async searchSites(
@AuthenticatedUser() userInfo,
@Args('searchParam', { type: () => String }) searchParam: string,
@Args('page', { type: () => Int }) page: number,
@Args('pageSize', { type: () => Int }) pageSize: number,
Expand All @@ -109,6 +110,7 @@ export class SitePublicResolver {
this.sitesLogger.log('SiteResolver.searchSites() start ');

return await this.siteService.searchSites(
userInfo,
searchParam,
page,
pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export class AssociatedSiteService {
siteIdAssociatedWith: assocs?.siteIdAssociatedWith,
effectiveDate: formattedEffectiveDate,
note: assocs?.note ? assocs?.note.trim() : null, // Ensure note is trimmed
srAction:
assocs.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srValue: assocs.srAction === SRApprovalStatusEnum.PUBLIC,
srAction: assocs.srAction,
};
});

Expand Down
3 changes: 1 addition & 2 deletions backend/src/app/services/disclosure/disclosure.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export class DisclosureService {
const res = result?.map((res) => {
return {
...res,
srAction:
res.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srAction: res.srAction === SRApprovalStatusEnum.PUBLIC,
};
});
this.sitesLogger.log(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app/services/document/document.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class DocumentService {
siteId: res.siteId,
title: res.title,
submissionDate: formattedSubmissionDate,
srAction: res.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srAction: res.srAction === SRApprovalStatusEnum.PUBLIC,
documentDate: formattedDocumentDate,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down Expand Up @@ -139,6 +140,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down Expand Up @@ -172,6 +174,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down
2 changes: 2 additions & 0 deletions backend/src/app/services/landHistory/landHistory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LoggerService } from '../../logger/logger.service';

import { UserActionEnum } from '../../common/userActionEnum';
import { HttpException, HttpStatus } from '@nestjs/common';
import { SRApprovalStatusEnum } from '../../common/srApprovalStatusEnum';

export class LandHistoryService {
constructor(
Expand Down Expand Up @@ -67,6 +68,7 @@ export class LandHistoryService {
const result = (await query.getMany()).map((landHistory) => ({
...landHistory,
guid: v4(),
srValue: landHistory.srAction === SRApprovalStatusEnum.PUBLIC,
}));
this.sitesLogger.log('LandHistoryService.getLandHistoriesForSite() end');
this.sitesLogger.debug(
Expand Down
7 changes: 3 additions & 4 deletions backend/src/app/services/notation/notation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export class NotationService {
etypCode: event.etypCode,
eclsCode: event.eclsCode,
userAction: event.userAction ?? UserActionEnum.DEFAULT,
srAction:
event.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srAction: event.srAction === SRApprovalStatusEnum.PUBLIC,
notationParticipant: eventParticsForEvent?.map((partic) => ({
eventParticId: partic.id,
eventId: partic.eventId,
Expand All @@ -131,8 +130,8 @@ export class NotationService {
psnorgId: partic.psnorgId,
displayName: partic.psnorg.displayName,
userAction: partic.userAction ?? UserActionEnum.DEFAULT,
srAction:
partic.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srValue: partic.srAction === SRApprovalStatusEnum.PUBLIC,
srAction: partic.srAction,
})),
};
});
Expand Down
Loading
Loading