Skip to content

Commit

Permalink
WIP fix some types
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-marcellini committed Dec 13, 2024
1 parent 3d11b6c commit 03c9bf9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1491,9 +1491,15 @@ type PolicyInvoicingDetails = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Account balance */
stripeConnectAccountBalance?: number;

/** AccountID */
stripeConnectAccountID?: string;

/** bankAccountID of selected BBA for payouts */
transferBankAccountID?: number;
};

/** The markUp */
markUp?: number;
}>;

/** Names of policy features */
Expand Down Expand Up @@ -1593,7 +1599,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
outputCurrency: string;

/** The address of the company */
address?: CompanyAddress;
address?: CompanyAddress | [];

/** The URL for the policy avatar */
avatarURL?: string;
Expand Down Expand Up @@ -1742,13 +1748,15 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
taxRates?: TaxRatesWithDefault;

/** A set of rules related to the workpsace */
rules?: {
/** A set of rules related to the workpsace approvals */
approvalRules?: ApprovalRule[];

/** A set of rules related to the workpsace expenses */
expenseRules?: ExpenseRule[];
};
rules?:
| {
/** A set of rules related to the workpsace approvals */
approvalRules?: ApprovalRule[];

/** A set of rules related to the workpsace expenses */
expenseRules?: ExpenseRule[];
}
| [];

/** ReportID of the admins room for this workspace */
chatReportIDAdmins?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
currency?: string;

/** Collection of errors that exist in report fields */
errorFields?: OnyxCommon.ErrorFields;
errorFields?: OnyxCommon.ErrorFields | null;

/** Whether the report is waiting on a bank account */
isWaitingOnBankAccount?: boolean;
Expand Down
4 changes: 3 additions & 1 deletion tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3407,6 +3407,7 @@ describe('actions/IOU', () => {
areReportFieldsEnabled: false,
areConnectionsEnabled: false,
employeeList: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'[email protected]': {
role: 'admin',
errors: {},
Expand Down Expand Up @@ -3438,6 +3439,7 @@ describe('actions/IOU', () => {
reimbursable: false,
},
fieldList: {
// eslint-disable-next-line @typescript-eslint/naming-convention
text_title: {
defaultValue: '{report:type} {report:startdate}',
deletable: true,
Expand Down Expand Up @@ -3537,7 +3539,7 @@ describe('actions/IOU', () => {
expect(writeSpy).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
invoiceRoomReportID: expect.not.stringMatching(convertedInvoiceChat.reportID),
invoiceRoomReportID: expect.not.stringMatching(convertedInvoiceChat?.reportID ?? ''),

Check failure on line 3542 in tests/actions/IOUTest.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an `any` value
}),
expect.anything(),
);
Expand Down
12 changes: 8 additions & 4 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CONST from '@src/CONST';
import * as TransactionUtils from '@src/libs/TransactionUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetailsList, Policy, Report, ReportAction} from '@src/types/onyx';
import type {InvoiceReceiver} from '@src/types/onyx/Report';
import {toCollectionDataSet} from '@src/types/utils/CollectionDataSet';
import * as NumberUtils from '../../src/libs/NumberUtils';
import * as LHNTestUtils from '../utils/LHNTestUtils';
Expand Down Expand Up @@ -62,24 +63,27 @@ const policy: Policy = {
isPolicyExpenseChatEnabled: false,
};

const convertedInvoiceChat = {
const convertedInvoiceChat: OnyxEntry<Report> = {
chatType: CONST.REPORT.CHAT_TYPE.INVOICE,
currency: 'USD',
description: '',
errorFields: null,
hasOutstandingChildRequest: false,
hasOutstandingChildTask: false,

// The invoice receiver shouldn't have an accountID when the type is business,
// but this is to test that it still works if the value is present
invoiceReceiver: {
accountID: 33,
policyID: '5F2F82F98C848CAA',
type: 'policy',
},
} as unknown as InvoiceReceiver,
isCancelledIOU: false,
isOwnPolicyExpenseChat: false,
isPinned: false,
isWaitingOnBankAccount: false,
lastActionType: 'REPORTPREVIEW',
lastActorAccountID: '32',
lastActorAccountID: 32,
lastMessageHtml: 'paid $1.00',
lastMessageText: 'paid $1.00',
lastMessageTranslationKey: '',
Expand All @@ -98,7 +102,7 @@ const convertedInvoiceChat = {
},
'33': {
notificationPreference: 'always',
permissions: ['read', 'write', 'share', 'own'],
permissions: [CONST.REPORT.PERMISSIONS.READ, CONST.REPORT.PERMISSIONS.WRITE, CONST.REPORT.PERMISSIONS.SHARE, CONST.REPORT.PERMISSIONS.OWN],
},
},
policyAvatar: '',
Expand Down

0 comments on commit 03c9bf9

Please sign in to comment.