Skip to content

Commit caa5b4d

Browse files
authored
Fix: deletion parameters with specific value false where being filtered out before calling the API (#29)
1 parent 7f2a9b7 commit caa5b4d

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/app/screens/project-components-screen/project-components-screen.component.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,49 @@ describe('ProjectComponentsScreenComponent', () => {
312312
} as AppShellNotification, 8000);
313313
});
314314

315+
it('should not filter out incident params with boolean false value', () => {
316+
component.projectComponents = [{
317+
name: 'test-component',
318+
status: 'CREATED',
319+
logo: 'http://example.com/logo.png',
320+
url: 'http://example.com',
321+
canDelete: true,
322+
hasAutomatedDeletionWorkflow: false
323+
} as ProjectComponent];
324+
const testComponent = {
325+
name: 'test-component',
326+
status: 'CREATED',
327+
logo: 'http://example.com/logo.png',
328+
url: 'http://example.com',
329+
canDelete: true,
330+
hasAutomatedDeletionWorkflow: false
331+
} as ProjectComponent;
332+
component.selectedProject = { projectKey: 'PROJECT_1', location: 'LOC_1' } as AppProject;
333+
const mockResult = {
334+
deploymentStatus: false,
335+
changeNumber: 'CHG1234567',
336+
reason: 'Test reason',
337+
projectKey: 'PROJECT_1',
338+
componentName: 'test-component'
339+
};
340+
spyOn(component.dialog, 'open').and.returnValue({
341+
afterClosed: () => of(mockResult)
342+
} as any);
343+
344+
component.onRequestDeletionClicked(testComponent);
345+
346+
const incidentParams: CreateIncidentParameter[] = [
347+
{ name: 'is_deployed', type: 'boolean', value: false as Boolean },
348+
{ name: 'change_number', type: 'string', value: 'CHG1234567' as String },
349+
{ name: 'reason', type: 'string', value: 'Test reason' as String }
350+
];
351+
expect(provisionerServiceSpy.requestComponentDeletion).toHaveBeenCalledWith(
352+
'PROJECT_1',
353+
'test-component',
354+
incidentParams
355+
);
356+
});
357+
315358
it('should show error toast when deletion request fails', () => {
316359
component.projectComponents = [{
317360
name: 'test-component',

src/app/screens/project-components-screen/project-components-screen.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ProjectComponentsScreenComponent implements OnInit, OnDestroy {
171171
type: 'string',
172172
value: result.reason as String // NOSONAR
173173
}
174-
].filter(p => p.value); // Filter by defined values, which are undefined when the simple dialog is called
174+
].filter(p => p.value != null); // Filter by defined values, which are undefined when the simple dialog is called
175175
/* eslint-enable @typescript-eslint/no-wrapper-object-types */
176176
this.provisionerService.requestComponentDeletion(
177177
result.projectKey,

0 commit comments

Comments
 (0)