Skip to content

Comments

fix/PRO-3155/empty-home-feed-tiles#268

Merged
RanaBug merged 1 commit intostagingfrom
fix/PRO-3155/empty-home-feed-tiles
Mar 25, 2025
Merged

fix/PRO-3155/empty-home-feed-tiles#268
RanaBug merged 1 commit intostagingfrom
fix/PRO-3155/empty-home-feed-tiles

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Mar 25, 2025

Description

  • Adding more conditions that if not met will not display tiles

How Has This Been Tested?

  • Unit Tests and Manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • Refactor

    • Updated display logic across several content components to render only when complete and valid data is available. This enhances robustness and ensures a consistent, error-free user experience.
  • Tests

    • Expanded test coverage with new cases that verify each component correctly handles scenarios with missing or incomplete data, confirming that they remain hidden when required data is not available.

@RanaBug RanaBug requested a review from IAmKio March 25, 2025 11:15
@RanaBug RanaBug self-assigned this Mar 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

The pull request enhances the conditional rendering logic across multiple components in the pillarx app. Each component now performs additional validations on its respective data props (e.g., checking for the presence and validity of keys in objects and non-empty arrays) before rendering. Tests have been updated or added to cover edge cases where data is missing, incomplete, or still loading, ensuring that components return null appropriately to prevent rendering issues.

Changes

File(s) Change Summary
src/apps/.../EditorialTile/EditorialTile.tsx
src/apps/.../EditorialTile/test/EditorialTile.test.tsx
Enhanced conditional rendering to require a defined editorialDisplay with at least two keys; tests added for undefined data, insufficient keys in editorialDisplay, and loading state.
src/apps/.../GenericBannerTile/GenericBannerTile.tsx
src/apps/.../GenericBannerTile/test/GenericBannerTile.test.tsx
Expanded rendering conditions to validate that both meta and bannerDisplay exist and are non-empty; tests now cover scenarios with undefined or empty objects.
src/apps/.../HighlightedMediaGridTile/HighlightedMediaGridTile.tsx
src/apps/.../HighlightedMediaGridTile/test/HighlightedMediaGridTile.test.tsx
Updated null-checks to verify that grid data is present and non-empty, including checks for an empty object; tests added for empty grid data conditions.
src/apps/.../PointsTile/PointsTile.tsx
src/apps/.../PointsTile/test/PointsTile.test.tsx
Modified conditional rendering logic to check for an empty pointsData object in addition to existing conditions; a new test confirms non-rendering when data is empty.
src/apps/.../TokensHorizontalTile/TokensHorizontalTile.tsx,
src/apps/.../TokensHorizontalTile/test/TokensHorizontalTile.test.tsx,
src/apps/.../TokensVerticalTile/TokensVerticalTile.tsx
src/apps/.../TokensVerticalTile/test/TokensVerticalTile.test.tsx
Strengthened rendering conditions by ensuring that token arrays (dataTokensHorizontal and dataTokensVertical) are non-empty before rendering; corresponding tests verify that components return null when given empty token data.

Sequence Diagram(s)

sequenceDiagram
    participant C as Component
    participant P as Props
    participant V as Validation Logic
    participant R as Render Output

    C->>P: Receive props (data, isDataLoading, etc.)
    C->>V: Check required conditions (e.g., valid keys, non-empty arrays)
    alt Conditions Met
        V--)C: Valid Data
        C->>R: Render Component UI
    else Conditions Not Met
        V--)C: Invalid or Insufficient Data
        C->>R: Return null (do not render)
    end
Loading

Suggested reviewers

  • IAmKio

Poem

I'm a bouncy bunny, coding with delight,
Hopping through conditions both day and night.
I peek at props and nibble on each check,
Making sure no data goes awry on deck.
With tests so crisp and code so neat,
I dance with carrots in this dev tweet!
🥕🐇 Happy hops to our changes!

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8fbb6f and 9cb136b.

⛔ Files ignored due to path filters (2)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (12)
  • src/apps/pillarx-app/components/EditorialTile/EditorialTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/EditorialTile/test/EditorialTile.test.tsx (1 hunks)
  • src/apps/pillarx-app/components/GenericBannerTile/GenericBannerTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/GenericBannerTile/test/GenericBannerTile.test.tsx (1 hunks)
  • src/apps/pillarx-app/components/HighlightedMediaGridTile/HighlightedMediaGridTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/HighlightedMediaGridTile/test/HighlightedMediaGridTile.test.tsx (2 hunks)
  • src/apps/pillarx-app/components/PointsTile/PointsTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/PointsTile/test/PointsTile.test.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensVerticalTile/TokensVerticalTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (3)
src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (1)
src/types/api.ts (1)
  • Projection (133-140)
src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (1)
src/types/api.ts (1)
  • Projection (133-140)
src/apps/pillarx-app/components/PointsTile/test/PointsTile.test.tsx (1)
src/types/api.ts (2)
  • Projection (133-140)
  • Points (111-131)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (17)
src/apps/pillarx-app/components/HighlightedMediaGridTile/HighlightedMediaGridTile.tsx (1)

59-60: Good enhancement to the null-checking logic.

The expanded condition now properly handles both cases where grids is an empty array and where dataMediaGrid is an empty object. This more robust check will prevent rendering empty tiles when no meaningful data is available to display.

src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (1)

57-78: Good test case addition.

This test properly validates that the component returns null when given an empty data array, which is crucial for preventing empty tiles from rendering. The test follows good practices by creating well-structured mock data and making a clear assertion about the expected behavior.

src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (1)

70-94: Well-structured test for empty data handling.

This test correctly validates that the component returns null when given an empty data array, ensuring it doesn't render empty tiles. The test follows a consistent pattern with other tests in the codebase and makes a clear assertion about the expected behavior.

src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (1)

57-57: Improved conditional rendering check.

The enhanced condition now properly handles the case where dataTokensHorizontal is an empty array. This prevents the component from rendering when there's no token data to display, which directly addresses the issue of empty home feed tiles.

src/apps/pillarx-app/components/TokensVerticalTile/TokensVerticalTile.tsx (1)

25-25: Good improvement - preventing rendering when token list is empty.

The additional check for dataTokensVertical?.length makes the component more robust by ensuring it only renders when there are tokens to display, which aligns with the PR objective of preventing empty tiles.

src/apps/pillarx-app/components/HighlightedMediaGridTile/test/HighlightedMediaGridTile.test.tsx (1)

67-80: Well-structured test for empty data case.

This test is a good addition that verifies the component correctly handles the edge case when data is empty, which supports the PR objective of preventing empty home feed tiles.

src/apps/pillarx-app/components/GenericBannerTile/GenericBannerTile.tsx (1)

20-27: Comprehensive defensive checks to prevent empty tiles.

The expanded conditional check now thoroughly validates all required data properties before rendering, which effectively prevents empty banner tiles when the necessary data is missing or incomplete.

src/apps/pillarx-app/components/PointsTile/test/PointsTile.test.tsx (1)

117-126: LGTM: Good test coverage for empty data scenario

This test case correctly verifies that the PointsTile component doesn't render when provided with an empty data object, which is essential for preventing empty tiles from appearing in the UI. This matches the PR objective of fixing empty home feed tiles.

src/apps/pillarx-app/components/EditorialTile/EditorialTile.tsx (1)

73-78: Improved conditional rendering logic

The enhanced conditions properly prevent rendering when there's insufficient data. I particularly like the addition of checking both for the existence of editorialDisplay and ensuring it has at least 2 keys, which prevents partially populated tiles from being displayed.

src/apps/pillarx-app/components/EditorialTile/test/EditorialTile.test.tsx (4)

225-233: LGTM: Good test for undefined data

This test properly verifies that the component doesn't render when data is undefined, which is critical for preventing errors and empty displays.


235-251: LGTM: Thorough test for undefined display property

Good coverage of the case where editorialDisplay is undefined, ensuring the component's defensive rendering logic works correctly.


253-271: LGTM: Well-tested edge case

This test nicely covers the case where editorialDisplay has insufficient data (less than 2 keys), aligning with the new rendering condition in the component.


273-281: LGTM: Good loading state test

Properly verifies that the component doesn't render during loading states, preventing flashing of incomplete content.

src/apps/pillarx-app/components/GenericBannerTile/test/GenericBannerTile.test.tsx (4)

115-118: LGTM: Good test for undefined data

This test properly verifies the component's behavior when data is undefined.


120-129: LGTM: Good edge case coverage

Well-written test to verify behavior when meta is an empty object, which is a subtle but important edge case.


131-145: LGTM: Thorough edge case testing

Good test coverage for the scenario when bannerDisplay is undefined, ensuring robust rendering logic.


147-161: LGTM: Comprehensive test suite

This test completes the set of edge cases by checking behavior when bannerDisplay is an empty object. The test suite now thoroughly covers all relevant scenarios to prevent empty tile rendering.

}, [copied]);

if (!data || isDataLoading) {
if (!data || Object.keys(pointsData).length === 0 || isDataLoading) {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential null reference before checking object keys.

The additional check for empty pointsData is good, but there's a risk of a runtime error if data is defined but data.data is undefined, since line 38 assigns pointsData = data?.data as Points. In that case, Object.keys(pointsData) would throw an error.

-  if (!data || Object.keys(pointsData).length === 0 || isDataLoading) {
+  if (!data || !pointsData || Object.keys(pointsData).length === 0 || isDataLoading) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!data || Object.keys(pointsData).length === 0 || isDataLoading) {
if (!data || !pointsData || Object.keys(pointsData).length === 0 || isDataLoading) {

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9cb136b
Status: ✅  Deploy successful!
Preview URL: https://20407cdd.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3155-empty-home-feed.x-e62.pages.dev

View logs

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM

@RanaBug RanaBug merged commit 4d0e822 into staging Mar 25, 2025
7 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.

2 participants