Skip to content

Commit

Permalink
Merge pull request #915 from bcgov/feature/ALCS-1068
Browse files Browse the repository at this point in the history
Delete their cards when deleting recons/modifications
  • Loading branch information
dhaselhan authored Aug 25, 2023
2 parents ce144fc + f8779be commit f29c77c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,18 @@ describe('ApplicationModificationService', () => {
expect(modificationRepoMock.save).toHaveBeenCalledTimes(0);
});

it('should call softRemove on delete', async () => {
it('should archive the card and call softRemove on delete', async () => {
const uuid = 'fake';
modificationRepoMock.softRemove.mockResolvedValue({} as any);
cardServiceMock.archive.mockResolvedValue();

await service.delete(uuid);

expect(modificationRepoMock.findOneBy).toBeCalledWith({
uuid,
});
expect(modificationRepoMock.softRemove).toHaveBeenCalledTimes(1);
expect(cardServiceMock.archive).toHaveBeenCalledTimes(1);
});

it('should fail on delete if modification does not exist', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class ApplicationModificationService {

async delete(uuid: string) {
const modification = await this.getByUuidOrFail(uuid);
await this.cardService.archive(modification.cardUuid);
return this.modificationRepository.softRemove([modification]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,16 @@ describe('ReconsiderationService', () => {
} as ApplicationReconsideration);
});

it('should call softRemove on delete', async () => {
it('should archive the card and call softRemove on delete', async () => {
const uuid = 'fake';
reconsiderationRepositoryMock.softRemove.mockResolvedValue({} as any);
cardServiceMock.archive.mockResolvedValue();

await service.delete(uuid);

expect(reconsiderationRepositoryMock.findOne).toHaveBeenCalledTimes(1);
expect(reconsiderationRepositoryMock.softRemove).toHaveBeenCalledTimes(1);
expect(cardServiceMock.archive).toHaveBeenCalledTimes(1);
});

it('should fail on delete if reconsideration does not exist', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export class ApplicationReconsiderationService {

async delete(uuid: string) {
const reconToDelete = await this.fetchAndValidateReconsideration(uuid);
await this.cardService.archive(reconToDelete.cardUuid);
return this.reconsiderationRepository.softRemove([reconToDelete]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,18 @@ describe('NoticeOfIntentModificationService', () => {
expect(modificationRepoMock.save).toHaveBeenCalledTimes(0);
});

it('should call softRemove on delete', async () => {
it('should archive the card and call softRemove on delete', async () => {
const uuid = 'fake';
modificationRepoMock.softRemove.mockResolvedValue({} as any);
cardServiceMock.archive.mockResolvedValue();

await service.delete(uuid);

expect(modificationRepoMock.findOneBy).toBeCalledWith({
uuid,
});
expect(modificationRepoMock.softRemove).toHaveBeenCalledTimes(1);
expect(cardServiceMock.archive).toHaveBeenCalledTimes(1);
});

it('should fail on delete if modification does not exist', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class NoticeOfIntentModificationService {

async delete(uuid: string) {
const modification = await this.getByUuidOrFail(uuid);
await this.cardService.archive(modification.cardUuid);
return this.modificationRepository.softRemove([modification]);
}

Expand Down

0 comments on commit f29c77c

Please sign in to comment.