Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
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
2 changes: 1 addition & 1 deletion frontend/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

One automated happy path through the real Angular UI and Spring Boot API:
sign in as `agent` → land on the home screen → open customer lookup → search
**Amina** → open **CUS-1001** → record an interaction → see it on her timeline → soft-delete it again (keeps runs repeatable).
**Amina** → open **CUS-1001** → record an interaction → see it on her timeline → soft-delete it again, accepting the confirm (keeps runs repeatable).

It is **not** part of `ng test` or `mvn test` and not in default CI: it needs a
running backend, PostgreSQL, Kafka, and a real Chrome.
Expand Down
4 changes: 4 additions & 0 deletions frontend/e2e/crm-happy-path.e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ test('agent records an interaction for Amina and sees it on her timeline', async
assert.match(await row.getText(), /NOTE/);

// 5. Clean up: soft-delete it (audit row stays in PostgreSQL by design).
// The UI asks before deleting; accept the browser confirm.
await row.findElement(byTestId('delete-interaction')).click();
const prompt = await driver.wait(until.alertIsPresent(), WAIT_MS);
assert.match(await prompt.getText(), new RegExp(`Delete "${summary}" for .*CUS-1001`));
await prompt.accept();
await driver.wait(async () => {
for (const r of await driver.findElements(byTestId('interaction-row'))) {
if ((await r.getText()).includes(summary)) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class CustomerDetailPageComponent implements OnInit {
close(): void {
const current = this.customer();
if (!current) return;
if (!window.confirm(`Close ${current.fullName} (${current.customerId})?`)) return;
this.closing.set(true);
this.error.set(null);
this.api.delete(current.customerId).subscribe({
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/app/features/customers/customer-pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,29 @@ describe('customer pages', () => {
expect(api.getById).toHaveBeenCalledWith('CUS-1001');
expect(fixture.nativeElement.textContent).toContain('Amina Khan');

const confirm = spyOn(window, 'confirm').and.returnValue(true);
fixture.componentInstance.close();
expect(confirm).toHaveBeenCalledWith('Close Amina Khan (CUS-1001)?');
expect(api.delete).toHaveBeenCalledWith('CUS-1001');
expect(celebration.celebrate).toHaveBeenCalledTimes(1);
expect(navigate).toHaveBeenCalledWith(['/customers']);
});

it('detail page does nothing when the close is not confirmed', async () => {
await configure('CUS-1001');
router = TestBed.inject(Router);
const navigate = spyOn(router, 'navigate').and.returnValue(Promise.resolve(true));
const fixture = TestBed.createComponent(CustomerDetailPageComponent);
fixture.detectChanges();

spyOn(window, 'confirm').and.returnValue(false);
fixture.componentInstance.close();

expect(api.delete).not.toHaveBeenCalled();
expect(celebration.celebrate).not.toHaveBeenCalled();
expect(navigate).not.toHaveBeenCalled();
});

it('detail page shows the error and skips confetti when the close is refused', async () => {
api.delete.and.returnValue(
throwError(() => new HttpErrorResponse({ status: 403, statusText: 'Forbidden' })),
Expand All @@ -104,6 +121,7 @@ describe('customer pages', () => {
const fixture = TestBed.createComponent(CustomerDetailPageComponent);
fixture.detectChanges();

spyOn(window, 'confirm').and.returnValue(true);
fixture.componentInstance.close();

expect(api.delete).toHaveBeenCalledWith('CUS-1001');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class InteractionDetailPageComponent implements OnInit {
remove(): void {
const current = this.interaction();
if (!current) return;
if (!window.confirm(`Delete "${current.summary}" for ${current.customerId}?`)) return;
this.deleting.set(true);
this.error.set(null);
this.api.delete(current.id).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export class InteractionListPageComponent {
}

remove(row: Interaction): void {
const customer = this.customers().find((c) => c.customerId === row.customerId);
const who = customer ? `${customer.fullName} (${row.customerId})` : row.customerId;
if (!window.confirm(`Delete "${row.summary}" for ${who}?`)) return;
this.savedNotice.set('');
this.error.set(null);
this.api.delete(row.id).subscribe({
Expand Down
29 changes: 29 additions & 0 deletions frontend/src/app/features/interactions/interaction-pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ describe('interaction pages', () => {
expect(fixture.nativeElement.textContent).toContain('Requested address update');
});

it('list page deletes a row only after the user confirms', () => {
const fixture: ComponentFixture<InteractionListPageComponent> =
TestBed.createComponent(InteractionListPageComponent);
fixture.detectChanges();
const confirm = spyOn(window, 'confirm').and.returnValue(false);

fixture.componentInstance.remove(sample);
expect(confirm).toHaveBeenCalledWith(`Delete "${sample.summary}" for CUS-1001?`);
expect(api.delete).not.toHaveBeenCalled();

confirm.and.returnValue(true);
fixture.componentInstance.remove(sample);
expect(api.delete).toHaveBeenCalledWith(sample.id);
});

it('detail page keeps the interaction when the delete is not confirmed', () => {
const navigate = spyOn(router, 'navigate').and.returnValue(Promise.resolve(true));
const fixture = TestBed.createComponent(InteractionDetailPageComponent);
fixture.detectChanges();
spyOn(window, 'confirm').and.returnValue(false);

fixture.componentInstance.remove();

expect(api.delete).not.toHaveBeenCalled();
expect(navigate).not.toHaveBeenCalled();
});

it('create page submits the Lab 49 DTO and routes to the created detail', () => {
const navigate = spyOn(router, 'navigate').and.returnValue(Promise.resolve(true));
const fixture = TestBed.createComponent(InteractionCreatePageComponent);
Expand Down Expand Up @@ -99,7 +126,9 @@ describe('interaction pages', () => {
summary: 'Updated',
});

const confirm = spyOn(window, 'confirm').and.returnValue(true);
fixture.componentInstance.remove();
expect(confirm).toHaveBeenCalledWith('Delete "Updated" for CUS-1001?');
expect(api.delete).toHaveBeenCalledWith(sample.id);
expect(navigate).toHaveBeenCalledWith(['/interactions'], {
queryParams: { customerId: 'CUS-1001' },
Expand Down
Loading