Skip to content

Commit

Permalink
test: 40% coverage of add-edit-adv-request pagee (#2467)
Browse files Browse the repository at this point in the history
* fix: lint issues in add edit adv request page

* test: 12% coverage of add-edit-advance-request page

* minor

* test: 26% coverage of add edit adv request page

* test: 40% coverage of add-edit-adv-request pagee

* test: 58% coverage add-edit-adv-request page (#2476)

* test: 45% coverage of add edit adv request

* 58% coverage of page

* minor

* test: 70% coverage of add-edit-adv-req page (#2479)

* test: 67% coverage of page

* 70% coverage of page

* minor

* minor

* test: 87% coverage of add-edit-adv-request page (#2481)

* test: 87% coverage of add-edit-adv-request page

* test: 98.45% coverage of add-edit-adv-request page (#2482)

* test: 97% coverage

* 98% coverage

* pr fix

* pr comments
  • Loading branch information
suyashpatil78 authored Oct 5, 2023
1 parent 09e8d7c commit de1a71f
Show file tree
Hide file tree
Showing 13 changed files with 1,005 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AddEditAdvanceRequestFormValue } from '../models/add-edit-advance-request-form-value.model';
import { recentlyUsedProjectRes } from './recently-used.data';

export const addEditAdvanceRequestFormValueData: AddEditAdvanceRequestFormValue = {
currencyObj: {
Expand All @@ -20,3 +21,8 @@ export const addEditAdvanceRequestFormValueData2: AddEditAdvanceRequestFormValue
project: null,
customFieldValues: [],
};

export const addEditAdvanceRequestFormValueData3: AddEditAdvanceRequestFormValue = {
...addEditAdvanceRequestFormValueData,
project: recentlyUsedProjectRes[0],
};
40 changes: 40 additions & 0 deletions src/app/core/mock-data/advance-request-custom-field-values.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { AdvanceRequestCustomFieldValues } from '../models/advance-request-custom-field-values.model';

export const advanceRequestCustomFieldValuesData: AdvanceRequestCustomFieldValues[] = [
{
id: 1302,
name: 'Phase',
value: 'Phase 1',
type: 'SELECT',
},
{
id: 1305,
name: 'BILLABLE',
value: true,
type: 'BOOLEAN',
},
{
id: 1304,
name: 'Arrival Date',
value: '2 Jan 2023',
type: 'DATE',
},
];

export const advanceRequestCustomFieldValuesData2: AdvanceRequestCustomFieldValues[] = [
{
id: 1302,
name: 'Phase',
value: 'Phase 1',
},
{
id: 1304,
name: 'Arrival Date',
value: '2023-1-2',
},
{
id: 1305,
name: 'BILLABLE',
value: true,
},
];
45 changes: 45 additions & 0 deletions src/app/core/mock-data/advance-requests-custom-fields.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,48 @@ export const advanceRequestCustomFieldData: AdvanceRequestsCustomFields[] = [
placeholder: '123',
},
];

export const advanceRequestCustomFieldData2: AdvanceRequestsCustomFields[] = [
{
id: 150,
org_id: 'orNVthTo2Zyo',
created_at: new Date('2022-10-30T23:07:03.385Z'),
updated_at: new Date('2022-10-30T23:07:03.385Z'),
type: 'BOOLEAN',
name: 'checking',
options: ['option1', 'option2'],
mandatory: false,
active: true,
added_by: 'ouX8dwsbLCLv',
last_updated_by: 'ouX8dwsbLCLv',
placeholder: null,
},
{
id: 142,
org_id: 'orNVthTo2Zyo',
created_at: new Date('2022-11-04T02:14:37.292Z'),
updated_at: new Date('2022-11-04T02:14:37.292Z'),
type: 'BOOLEAN',
name: 'Okay?',
options: null,
mandatory: false,
active: true,
added_by: 'ouX8dwsbLCLv',
last_updated_by: 'ouX8dwsbLCLv',
placeholder: null,
},
{
id: 144,
org_id: 'orNVthTo2Zyo',
created_at: new Date('2022-11-04T02:14:37.292Z'),
updated_at: new Date('2022-11-04T02:14:37.292Z'),
type: 'BOOLEAN',
name: 'Okay?',
options: null,
mandatory: false,
active: true,
added_by: 'ouX8dwsbLCLv',
last_updated_by: 'ouX8dwsbLCLv',
placeholder: null,
},
];
18 changes: 18 additions & 0 deletions src/app/core/mock-data/advance-requests.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,21 @@ export const checkPolicyAdvReqParam: AdvanceRequests = {
is_sent_back: null,
is_pulled_back: true,
};

export const advanceRequests2: Partial<AdvanceRequests> = {
...advanceRequests,
currency: 'USD',
amount: 130,
purpose: 'Test purpose',
project_id: 168826,
notes: 'Test notes',
source: 'MOBILE',
custom_field_values: null,
};

export const advanceRequests3: Partial<AdvanceRequests> = {
org_user_id: 'ouX8dwsbLCLv',
currency: 'GNF',
source: 'MOBILE',
created_at: new Date(),
};
49 changes: 49 additions & 0 deletions src/app/core/mock-data/file-object.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,52 @@ export const expectedFileData1 = [
thumbnail: 'thumbnail',
},
];

export const advanceRequestFileUrlData: FileObject[] = [
{
...fileObjectAdv1,
},
{
...fileObject7[0],
type: 'jpeg',
id: null,
},
];

export const expectedFileData2: FileObject[] = [
{
type: 'pdf',
url: '2023-02-08/orNVthTo2Zyo/receipts/fi6PQ6z4w6ET.000.pdf',
thumbnail: '2023-02-08/orNVthTo2Zyo/receipts/fi6PQ6z4w6ET.000.pdf',
},
];

export const advanceRequestFileUrlData2: FileObject[] = [
{
...fileObjectAdv1,
id: null,
},
{
...fileObject7[0],
type: 'image',
id: null,
},
];

export const fileObject9: FileObject[] = [
{
id: 'fiV1gXpyCcbU',
org_user_id: 'ouX8dwsbLCLv',
created_at: new Date('2023-03-06T07:51:05.614Z'),
name: '000.jpeg',
s3url: '2023-03-06/orNVthTo2Zyo/receipts/fiV1gXpyCcbU.000.jpeg',
transaction_id: 'tx1vdITUXIzf',
invoice_id: null,
advance_request_id: null,
purpose: 'ORIGINAL',
password: null,
receipt_coordinates: null,
email_meta_data: null,
fyle_sub_url: '/api/files/fiV1gXpyCcbU/download',
},
];
18 changes: 18 additions & 0 deletions src/app/core/mock-data/file.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ export const fileData2: File[] = [
fyle_sub_url: '/api/files/fiK7c69UDJNb/download',
},
];

export const fileData3: File[] = [
{
id: 'fiV1gXpyCcbU',
org_user_id: 'ouX8dwsbLCLv',
created_at: new Date('2023-03-06T07:51:05.614Z'),
name: '000.jpeg',
s3url: '2023-03-06/orNVthTo2Zyo/receipts/fiV1gXpyCcbU.000.jpeg',
transaction_id: 'tx1vdITUXIzf',
invoice_id: null,
advance_request_id: null,
purpose: 'ORIGINAL',
password: null,
receipt_coordinates: null,
email_meta_data: null,
fyle_sub_url: '/api/files/fiV1gXpyCcbU/download',
},
];
57 changes: 57 additions & 0 deletions src/app/core/mock-data/modal-controller.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { reportOptionsData } from './report-options.data';
import { expectedErpt } from './report-unflattened.data';
import { FyInputPopoverComponent } from 'src/app/shared/components/fy-input-popover/fy-input-popover.component';
import { PolicyViolationDialogComponent } from 'src/app/fyle/add-edit-advance-request/policy-violation-dialog/policy-violation-dialog.component';
import { CaptureReceiptComponent } from 'src/app/shared/components/capture-receipt/capture-receipt.component';
import { FyViewAttachmentComponent } from 'src/app/shared/components/fy-view-attachment/fy-view-attachment.component';
import { advanceRequestFileUrlData2 } from './file-object.data';
import { ViewCommentComponent } from 'src/app/shared/components/comments-history/view-comment/view-comment.component';

export const modalControllerParams = {
component: FyFiltersComponent,
Expand Down Expand Up @@ -387,3 +391,56 @@ export const advanceRequestPolicyViolationParams = {
breakpoints: [0, 1],
handle: false,
};

export const popoverControllerParams4 = {
component: PopupAlertComponent,
componentProps: {
title: 'Review',
message:
'This action will save a draft advance request and will not be submitted to your approvers directly. You need to explicitly submit a draft advance request.',
primaryCta: {
text: 'Finish',
action: 'continue',
},
secondaryCta: {
text: 'Cancel',
action: 'cancel',
},
},
cssClass: 'pop-up-in-center',
};

export const modalControllerParams3 = {
component: CaptureReceiptComponent,
componentProps: {
isModal: true,
allowGalleryUploads: false,
allowBulkFyle: false,
},
cssClass: 'hide-modal',
};

export const modalControllerParams4 = {
component: FyViewAttachmentComponent,
componentProps: {
attachments: advanceRequestFileUrlData2,
canEdit: true,
},
mode: 'ios' as Mode,
};

export const modalControllerParams5 = {
component: ViewCommentComponent,
componentProps: {
objectType: 'advance_requests',
objectId: 'areqR1cyLgXdND',
},
cssClass: 'fy-modal',
showBackdrop: true,
canDismiss: true,
backdropDismiss: true,
animated: true,
initialBreakpoint: 1,
breakpoints: [0, 1],
handle: false,
};
74 changes: 74 additions & 0 deletions src/app/core/mock-data/unflattened-advance-request.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { UnflattenedAdvanceRequest } from '../models/unflattened-advance-request.model';

export const unflattenedAdvanceRequestData: UnflattenedAdvanceRequest = {
areq: {
id: 'areqLFKMxUSAlQ',
created_at: new Date('2023-10-03T09:20:22.112Z'),
approved_at: null,
purpose: 'hello',
notes: 'fdv',
state: 'SUBMITTED',
currency: 'USD',
amount: 2,
org_user_id: 'ouuJzJYWcnzP',
advance_id: null,
policy_amount: null,
policy_flag: null,
policy_state: 'SUCCESS',
project_id: null,
custom_field_values: [
{
id: 159,
name: 'Advance Request Place',
value: 'd',
type: null,
},
{
id: 160,
name: 'Category',
value: 'Fyle is best',
type: null,
},
],
updated_at: new Date('2023-10-03T14:50:22.552Z'),
source: 'MOBILE',
advance_request_number: 'AR/2023/10/R/1',
updated_by: null,
is_sent_back: null,
is_pulled_back: null,
},
ou: {
id: 'ouuJzJYWcnzP',
org_id: 'orNbIQloYtfa',
org_name: 'Advance-test',
employee_id: null,
location: null,
level: null,
business_unit: null,
department: null,
title: null,
mobile: null,
sub_department: null,
department_id: null,
},
us: {
full_name: 'Suyash',
email: '[email protected]',
name: 'Suyash',
},
project: {
code: null,
name: null,
},
advance: {
id: null,
},
policy: {
amount: null,
flag: null,
state: 'SUCCESS',
},
new: {
state: 'APPROVAL_PENDING',
},
};
14 changes: 14 additions & 0 deletions src/app/core/models/advance-request-delete-params.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FyDeleteDialogComponent } from 'src/app/shared/components/fy-delete-dialog/fy-delete-dialog.component';
import { AdvanceRequests } from './advance-requests.model';
import { Observable } from 'rxjs';

export interface AdvanceRequestDeleteParams {
component: typeof FyDeleteDialogComponent;
cssClass: string;
backdropDismiss: boolean;
componentProps: {
header: string;
body: string;
deleteMethod: () => Observable<AdvanceRequests>;
};
}
Loading

0 comments on commit de1a71f

Please sign in to comment.