Fix: enable data-browser-library related tests #1029
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The previous PR added 5 test suites to
testPathIgnorePatternsdue to complex mocking requirements for@scality/data-browser-library. This PR fixes those tests and removes the ignore patterns.Problem
@scality/data-browser-libraryhooksuserEventSolution
@scality/data-browser-libraryinjestSetupAfterEnv.tsxjest.spyOnwith synchronousfireEventChanges
Modified Files
jest.config.jstestPathIgnorePatternsfor 5 test suitesjestSetupAfterEnv.tsxjest.mock('@scality/data-browser-library')and clipboard mock implementationuseGetS3ServicePoint.test.tsjest.mocktojest.spyOnpattern for proper module mockingVeeamCapacityOverviewRow.test.tsxuseGetBucketTagginganduseGetObjecthook mocksVeeamCapacityModal.test.tsxusePutObjecthook mock; fixed validation message textISVSummary.test.tsxuseGetS3ServicePointtojest.spyOn; switched clipboard tests fromuserEventtofireEventSelectAccountIAMRole.test.tsxDataServiceRoleProviderto provideassumedRoleimmediately; simplified MSW handlerIssues Encountered and Solutions
Issue 1:
jest.mockNot Working for Partial Module MocksCause:
jest.mockwith factory function couldn't properly mock specific exports while keeping others.Fix: Used
jest.spyOnon imported module objects:Issue 2: MSW Not Intercepting data-browser-library Requests
Cause: The library uses internal S3 client that doesn't go through standard fetch/XHR that MSW intercepts.
Fix: Mock the hooks directly:
Issue 3: Clipboard Tests Failing with
userEventCause:
userEvent.clickis async and the clipboard mock's state wasn't properly synchronized.Fix: Use synchronous
fireEvent.clickandjest.spyOnassertions:Issue 4: SelectAccountIAMRole Stuck at Loading State
Cause:
DataServiceRoleProviderwas waiting for asyncassumeRolecall that never completed in test environment.Fix: Mock
DataServiceRoleProviderto provideassumedRolecontext immediately:Issue 5: Validation Message Mismatch
Cause: Test expected "larger than" but Joi outputs "greater than".
Fix: Updated test assertion to match actual Joi validation message.
Test Coverage Progress
Testing