[Customer Portal][FE][Web] Deprecate Legacy Mock Infrastructure - #184
Conversation
Replace reliance on shared mock data and MockConfigProvider across three hook tests (useGetCallRequests, useGetCaseAttachments, useGetCaseComments). Introduce inline mock response objects and mock the auth API client/fetch to return those responses, remove API_MOCK_DELAY override, and stop toggling isMockEnabled. Update query keys (remove mock flag parameter) and adjust assertions/expectations to match the new mocked API responses. Also set a test window.config base URL where needed.
Remove runtime mock-mode feature and related checks. IdleTimeoutProvider no longer imports or checks isMockEnabled and always enforces idle behavior for signed-in users. MockConfigProvider is simplified to a stub that always provides isMockEnabled: false (preserving the context API and useMockConfig) and removes localStorage/state persistence and setters. Tests updated to remove reliance on mock data import: added a factory to create RecommendedUpdateLevelItem entries and adjusted the aggregateUpdateStats test to use generated multi-product data.
Remove reliance on MockConfigProvider across the customer portal: CreateCasePage no longer imports or checks isMockEnabled, the mock creation shortcut and mock-related submit disabling were removed. NoveraChatPage no longer uses getNoveraResponse and now shows a placeholder message until the API is connected. Also remove the MockConfigProvider unit test file. These changes simplify mock handling and prepare the code for using the real API/flow.
Introduce ProjectUser and CaseCreationMetadata interfaces in responses.ts to model project users and case creation form metadata (projects, products, deployments, issue/severity data and conversation summary). Update AllCasesPage tests to include inline mockCaseMetadata and mockCases fixtures used by the page, and remove an unnecessary mock from NoveraChatPage tests. These changes provide typed shapes for new UI data and make tests self-contained.
Replace shared mockData imports with inline mock objects in tests and add a LoggerProvider wrapper to CaseDetailsTabPanels tests. Update test assertions to match the new mock values (e.g. file.txt and 'Call requests will appear here.'). Remove the API_MOCK_DELAY constant from apiConstants.ts and delete the now-obsolete models/mockFunctions.ts file. These changes simplify test setup, reduce external test dependencies, and remove unused mock utilities.
Remove useMockConfig/isMockEnabled usage from UploadAttachmentModal: delete the import and all checks referencing isMockEnabled, update JSDoc, and simplify the upload enablement and early-return logic so uploads are not gated by the mock config. Also replace the shared mockCaseDetails import in two test files with inline mock objects to make the tests self-contained.
Switch CaseCreationMetadata import to @models/responses and replace shared mockData usages with local, typed inline mocks in tests. Add LoggerProvider wrapper to CaseDetailsActivityPanel tests, adjust the activity test assertion to query the textbox instead of placeholder text, and add typed mock attachments for the attachments panel. These changes decouple tests from @models/mockData and provide more explicit test fixtures and context providers.
Replace MockConfigProvider-based mocking with AuthApiContext/useAuthApiClient mocks across case details, cases filters, and chat history tests. Introduce inline mock responses (mockCaseDetails, mockFiltersResponse, mockChatResponse), stub window.config.CUSTOMER_PORTAL_BACKEND_BASE_URL, and standardize mock fetch helper (mockAuthFetch). Remove API_MOCK_DELAY manipulation and boolean mock flags from query keys, simplify QueryClient defaultOptions, and update assertions to expect API responses and proper error propagation.
ProjectCard: remove dependency on mockFunctions and useMemo, and fall back to safe defaults for stats (slaStatus → "—", openCases → 0, activeChats → 0). Tests: make AllCasesFilters and AllCasesList self-contained by inlining mockCaseMetadata and mockCases instead of importing @models/mockData. This simplifies runtime behavior and keeps tests independent of external mock modules.
Remove use of the mock config provider and simplify authentication/login flow. UserProfile no longer depends on isMockEnabled when deciding to render. LoginBox now only offers the real API sign-in (removed mock sign-in button and mock toggling logic) and updated the copy accordingly. ProjectUsersTab types updated from MockProjectUser to ProjectUser (including localUsers state and new user creation) to align with real API response types.
Refactor Header, ProjectSwitcher, and UserProfile tests to use local inline mock data instead of importing from @models/mockData. Remove the MockConfigProvider mock and related expectations from UserProfile tests, simplifying the test setup and making the tests self-contained. Adjusted beforeEach and updated/removing tests that relied on the mock-config behavior.
Replace legacy MockConfigProvider/API_MOCK_DELAY and direct global fetch stubs with a mocked AuthApiContext.useAuthApiClient (mockAuthFetch). Add inline mock responses for deployments and deployment products, set window.config.CUSTOMER_PORTAL_BACKEND_BASE_URL in test setup, and simplify QueryClient options. Update assertions to expect calls to mockAuthFetch, adjust test names and expectations (e.g. dashboard stats now errors with a "not implemented" message and queryKey no longer includes a boolean flag), and remove outdated mock-mode branches to streamline tests.
Remove MockConfigProvider and related mock handling so hooks always use real API calls. AppWithConfig no longer wraps the app with MockConfigProvider. usePostCreateDeployment and usePostProductVulnerabilities no longer import or check useMockConfig, and mock-specific imports/logic (including mock responses and API_MOCK_DELAY) were removed. This cleans up mock-only code paths and ensures the hooks rely on the authenticated API client.
Remove mock-mode logic from create/classify/comment hooks so they always call the real API. Deleted useMockConfig imports and checks from usePostCase, usePostCaseClassifications, and usePostComment; removed API_MOCK_DELAY and getMockCaseClassification usage and the mock response/delay/throw branches. Also simplified the JSDoc in usePostCase. These changes ensure the hooks use useAuthApiClient unconditionally.
Remove useMockConfig imports and mock-specific behavior from three customer-portal hooks. Files changed: useGetUserDetails, usePostAttachments, usePostCallRequest. Deleted mockUserDetails usage and mock-branching logic, removed thrown errors when mock mode was enabled, and simplified useGetUserDetails queryKey and enabled condition to rely solely on auth state (isSignedIn / isAuthLoading). This makes the hooks behave consistently regardless of mock mode and lets authentication determine when queries/mutations run.
Replace MockConfigProvider/global fetch stubs with a mocked useAuthApiClient across product update levels, vulnerabilities, and project cases tests. Introduce mockAuthFetch responses, set window.config CUSTOMER_PORTAL_BACKEND_BASE_URL in beforeEach, simplify getIdToken mock, remove API_MOCK_DELAY stubbing, and update assertions and query keys (drop mock flag). Also standardize QueryClient defaultOptions formatting and consolidate error-case handling in tests.
Replace mock-enabled behavior across project API hooks and switch to real authenticated fetches. In useGetProjectTimeTrackingStat and useGetRecommendedUpdateLevels, removed MockConfig and mock functions, simplified query keys, updated logger messages, and require the user to be signed in for queries. In useGetProjectUsers, replaced mock data with a real GET request using useAuthApiClient, added response/error handling, updated the result type to ProjectUser[], and enable the query only when authenticated. Minor import cleanup and preserved query staleTime settings.
Remove in-memory mock support and related imports from project API hooks. Deleted useMockConfig, mock data/functions, and API_MOCK_DELAY usages; removed isMockEnabled from query keys and enabled conditions; eliminated mock branches and artificial delays. Updated logging and simplified query keys so hooks rely on real backend and auth state. Files changed: useGetProjectStat.ts, useGetProjectSupportStats.ts, useGetProjects.ts.
Remove in-memory mock support from project API hooks. Deleted useMockConfig and mock data usages in useGetProjectCasesStats, useGetProjectDeployments, and useGetProjectDetails; removed API_MOCK_DELAY and mock-based conditional branches. Update query keys to omit the mock flag and change enabled checks to require the user to be signed in (and auth not loading). Simplified debug logs and keep real fetching via the AuthApiClient.
Remove mock-mode handling from product vulnerability and project cases hooks. Deleted useMockConfig and mock data/timeout imports, removed mock response branches and mock flag from query keys, and tightened query enabled conditions to require real auth (isSignedIn && !isAuthLoading). Files updated: useGetProductVulnerabilities.ts and useGetProjectCases.ts. This simplifies the hooks to always call the backend API instead of returning mock data.
Refactor unit tests for project APIs to mock the Auth API client instead of the previous MockConfigProvider/API_MOCK_DELAY approach. Each test now provides inline mock responses for cases stats, deployments, and project details via useAuthApiClient, sets window.config.CUSTOMER_PORTAL_BACKEND_BASE_URL in beforeEach, and tightens assertions to expected values. Also simplified asgardeo token mocks, normalized QueryClient defaultOptions formatting, and removed imports of shared mock data. Files updated: useGetProjectCasesStats.test.tsx, useGetProjectDeployments.test.tsx, useGetProjectDetails.test.tsx.
Replace legacy test mocks and config toggles with centralized AuthApiContext fetch mocks and explicit mock responses. Updated tests in useGetProjectStat, useGetProjectSupportStats, and useGetProjects to stub API responses (and errors) via useAuthApiClient, set window.config backend URL in setup, and remove MockConfigProvider/API_MOCK_DELAY usage. Simplified assertions and test flows (adjusted expected pagination/limits and removed old mock-enabled/disabled branches) to make tests deterministic and clearer.
Stop using the mock config and mock helper functions in several customer-portal API hooks. Removed isMockEnabled from query keys and enabled checks, deleted mock delays and mock data paths, and simplified logging. useGetDashboardMockStats now throws because the real dashboard stats API is not implemented. fetchDeploymentProducts signature was updated to remove the isMockEnabled option and always call the real backend. Affected files: useGetChatHistory, useGetDashboardMockStats, useGetDeployments, useGetDeploymentsProducts.
Replace MockConfigProvider/global fetch stubs with a mocked useAuthApiClient across API tests. Updated tests in useGetProjectTimeTrackingStat, useGetRecommendedUpdateLevels and usePostAttachments to: mock authenticated API responses via AuthApiContext, set window.config.CUSTOMER_PORTAL_BACKEND_BASE_URL in setup, remove API_MOCK_DELAY and provider-level mock toggles, simplify queryClient defaults, and tighten assertions/timeouts. Also adjusted logger/asgardeo mocks and test expectations to reflect the new API-client-based mocking approach and improved cleanup.
Refactor several customer-portal API tests to use a mocked Auth API client instead of stubbing global fetch or reading MockConfigProvider. Changes in usePostCallRequest.test.tsx, usePostCase.test.tsx, usePostCaseClassifications.test.tsx, and usePostCreateDeployment.test.tsx remove mockIsMockEnabled/MockConfigProvider usage, replace fetch stubs with a mockAuthFetch provided via @context/AuthApiContext (useAuthApiClient), and update assertions to expect calls to mockAuthFetch. Also remove tests that asserted behavior when the mock config was enabled and simplify some expectations (e.g. removed explicit headers check and API_MOCK_DELAY override).
Remove in-file mock handling and mock config dependency from case-related React Query hooks. Deleted useMockConfig, mock data imports, and API_MOCK_DELAY usage; removed branches that returned mock responses and delays. Updated query keys to exclude the mock flag, simplified log messages, and tightened enabled conditions to rely on auth (isSignedIn && !isAuthLoading). Changes applied to useGetCaseComments.ts, useGetCaseDetails.ts, and useGetCasesFilters.ts.
Tests and hooks now centralize calls through the AuthApiContext client and remove the MockConfigProvider paths. Updated usePostProductVulnerabilities test to mock useAuthApiClient (mockAuthFetch) instead of stubbing global fetch or toggling isMockEnabled, and removed mock-only assertions. Simplified useGetCallRequests and useGetCaseAttachments by removing useMockConfig, API_MOCK_DELAY and mock data branches, updating query keys and enabled conditions to require a signed-in user, and cleaning up related log messages.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughRemoved mock-mode infrastructure and mock data across the customer portal: deleted mockFunctions and API_MOCK_DELAY, simplified MockConfigProvider to a static stub, and refactored numerous hooks, providers, components, and tests to always use the AuthApiContext-backed API client and real backend flows. (47 words) Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (7)
apps/customer-portal/webapp/src/utils/__tests__/updates.test.ts (1)
71-78:⚠️ Potential issue | 🔴 CriticalIncorrect expected values for installed breakdown — test will fail.
The math for
totalUpdatesInstalledBreakdowndoesn't match the input data:
- regular: 200 + (19 × 183) = 200 + 3477 = 3677 (test expects 3667)
- security: 40 + (19 × 39) = 40 + 741 = 781 (test expects 791)
The two errors cancel out (both off by 10 in opposite directions), so
totalUpdatesInstalled(4458) is coincidentally correct, but the breakdown assertions will fail.🐛 Proposed fix
- expect(stats.totalUpdatesInstalledBreakdown!.regular).toBe(3667); - expect(stats.totalUpdatesInstalledBreakdown!.security).toBe(791); + expect(stats.totalUpdatesInstalledBreakdown!.regular).toBe(3677); + expect(stats.totalUpdatesInstalledBreakdown!.security).toBe(781);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/utils/__tests__/updates.test.ts` around lines 71 - 78, The test expectations for the installed updates breakdown are wrong—update the assertions on stats.totalUpdatesInstalledBreakdown to use the correct computed values: change the expectation for stats.totalUpdatesInstalledBreakdown!.regular from 3667 to 3677 and change stats.totalUpdatesInstalledBreakdown!.security from 791 to 781 so they match the input data calculations and keep the overall totals consistent.apps/customer-portal/webapp/src/pages/__tests__/AllCasesPage.test.tsx (1)
269-306:⚠️ Potential issue | 🔴 CriticalPagination test is dead code with the current 2-item
mockCases.Stepping through the math with
mockCases.length === 2:
- Line 275:
totalCases = 2- Line 281: asserts
"Showing 10 of 2 cases"— will never match- Line 288: looks for a page-2 button — won't exist (only 2 items, page size 10)
- Line 291:
expectedCountOnPage2 = Math.min(10, Math.max(0, 2 - 10)) = 0This test guaranteed to fail at runtime. Either bulk up
mockCasesto ≥11 items or rewrite the assertions for the actual dataset size.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/pages/__tests__/AllCasesPage.test.tsx` around lines 269 - 306, The pagination test uses a hard-coded page size of 10 but the test data mockCases is only 2 items, so the assertions and page-2 interaction are invalid; update the test to either (A) increase mockCases to at least 11 items so the initial assertion "Showing 10 of X cases" and the page-2 button exist, or (B) make the assertions data-driven by deriving pageSize (10) and using totalCases = mockCases.length to expect "Showing {Math.min(pageSize,totalCases)} of {totalCases} cases" for the first page, only attempt to click a page-2 button if totalCases > pageSize, and compute expectedCountOnPage2 as Math.min(pageSize, Math.max(0, totalCases - pageSize)); adjust uses of renderComponent, totalCases, expectedCountOnPage2, and page2Button accordingly.apps/customer-portal/webapp/src/components/support/case-details/details-tab/__tests__/CaseDetailsDetailsPanel.test.tsx (2)
116-130:⚠️ Potential issue | 🔴 CriticalContradictory test expectations for "Assigned Engineer" with identical data.
Both this test (Line 129) and the test at Line 92 render with
assignedEngineer: null(the base mock value), yet:
- Line 92 expects
getAllByText("Assigned Engineer").length > 0(present)- Line 129 expects
queryByText("Assigned Engineer")to not be in the documentThe overrides on lines 118–125 are all identical to the base mock values (all already
null), so both tests render the same component with the same props. One of them will fail.If the intent is to test with a non-null
assignedEngineerin the base case (Line 80 test), update the mock fixture:Proposed fix — give base mock a non-null assignedEngineer
- assignedEngineer: null, + assignedEngineer: { id: "eng-1", name: "John Doe" },Then the Line 80 test would verify it renders the engineer name, and this test would verify that
nullhides the field.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/components/support/case-details/details-tab/__tests__/CaseDetailsDetailsPanel.test.tsx` around lines 116 - 130, The two tests render the same props because mockCaseDetails currently has assignedEngineer null, causing contradictory expectations; fix this by updating the base fixture mockCaseDetails to include a non-null assignedEngineer value (so tests that rely on the default show the field) and keep the override assignedEngineer: null in the "should display -- for null or undefined values and hide Assigned Engineer when null" test (which uses renderDetailsPanel overrides) so that test specifically verifies hiding the field; locate and change the mockCaseDetails definition and ensure tests still pass.
105-114:⚠️ Potential issue | 🔴 CriticalMock data values don't match test assertions — tests will fail.
Line 109 asserts
"Customer 3i"butmockCaseDetails.account.nameis"Account". Line 112 asserts"Customer Portal – Subscription"butmockCaseDetails.project.nameis"Project". The component renders these values directly viaformatValue(), which passes strings through unchanged.Update the mock fixture to match the assertions:
Proposed fix
- account: { type: null, id: "acc-1", name: "Account" }, + account: { type: null, id: "acc-1", name: "Customer 3i" }, csManager: null, assignedEngineer: null, - project: { id: "p1", name: "Project" }, + project: { id: "p1", name: "Customer Portal – Subscription" },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/components/support/case-details/details-tab/__tests__/CaseDetailsDetailsPanel.test.tsx` around lines 105 - 114, The test asserts specific displayed strings but the mock fixture values differ; update the mockCaseDetails used by renderDetailsPanel() so mockCaseDetails.account.name equals "Customer 3i" and mockCaseDetails.project.name equals "Customer Portal – Subscription" (or change the test assertions to match the existing mock), ensuring the test's renderDetailsPanel() uses the updated mock values referenced by the component's formatValue() output.apps/customer-portal/webapp/src/api/__tests__/useGetProductUpdateLevels.test.tsx (1)
82-84:⚠️ Potential issue | 🟡 Minor
window.configis not cleaned up inafterEach— test isolation risk.
vi.unstubAllGlobals()only reverts globals that were stubbed viavi.stubGlobal(). Sincewindow.configis assigned directly inbeforeEach(line 76), it won't be cleaned up here. Compare withuseGetRecommendedUpdateLevels.test.tsxwhich correctly usesdelete (window as ...).configandqueryClient.clear().Suggested fix
afterEach(() => { - vi.unstubAllGlobals(); + delete (window as unknown as { config?: unknown }).config; + queryClient.clear(); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/api/__tests__/useGetProductUpdateLevels.test.tsx` around lines 82 - 84, afterEach currently only calls vi.unstubAllGlobals() but does not remove the test-injected window.config or clear test state; update the afterEach in useGetProductUpdateLevels.test.tsx to delete (window as any).config (or delete (globalThis as any).config) and call queryClient.clear() in addition to vi.unstubAllGlobals() to restore global state and clear React Query cache, mirroring the cleanup used in useGetRecommendedUpdateLevels.test.tsx.apps/customer-portal/webapp/src/components/support/case-details/header/__tests__/CaseDetailsTabPanels.test.tsx (1)
117-136:⚠️ Potential issue | 🟡 MinorUse the component's
CaseDetailstype for therenderTabPanelsparameter instead oftypeof mockCaseDetails.The
renderTabPanelsfunction parameterdata?: typeof mockCaseDetailsinfersprojectas{ id: string; name: string }(non-nullable), but line 150 attempts to assignproject: null. The component itself expectsdata?: CaseDetails, whereproject: CaseDetailsProject | nullis properly nullable.Change line 120 from:
options?: { data?: typeof mockCaseDetails; isError?: boolean },to:
options?: { data?: CaseDetails; isError?: boolean },And import
CaseDetailsfrom@models/responsesat the top of the test file.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/components/support/case-details/header/__tests__/CaseDetailsTabPanels.test.tsx` around lines 117 - 136, The test helper renderTabPanels currently types its options.data as typeof mockCaseDetails which makes project non-nullable; change the parameter to options?: { data?: CaseDetails; isError?: boolean } (use the CaseDetails type) and add an import for CaseDetails from `@models/responses` at the top of the test file so the test can pass a CaseDetails object with project: null; locate renderTabPanels and mockCaseDetails in the test and update the type and imports accordingly.apps/customer-portal/webapp/src/api/useGetCaseDetails.ts (1)
52-52:⚠️ Potential issue | 🔴 CriticalInclude
projectIdin the request URL for consistency and correctness.The function signature, query key, and enabled condition all require
projectId, yet the URL is${baseUrl}/cases/${caseId}without it. The JSDoc states "Fetches a single case by id for a project," indicating project context is essential. Other project-scoped operations in the codebase (e.g.,useGetCallRequests) include projectId in the URL as/projects/${projectId}/cases/${caseId}/.... Either the URL should be/projects/${projectId}/cases/${caseId}orprojectIdshould be removed from the function signature and enabled condition if the endpoint is truly globally scoped.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/api/useGetCaseDetails.ts` at line 52, The request URL in useGetCaseDetails is missing project context: update the requestUrl construction to include projectId (e.g. use baseUrl/projects/${projectId}/cases/${caseId}) so it matches the function signature, query key and enabled condition that depend on projectId; adjust the requestUrl constant (referencing requestUrl, baseUrl, projectId, caseId in useGetCaseDetails) to use the project-scoped path rather than /cases/${caseId} or alternatively remove projectId from the function signature and enabled logic if the endpoint is truly global.
Replace the inline mocked useAuthApiClient with a reusable mockAuthFetch so tests can set and reset its resolved value cleanly. Add import of afterEach, configure mockAuthFetch.resolve in beforeEach, and reset it in afterEach. Update the AuthApiContext mock to return mockAuthFetch instead of a pre-resolved function to improve test control and cleanup.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/customer-portal/webapp/src/api/__tests__/useGetCaseComments.test.tsx (1)
58-72:window.configis set inbeforeEachbut never cleaned up inafterEach.If other test files in the same Vitest worker don't set their own
window.config, they may inadvertently inherit this value. Consider deleting it inafterEachfor test isolation.Suggested cleanup
afterEach(() => { mockAuthFetch.mockReset(); + delete (window as unknown as { config?: unknown }).config; });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/api/__tests__/useGetCaseComments.test.tsx` around lines 58 - 72, The test sets window.config in the beforeEach (see beforeEach in useGetCaseComments.test.tsx) but does not remove or restore it in afterEach, risking cross-test leakage; update the afterEach block (afterEach in this file) to clean up window.config by deleting it or restoring any previous value so other tests in the same Vitest worker don’t inherit the config.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/customer-portal/webapp/src/api/__tests__/useGetCaseComments.test.tsx`:
- Around line 39-43: Keep the module-scoped mock pattern: ensure the top-level
mockAuthFetch constant is defined and exported to tests and that the vi.mock
replacement returns useAuthApiClient: () => mockAuthFetch so individual tests
can override mockAuthFetch and assert calls; verify the mock name mockAuthFetch
and the hook symbol useAuthApiClient in useGetCaseComments.test.tsx match the
other tests (useGetCaseAttachments.test.tsx, useGetCasesFilters.test.tsx) for
consistency.
---
Nitpick comments:
In `@apps/customer-portal/webapp/src/api/__tests__/useGetCaseComments.test.tsx`:
- Around line 58-72: The test sets window.config in the beforeEach (see
beforeEach in useGetCaseComments.test.tsx) but does not remove or restore it in
afterEach, risking cross-test leakage; update the afterEach block (afterEach in
this file) to clean up window.config by deleting it or restoring any previous
value so other tests in the same Vitest worker don’t inherit the config.
In ProjectCard.tsx, change the default placeholders for openCases and activeChats from '_' to '-' so unavailable stats render a hyphen for better consistency and readability in the UI.
Replace occurrences of para-admin@wso2.com with admin@test.com in mock data and tests. Updated apps/customer-portal/webapp/src/components/support/case-details/attachments-tab/__tests__/CaseDetailsAttachmentsPanel.test.tsx to use the new email and adjust the expectation, and updated apps/customer-portal/webapp/src/models/mockData.ts to keep mockCaseAttachments consistent. This ensures tests and mock fixtures use the same placeholder account.
b22b690
into
wso2-open-operations:customer-portal-milestone-1
Description
This pull request removes all usage of the
MockConfigProviderand the "mock data" testing mode from the customer portal webapp. Tests are updated to use real API mocks instead of relying on mock data toggled by the provider, and the application no longer wraps components inMockConfigProvider. Query keys in tests are also updated to reflect the removal of mock-specific parameters.The most important changes are:
Removal of Mock Data and MockConfigProvider
MockConfigProviderfrom the main app (AppWithConfig.tsx) and test files, so the app and tests no longer support toggling between mock and real data using this provider. [1] [2] [3]isMockEnabledand related logic in test files, simplifying the test setup and focusing tests on real API responses. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Test Refactoring for Real API Mocks
useGetCallRequests.test.tsx,useGetCaseAttachments.test.tsx,useGetCaseComments.test.tsx,useGetCaseDetails.test.tsx,useGetCasesFilters.test.tsx) to use direct API response mocks instead of mock data from@models/mockData. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Query Key Updates
These changes streamline the codebase by removing legacy mock data support, making tests clearer and more closely aligned with production behavior.
Summary by CodeRabbit
Refactor
Tests
Chores