Skip to content

Conversation

geolffreym
Copy link
Member

No description provided.

cswni and others added 30 commits March 18, 2025 19:56
- Added `change-case.test.ts` in `src/utils/__test__/` to test `paramCase` and `snakeCase` utility functions.
  - Verified handling of spaces, special characters, case conversion, and edge cases.
  - Included snapshot testing for various inputs.
- Generated corresponding snapshot file `change-case.test.ts.snap` to validate consistent outputs.
- Added tests for `handleNotification` in `events.test.ts` to ensure:
  - Correct dispatch of `appendNotification` when `profileId` matches receiver.
  - No dispatch when `profileId` does not match or dispatch is not provided.
  - Accurate creation of `onMarkAsRead` function for notifications.
- Added tests for `handleEvents` to verify:
  - Correct handler invocation based on event type.
  - Proper handling when event type or payload is missing or unknown.
- Verified `eventsHandlersMap` contains the `NOTIFICATION` handler.
Cleaned up unused imports from the change-case.test.ts file.
- Removed `describe`, `it`, and `expect` imports from 'vitest'.
This ensures the file only contains necessary imports, reducing clutter.
- Added test cases in `flatten-array.test.ts` to validate:
  - Handling of nested, deeply nested, and custom-key arrays.
  - Responses for edge cases like empty arrays and arrays with no or empty children.
  - Preservation of all object properties during flattening.
  - Behavior with null and undefined inputs.
  - Snapshot testing for various input scenarios.
- Included generated snapshot file in `__snapshots__/flatten-array.test.ts.snap`.
Added comprehensive test cases for the `format-time` utility functions.
- `src/utils/__test__/format-time.test.ts`:
  - Added test cases for `fDate`, `fDateTime`, `fTimestamp`, and `fToNow`.
  - Verified outputs, edge cases (null/undefined), and snapshot tests.
- `src/utils/__test__/__snapshots__/format-time.test.ts.snap`:
  - Generated snapshot files to ensure consistent output for various test cases.
- Created `highlight.test.ts` to validate highlight.js utils.
- Mocked `highlight.js` and its styles for testing.
- Verified `highlight.js` configuration with correct languages.
- Ensured `window.hljs` is set when `window` is defined.
- Tested highlighting different supported languages successfully.
- Added tests for language auto-detection with `highlightAuto`.
- Checked behavior when `window` is undefined (no `hljs` set).
- `errors.test.ts`:
  - Verified the `ERROR_MESSAGES` object for completeness, format, and consistency.
  - Added specific tests to validate placeholder logic and message correctness.
  - Included snapshot testing for error messages.

- `info.test.ts`:
  - Tested `INFO_MESSAGES` for all keys and placeholders using snapshots.
  - Ensured consistency in deposit, withdraw, and approval-related info messages.
  - Validated template patterns and confirmation phrases.

- `internal-notifications.test.ts`:
  - Covered notification methods (`notifyError`, `notifySuccess`, etc.) comprehensively.
  - Included tests for fallback messages and template tag replacements.
  - Verified notifier options and edge cases when global notifier is not set.

- `success.test.ts`:
  - Ensured `SUCCESS_MESSAGES` structure, placeholders, and consistency via unit and snapshot tests.

- `warning.test.ts`:
  - Validated `WARNING_MESSAGES` comprehensiveness, format, and absence of placeholders.
  - Tested consistency in wallet- and amount-related warnings.

- Added snapshots for `errors`, `info`, `success`, and `warning` messages.
- Moved `ipfs.ts` from `src/utils` to `src/libs` for better organization.
- Updated imports in the following files to reflect the new path:
  - `src/hooks/use-submit-assets-to-lens.ts`
  - `src/components/login-modal/profile-form-view.tsx`
  - `src/workers/backgroundTaskWorker.ts`
  - `src/sections/publication/components/publication-details-comment-form.tsx`
- Moved common interfaces and types from multiple files:
  - Consolidated 'ProcessedTransactionData', 'Transaction', 'EventName', and others into 'src/libs/types.ts'.
  - Adjusted imports and updated relevant files:
    - 'groupedTransactions.ts' now imports Transaction-related types.
    - 'internal-notifications.ts' references 'NotificationType' and 'NotificationOptions' from the centralized types.
    - 'carousel/index.ts' relies on 'CalculateItemsPerSlideProps' from the consolidated types.
    - 'ipfs.ts' uses 'PinataHeaders', 'PinataResponse', 'IPFSMetadata' from the shared types file.
- Removed duplicate type definitions and improved maintainability.
# Conflicts:
#	src/App.tsx
#	src/components/follow-unfollow-button.tsx
#	src/components/login-modal/profile-form-view.tsx
#	src/components/login-modal/profile-select-view.tsx
#	src/components/subscribe-profile-modal.tsx
#	src/hooks/protocol/use-authorize-policy.ts
#	src/hooks/protocol/use-configure-campaign.ts
#	src/hooks/protocol/use-create-campaign.ts
#	src/hooks/protocol/use-deposit.ts
#	src/hooks/protocol/use-has-access.ts
#	src/hooks/protocol/use-register-asset.ts
#	src/hooks/protocol/use-sponsored-access-agreement.ts
#	src/hooks/protocol/use-subscribe.ts
#	src/hooks/protocol/use-transfer-asset.ts
#	src/sections/finance/components/finance-invite-friends.tsx
#	src/sections/finance/views/finance-view.tsx
#	src/sections/marketing/components/campaign-settings-modal-content.tsx
#	src/sections/ownership/components/ownership-process.tsx
#	src/sections/publication/components/publication-details-comment-form.tsx
#	src/sections/user/views/user-profile-view.tsx
- Add a new `IPFSError` class for standardized error representation in `src/libs/ipfs.ts`.
- Update all error handling to use `IPFSError`, providing better context for debugging:
  - Modify `uploadToIPFS` to throw `IPFSError` on failures.
  - Enhance error handling in `uploadImageToIPFS`, `uploadImagesToIPFS`, `uploadMetadataToIPFS`, and `verifyIPFSData`.
- Ensure original errors are preserved and logged with meaningful messages.
…fallback logic

- Introduced `TemplateValue` type to simplify and standardize type definitions across functions in `internal-notifications.ts`.
- Replaced logical OR (`||`) with nullish coalescing (`??`) in fallback message handling for improved clarity and safety.
- Updated all affected functions (`notify`, `notifyError`, `notifySuccess`, `notifyWarning`, `notifyInfo`) to use the new `TemplateValue` type and adjusted fallback logic.
- Updated `src/libs/storage-available.ts` to use the nullish coalescing operator (??) instead of the logical OR operator (||).
- This ensures that falsy values like 0 or empty strings are not mistakenly replaced by the default value.
- Added a `SupabaseError` class to standardize error handling across `supabase-actions.ts`.
- Updated all functions to use `SupabaseError` for capturing and throwing errors.
- Enhanced error logging with `console.error` to clarify and standardize output.
- Introduced `createSupabaseError` utility in `src/libs/supabase-actions.ts` to standardize error handling.
- Replaced repetitive error handling code in various functions with `createSupabaseError`.
- Affected functions include `fetchInvitations`, `checkPendingInvitations`, `acceptInvitation`, `checkInvitationStatus`, `checkAcceptedInvitations`, `sendInvitation`, `acceptOrCreateInvitation`, and `checkInvitedStatus`.
This change reduces duplicated code, improves readability, and ensures consistency.
- `src/components/__test__/modal.test.tsx`: Updated comment for a specific TypeScript error.
- `src/components/markdown/markdown.tsx`: Improved typing with `PropsWithChildren` and removed unused variables.
- `src/components/video-player/video-player.tsx`: Replaced `@ts-ignore` with `@ts-expect-error` and fixed comment formatting.
- Updated all instances across components and hooks to replace `@ts-ignore` with `@ts-expect-error` for improved TypeScript error handling, including:
  - Various test files (`types.test.tsx`, `setupTest.tsx`).
  - Redux-related files (`notifications`, `nav-toggle-button`).
  - UI components (`carousel`, `header-balance`, `login-modal`, `dashboard layout`, etc.).
- Extracted `TableHeadCustomProps` from `table-head-custom.tsx` and moved it to `types.ts`.
- Added `HeadLabel` interface to define the structure of head label objects.
- Updated imports in `table-head-custom.tsx` to reference new type definitions.

This improves code organization and reusability by consolidating type definitions into one location.
- Removed unnecessary comments at the top of the file.
- Updated `getComparator` to use a generic type `T` instead of a constrained key type for improved flexibility.
- Adjusted comparator function signatures for clarity and broader applicability.
- Updated `style` prop type to `CSSProperties` for better type safety in `src/components/watchit-loader/index.tsx`.
- Added a default empty object fallback for `style` prop when undefined.
- Updated type casting for `profileImage` and `backgroundImage` in `modal.tsx` to use `ProfilePictureSet` for improved type safety.
- Added a `@ts-expect-error` comment to suppress type checking where necessary.
- Added `@ts-expect-error` to suppress false type error on `ProfilePictureSet` import in `src/components/user-item/index.tsx`.
- Explicitly specified `Profile` type for `profile` variable to improve clarity and type safety.
- Refined `AvatarProfile` usage by casting `profile?.metadata?.picture` as `ProfilePictureSet`.
- Added type assertions for `address` and `displayName` to enforce stricter type checking in `UserNameAndBadge`.
- `use-typography.ts`: Refactored `getFont` function to improve readability, extracting font properties explicitly and aligning with `FontProperties`. Adjusted `lineHeight` computation to use extracted values. Removed redundant imports.
- `types.ts`: Added the `FontProperties` interface to define typing for font property objects, enhancing type safety and maintainability.
- Added a `@ts-expect-error` directive to suppress type error related to `ProfilePictureSet` import in `subscribe-profile-modal.tsx`.
- Changed type casting for `profile.metadata.picture` to `ProfilePictureSet` for proper handling in the `avatar` field.

These changes ensure type safety and eliminate potential runtime errors.
- Removed unnecessary @ts-expect-error annotation in `activate-subscription-profile-modal.tsx` as it was not required.
- Updated `catch` block to log detailed error messages for better debugging.
- Updated `Hls.Events.ERROR` handler to use `ErrorData` type in `video-player.tsx`.
- Added a `@ts-expect-error` comment to suppress the type mismatch warning in the context of event handling.
- Replace `any` with `NeonPaperProps` in `neonPaperProps` for stricter typing in `sponsored-access-button/types.ts`.
- Improve type safety and consistency by using specific imported types.
Copy link
Member

@Jadapema Jadapema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@geolffreym geolffreym merged commit 6b077f1 into main May 15, 2025
3 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants