diff --git a/portal-frontend/src/app/case-detail/case-actions/case-actions.css b/portal-frontend/src/app/case-detail/case-actions/case-actions.css new file mode 100644 index 0000000..e69de29 diff --git a/portal-frontend/src/app/case-detail/case-actions/case-actions.html b/portal-frontend/src/app/case-detail/case-actions/case-actions.html new file mode 100644 index 0000000..74d6341 --- /dev/null +++ b/portal-frontend/src/app/case-detail/case-actions/case-actions.html @@ -0,0 +1 @@ +

case-actions works!

diff --git a/portal-frontend/src/app/case-detail/case-actions/case-actions.spec.ts b/portal-frontend/src/app/case-detail/case-actions/case-actions.spec.ts new file mode 100644 index 0000000..c6f6700 --- /dev/null +++ b/portal-frontend/src/app/case-detail/case-actions/case-actions.spec.ts @@ -0,0 +1,51 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CaseDetailActions } from '../case-detail.types'; +import { CaseActions } from './case-actions'; + +describe('CaseActions', () => { + let fixture: ComponentFixture; + + function render(actions: CaseDetailActions): HTMLElement { + fixture = TestBed.createComponent(CaseActions); + fixture.componentRef.setInput('actions', actions); + fixture.detectChanges(); + return fixture.nativeElement as HTMLElement; + } + + beforeEach(async () => { + await TestBed.configureTestingModule({ imports: [CaseActions] }).compileComponents(); + }); + + const legacyActions: CaseDetailActions = { + editApplicantDetails: { mode: 'writeThrough', href: '/api/worklist/legacy/1001/details' }, + recordAssessment: { mode: 'redirect', href: '/legacy/aanvraag/1001/beoordeling' }, + takeOwnership: { mode: 'transition', href: '/api/worklist/legacy/1001/take-ownership' }, + }; + + const ownedActions: CaseDetailActions = { + editApplicantDetails: { mode: 'owned', href: '/api/worklist/owned/00000000-0000-0000-0000-000000000002/details' }, + recordAssessment: { mode: 'owned', href: '/api/worklist/owned/00000000-0000-0000-0000-000000000002/assessment' }, + releaseOwnership: { mode: 'transition', href: '/api/worklist/owned/00000000-0000-0000-0000-000000000002/ownership' }, + }; + + it('given a legacy-origin case, renders record-assessment as a link, shows take-ownership, hides release-ownership', () => { + const el = render(legacyActions); + + const link = el.querySelector('[data-testid="record-assessment-link"]'); + expect(link).toBeTruthy(); + expect(link!.getAttribute('href')).toBe('/legacy/aanvraag/1001/beoordeling'); + expect(el.querySelector('[data-testid="record-assessment-form"]')).toBeFalsy(); + expect(el.querySelector('[data-testid="take-ownership-button"]')).toBeTruthy(); + expect(el.querySelector('[data-testid="release-ownership-button"]')).toBeFalsy(); + }); + + it('given an owned-origin case, renders record-assessment as a form trigger, shows release-ownership, hides take-ownership', () => { + const el = render(ownedActions); + + expect(el.querySelector('[data-testid="record-assessment-form"]')).toBeTruthy(); + expect(el.querySelector('[data-testid="record-assessment-link"]')).toBeFalsy(); + expect(el.querySelector('[data-testid="release-ownership-button"]')).toBeTruthy(); + expect(el.querySelector('[data-testid="take-ownership-button"]')).toBeFalsy(); + }); +}); diff --git a/portal-frontend/src/app/case-detail/case-actions/case-actions.ts b/portal-frontend/src/app/case-detail/case-actions/case-actions.ts new file mode 100644 index 0000000..5778596 --- /dev/null +++ b/portal-frontend/src/app/case-detail/case-actions/case-actions.ts @@ -0,0 +1,13 @@ +import { Component, input } from '@angular/core'; + +import { CaseDetailActions } from '../case-detail.types'; + +@Component({ + selector: 'app-case-actions', + imports: [], + templateUrl: './case-actions.html', + styleUrl: './case-actions.css', +}) +export class CaseActions { + readonly actions = input.required(); +}