Skip to content
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

[#11878] Fix Edit #13056

Merged
merged 3 commits into from
Apr 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,12 @@ describe('AccountRequestTableComponent', () => {
component.accountRequests = accountRequestResults;
fixture.detectChanges();

const modalSpy = jest.spyOn(ngbModal, 'open').mockImplementation(() => {
return createMockNgbModalRef({});
});
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
};

const modalSpy = jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any);

const editButton: any = fixture.debugElement.nativeElement.querySelector('#edit-account-request-0');
editButton.click();
Expand Down Expand Up @@ -381,9 +384,12 @@ describe('AccountRequestTableComponent', () => {
component.accountRequests = accountRequestResults;
fixture.detectChanges();

jest.spyOn(ngbModal, 'open').mockImplementation(() => {
return createMockNgbModalRef({});
});
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
};

jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any);

jest.spyOn(accountService, 'editAccountRequest').mockReturnValue(throwError(() => ({
error: {
Expand All @@ -410,9 +416,12 @@ describe('AccountRequestTableComponent', () => {
component.accountRequests = accountRequestResults;
fixture.detectChanges();

const modalSpy = jest.spyOn(ngbModal, 'open').mockImplementation(() => {
return createMockNgbModalRef({});
});
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
};

const modalSpy = jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any);

const editedAccountRequest : AccountRequest = {
id: 'id',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input } from '@angular/core';
import { NgbModalRef, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AccountRequestTableRowModel } from './account-request-table-model';
import { EditRequestModalComponentResult } from './admin-edit-request-modal/admin-edit-request-modal-model';
import { EditRequestModalComponent } from './admin-edit-request-modal/admin-edit-request-modal.component';
import {
RejectWithReasonModalComponent,
Expand Down Expand Up @@ -63,14 +64,14 @@ export class AccountRequestTableComponent {
modalRef.componentInstance.accountRequestInstitution = accountRequest.instituteAndCountry;
modalRef.componentInstance.accountRequestComments = accountRequest.comments;

modalRef.result.then(() => {
modalRef.result.then((res: EditRequestModalComponentResult) => {
this.accountService.editAccountRequest(
accountRequest.id,
modalRef.componentInstance.accountRequestName,
modalRef.componentInstance.accountRequestEmail,
modalRef.componentInstance.accountRequestInstitution,
res.accountRequestName,
res.accountRequestEmail,
res.accountRequestInstitution,
accountRequest.status,
modalRef.componentInstance.accountRequestComments)
res.accountRequestComment)
.subscribe({
next: (resp: AccountRequest) => {
accountRequest.comments = resp.comments ?? '';
Expand Down
Loading