Skip to content
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
14 changes: 7 additions & 7 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@
"../../tests/actions/PolicyProfileTest.ts" "no-restricted-imports" 1
"../../tests/actions/PolicyTagTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/actions/PolicyTaxTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/actions/PolicyTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 86
"../../tests/actions/PolicyTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 74
"../../tests/actions/PolicyTest.ts" "no-restricted-imports" 1
"../../tests/actions/QueuedOnyxUpdatesTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/actions/ReimbursementAccountTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 5
Expand All @@ -1569,7 +1569,7 @@
"../../tests/actions/ReportPreviewActionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 30
"../../tests/actions/ReportPreviewActionUtilsTest.ts" "no-restricted-imports" 2
"../../tests/actions/ReportTest.ts" "@typescript-eslint/no-deprecated/buildNextStepNew" 1
"../../tests/actions/ReportTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 80
"../../tests/actions/ReportTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 58
"../../tests/actions/ReportTest.ts" "no-restricted-imports" 1
"../../tests/actions/SessionTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 12
"../../tests/actions/SubscriptionTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
Expand Down Expand Up @@ -1713,7 +1713,7 @@
"../../tests/unit/CLIVariadicTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/CardFeedErrorsDerivedValueTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/CardFeedUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/CardUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 152
"../../tests/unit/CardUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 56
"../../tests/unit/CardsSectionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/CategoryUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/ChatGPTTranslatorTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 7
Expand Down Expand Up @@ -1741,7 +1741,7 @@
"../../tests/unit/FileUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 13
"../../tests/unit/FlashListTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/FocusTrapForModalTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../tests/unit/FormulaTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 78
"../../tests/unit/FormulaTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 21
"../../tests/unit/FormulaTest.ts" "no-restricted-imports" 1
"../../tests/unit/FraudProtectionTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../tests/unit/GitTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 5
Expand Down Expand Up @@ -1791,7 +1791,7 @@
"../../tests/unit/PersonalDetailsSelectorTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 5
"../../tests/unit/PolicyChangeLogContentTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../tests/unit/PolicySelectorTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 10
"../../tests/unit/PolicyUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 111
"../../tests/unit/PolicyUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 13
"../../tests/unit/PopoverMenuV2Test.tsx" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../tests/unit/PressResponderTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/QuickActionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 7
Expand All @@ -1805,15 +1805,15 @@
"../../tests/unit/ReportActionsUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 35
"../../tests/unit/ReportLayoutUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/ReportNameUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 23
"../../tests/unit/ReportPrimaryActionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 181
"../../tests/unit/ReportPrimaryActionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 35
"../../tests/unit/ReportPrimaryActionUtilsTest.ts" "no-restricted-imports" 1
"../../tests/unit/ReportSecondaryActionUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 31
"../../tests/unit/ReportSecondaryActionUtilsTest.ts" "no-restricted-imports" 2
"../../tests/unit/ReportSubmitUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/ReportTitleUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../tests/unit/ReportTitleUtilsTest.ts" "no-restricted-imports" 1
"../../tests/unit/ReportUtilsGetIconsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/ReportUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 104
"../../tests/unit/ReportUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 18
"../../tests/unit/ReportUtilsTest.ts" "no-restricted-imports" 1
"../../tests/unit/ReportWelcomeTextTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/RequestConflictUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 11
Expand Down
46 changes: 29 additions & 17 deletions tests/actions/PolicyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager';
import {askToJoinPolicy, joinAccessiblePolicy} from '@src/libs/actions/Policy/Member';
import * as Policy from '@src/libs/actions/Policy/Policy';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Onboarding, PolicyJoinMember, PolicyReportField, Policy as PolicyType, Report, ReportAction, ReportActions, Transaction, TransactionViolations} from '@src/types/onyx';
import type {
Onboarding,
PolicyJoinMember,
PolicyReportField,
Policy as PolicyType,
Report,
ReportAction,
ReportActions,
ReportNextStepDeprecated,
Transaction,
TransactionViolations,
} from '@src/types/onyx';
import type {Participant} from '@src/types/onyx/Report';
import createRandomPolicy from '../utils/collections/policies';
import {createRandomReport} from '../utils/collections/reports';
import createRandomTransaction from '../utils/collections/transaction';
import createMock from '../utils/createMock';
import getOnyxValue from '../utils/getOnyxValue';
import * as TestHelper from '../utils/TestHelper';
import type {MockFetch} from '../utils/TestHelper';
Expand Down Expand Up @@ -673,7 +685,7 @@ describe('actions/Policy', () => {
await waitForBatchedUpdates();

const policyID = Policy.generatePolicyID();
const file = {uri: 'file://tmp/avatar.png', name: 'avatar.png', type: 'image/png'} as File;
const file = createMock<File>({uri: 'file://tmp/avatar.png', name: 'avatar.png', type: 'image/png'});
const options = {
currentUserAccountID: ESH_ACCOUNT_ID,
currentUserEmail: ESH_EMAIL,
Expand Down Expand Up @@ -1977,11 +1989,11 @@ describe('actions/Policy', () => {
mockFetch.pause();

// When setting the workspace avatar
const file = {
const file = createMock<File>({
uri: 'file://path/to/avatar.png',
name: 'avatar.png',
type: 'image/png',
} as File;
});
Policy.updateWorkspaceAvatar(policy.id, '', file);

// Then optimistic data should be set in Onyx
Expand Down Expand Up @@ -2010,11 +2022,11 @@ describe('actions/Policy', () => {

// When updating the workspace avatar but fail
mockFetch.fail();
const file = {
const file = createMock<File>({
uri: 'file://path/to/avatar.png',
name: 'avatar.png',
type: 'image/png',
} as File;
});
Policy.updateWorkspaceAvatar(policy.id, policy.avatarURL, file);
await waitForBatchedUpdates();

Expand Down Expand Up @@ -3279,7 +3291,7 @@ describe('actions/Policy', () => {
const buildNextStepNewSpy = jest
.spyOn(require('@libs/NextStepUtils'), 'buildNextStepNew')

.mockReturnValue({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Mock next step'}]} as never);
.mockReturnValue(createMock<ReportNextStepDeprecated>({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Mock next step'}]}));

const getAllPolicyReportsSpy = jest.spyOn(ReportUtils, 'getAllPolicyReports');
const isExpenseReportSpy = jest.spyOn(ReportUtils, 'isExpenseReport');
Expand All @@ -3296,18 +3308,18 @@ describe('actions/Policy', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, fakePolicy);
await waitForBatchedUpdates();

const submittedExpenseReport1 = {reportID: '100', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED} as unknown as Report;
const submittedExpenseReport2 = {reportID: '101', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED} as unknown as Report;
const submittedExpenseReport1 = createMock<Report>({reportID: '100', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED});
const submittedExpenseReport2 = createMock<Report>({reportID: '101', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED});
getAllPolicyReportsSpy.mockReturnValue([submittedExpenseReport1, submittedExpenseReport2]);
isExpenseReportSpy.mockReturnValue(true);
hasViolationsSpy.mockReturnValue(false);

const nextStepKey1 = `${ONYXKEYS.COLLECTION.NEXT_STEP}${submittedExpenseReport1.reportID}` as const;
const nextStepKey2 = `${ONYXKEYS.COLLECTION.NEXT_STEP}${submittedExpenseReport2.reportID}` as const;

const currentNextStep1 = {type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step 1'}]} as never;
const currentNextStep1 = createMock<ReportNextStepDeprecated>({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step 1'}]});

const currentNextStep2 = {type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step 2'}]} as never;
const currentNextStep2 = createMock<ReportNextStepDeprecated>({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step 2'}]});

Policy.setWorkspaceApprovalMode(fakePolicy, ESH_EMAIL, CONST.POLICY.APPROVAL_MODE.OPTIONAL, ESH_ACCOUNT_ID, ESH_EMAIL, {
reportNextSteps: {
Expand Down Expand Up @@ -3351,7 +3363,7 @@ describe('actions/Policy', () => {
const buildNextStepNewSpy = jest
.spyOn(require('@libs/NextStepUtils'), 'buildNextStepNew')

.mockReturnValue({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Mock next step'}]} as never);
.mockReturnValue(createMock<ReportNextStepDeprecated>({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Mock next step'}]}));

const getAllPolicyReportsSpy = jest.spyOn(ReportUtils, 'getAllPolicyReports');
const isExpenseReportSpy = jest.spyOn(ReportUtils, 'isExpenseReport');
Expand All @@ -3368,7 +3380,7 @@ describe('actions/Policy', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, fakePolicy);
await waitForBatchedUpdates();

const submittedReport = {reportID: '200', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED} as unknown as Report;
const submittedReport = createMock<Report>({reportID: '200', policyID, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED});
getAllPolicyReportsSpy.mockReturnValue([submittedReport]);
isExpenseReportSpy.mockReturnValue(true);

Expand All @@ -3377,7 +3389,7 @@ describe('actions/Policy', () => {

const nextStepKey = `${ONYXKEYS.COLLECTION.NEXT_STEP}${submittedReport.reportID}` as const;

const currentNextStep = {type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step'}]} as never;
const currentNextStep = createMock<ReportNextStepDeprecated>({type: 'neutral', icon: CONST.NEXT_STEP.ICONS.CHECKMARK, message: [{text: 'Old next step'}]});

Policy.setWorkspaceApprovalMode(fakePolicy, ESH_EMAIL, CONST.POLICY.APPROVAL_MODE.OPTIONAL, customAccountID, customEmail, {
reportNextSteps: {
Expand Down Expand Up @@ -4068,11 +4080,11 @@ describe('actions/Policy', () => {
const expenseChatReportID = '1';
const expenseReportID = '2';
const transactionID = '3';
const expenseChatReport = {
const expenseChatReport = createMock<Report>({
...createRandomReport(Number(expenseChatReportID), CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT),
policyID,
iouReportID: expenseReportID,
} as Report;
});
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${expenseChatReportID}`, expenseChatReport);

await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
Expand Down Expand Up @@ -7107,7 +7119,7 @@ describe('actions/Policy', () => {
await waitForBatchedUpdates();

const policyID = Policy.generatePolicyID();
const fakeFile = {uri: 'file://test-avatar.png', name: 'test-avatar.png'} as File;
const fakeFile = createMock<File>({uri: 'file://test-avatar.png', name: 'test-avatar.png'});
Policy.createDraftInitialWorkspace({
introSelected: {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM},
workspaceName: WORKSPACE_NAME,
Expand Down
Loading
Loading