-
Notifications
You must be signed in to change notification settings - Fork 902
WEB-895: Add success notification feedback to client action components #3444
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
Merged
IOhacker
merged 1 commit into
openMF:dev
from
Agaba-Ed:add-client-action-success-notifications
Apr 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
...ients-view/client-actions/accept-client-transfer/accept-client-transfer.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /** | ||
| * Copyright since 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { ActivatedRoute } from '@angular/router'; | ||
| import { of, throwError } from 'rxjs'; | ||
| import { AcceptClientTransferComponent } from './accept-client-transfer.component'; | ||
| import { ClientsService } from 'app/clients/clients.service'; | ||
| import { SettingsService } from 'app/settings/settings.service'; | ||
| import { Dates } from 'app/core/utils/dates'; | ||
| import { provideNativeDateAdapter } from '@angular/material/core'; | ||
| import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; | ||
| import { ClientActionNotifierService } from '../client-action-notifier.service'; | ||
|
|
||
| import { TranslateModule } from '@ngx-translate/core'; | ||
| import { describe, it, expect, jest, beforeEach } from '@jest/globals'; | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| describe('AcceptClientTransferComponent', () => { | ||
| let component: AcceptClientTransferComponent; | ||
| let fixture: ComponentFixture<AcceptClientTransferComponent>; | ||
|
|
||
| let clientsService: Partial<jest.Mocked<ClientsService>>; | ||
| let settingsService: Partial<SettingsService>; | ||
| let dates: Partial<jest.Mocked<Dates>>; | ||
| let notifier: Partial<jest.Mocked<ClientActionNotifierService>>; | ||
|
|
||
| const clientId = '456'; | ||
| const transferDate = new Date(2025, 10, 1).toISOString(); | ||
|
|
||
| const setup = async () => { | ||
| clientsService = { | ||
| executeClientCommand: jest.fn(() => of({})) | ||
| }; | ||
|
|
||
| settingsService = { | ||
| language: { code: 'en' }, | ||
| dateFormat: 'dd MMMM yyyy' | ||
| } as SettingsService; | ||
|
|
||
| dates = { | ||
| formatDate: jest.fn(() => '01 November 2025') | ||
| }; | ||
|
|
||
| notifier = { | ||
| notifyAndNavigate: jest.fn(), | ||
| notify: jest.fn() | ||
| }; | ||
|
|
||
| await TestBed.configureTestingModule({ | ||
| imports: [ | ||
| AcceptClientTransferComponent, | ||
| TranslateModule.forRoot() | ||
| ], | ||
| providers: [ | ||
| { | ||
| provide: ActivatedRoute, | ||
| useValue: { | ||
| data: of({ clientActionData: transferDate }), | ||
| parent: { snapshot: { params: { clientId } } } | ||
| } | ||
| }, | ||
| { provide: ClientsService, useValue: clientsService }, | ||
| { provide: SettingsService, useValue: settingsService }, | ||
| { provide: Dates, useValue: dates }, | ||
| { provide: ClientActionNotifierService, useValue: notifier }, | ||
| provideNativeDateAdapter(), | ||
| provideAnimationsAsync() | ||
| ] | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(AcceptClientTransferComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }; | ||
|
|
||
| beforeEach(setup); | ||
|
|
||
| it('should initialize correctly', () => { | ||
| expect(component.clientId).toBe(clientId); | ||
| expect(component.acceptClientTransferForm).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should call API with acceptTransfer command on submit', () => { | ||
| component.submit(); | ||
|
|
||
| expect(clientsService.executeClientCommand).toHaveBeenCalledWith(clientId, 'acceptTransfer', expect.any(Object)); | ||
| }); | ||
|
|
||
| it('should notify and navigate after successful submission', () => { | ||
| component.submit(); | ||
|
|
||
| expect(notifier.notifyAndNavigate).toHaveBeenCalledWith( | ||
| 'clients.actions.acceptTransfer.success', | ||
| TestBed.inject(ActivatedRoute) | ||
| ); | ||
| }); | ||
|
|
||
| it('should notify failure if API call fails', () => { | ||
| (clientsService.executeClientCommand as jest.Mock).mockReturnValueOnce(throwError(() => new Error('API error'))); | ||
|
|
||
| component.submit(); | ||
|
|
||
| expect(notifier.notify).toHaveBeenCalledWith('clients.actions.acceptTransfer.failure'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.