Skip to content

[Customer Portal][FE][Web] Implement Error States for Project Hub and Refactor Test Suite - #130

Merged
Rashmika998 merged 10 commits into
wso2-open-operations:customer-portal-milestone-1from
dileepapeiris:feat/add-error-state
Feb 12, 2026
Merged

Rashmika998 merged 10 commits into
wso2-open-operations:customer-portal-milestone-1from
dileepapeiris:feat/add-error-state

Conversation

@dileepapeiris

@dileepapeiris dileepapeiris commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request introduces improved empty and error state handling in the Project Hub page, replacing basic text messages and legacy error indicators with dedicated icon components and more descriptive messaging. It also adds unit tests for the new error state icon and updates mocks in related tests to support these changes.

image image

Enhancements to empty and error state UI:

  • Replaced basic text and legacy error indicator in ProjectHub with new icon components (EmptyIcon and ErrorStateIcon) and updated messaging for both empty and error states. This includes improved layout and more user-friendly descriptions. (apps/customer-portal/webapp/src/pages/ProjectHub.tsx) [1] [2]
  • Added new EmptyIcon component for empty state visuals. (apps/customer-portal/webapp/src/components/common/empty-state/EmptyIcon.tsx)
  • Added new ErrorStateIcon component and its unit test to ensure correct rendering and prop handling. (apps/customer-portal/webapp/src/components/common/error-state/__tests__/ErrorStateIcon.test.tsx)

Improvements to test coverage and mocking:

  • Updated ProjectHub tests to use new icon components, revised mock data, and improved mocking for UI elements and hooks to reflect the new UI logic. (apps/customer-portal/webapp/src/pages/__tests__/ProjectHub.test.tsx) [1] [2] [3] [4]

These changes collectively modernize the Project Hub's feedback for empty and error states, making the UI clearer and more visually consistent.

Summary by CodeRabbit

  • New Features

    • Improved error-state UI with clearer messaging and a full-page error illustration.
    • Added empty-state illustration and messaging when no projects are available.
    • Dynamic header and descriptive text that adapt to error, empty, or normal states.
  • Tests

    • Added/updated tests covering error, empty, and loading states, including icon rendering and prop passthrough.

Add a new Vitest test file for ErrorStateIcon verifying the component renders an SVG, has the expected viewBox and aria-hidden attributes, and correctly forwards SVG props (e.g. data-testid). Uses @testing-library/react for DOM assertions.
Add a mock for ErrorStateIcon and rename the test to 'should render error state when isError is true'. Replace previous assertions for tooltip/No Projects Yet with checks for the error-state-icon and specific error messages, while retaining the logger error assertion.
Introduce ErrorStateIcon.tsx — a React component that renders a detailed SVG illustration for full-page error states (used when data fails to load, e.g. Project Hub). The component accepts SVGProps<SVGSVGElement>, sets accessibility attributes (aria-hidden, focusable={false}), and includes the project license header. Adds the asset to apps/customer-portal/webapp/src/components/common/error-state.
Replace the previous error indicator with a centered ErrorStateIcon and enhanced error layout for the ProjectHub page. Add TriangleAlert (styled with error color) alongside FolderOpen as a conditional icon, update header and subtitle copy when an error occurs, and adjust spacing/padding for the error state. Also update imports to reflect ErrorStateIcon and TriangleAlert and remove the old ErrorIndicator import.
@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds two SVG React components (EmptyIcon, ErrorStateIcon), integrates them into ProjectHub for empty/error rendering, and updates tests and mocks to cover the new icons and loader behavior.

Changes

Cohort / File(s) Summary
New Icon Components
apps/customer-portal/webapp/src/components/common/empty-state/EmptyIcon.tsx, apps/customer-portal/webapp/src/components/common/error-state/ErrorStateIcon.tsx
Added two default-export React components that render static SVG illustrations; both accept and forward SVGProps<SVGSVGElement>.
Icon Tests
apps/customer-portal/webapp/src/components/common/empty-state/__tests__/EmptyIcon.test.tsx, apps/customer-portal/webapp/src/components/common/error-state/__tests__/ErrorStateIcon.test.tsx
New unit tests asserting SVG renders with expected viewBox, aria-hidden, and prop forwarding (data-testid).
ProjectHub Integration
apps/customer-portal/webapp/src/pages/ProjectHub.tsx
Replaced previous error indicator with ErrorStateIcon, added EmptyIcon for no-projects state, adjusted header/title/subtitle rendering and layout for error/empty/normal states.
ProjectHub Tests & Mocks
apps/customer-portal/webapp/src/pages/__tests__/ProjectHub.test.tsx
Updated tests: wrap with MemoryRouter, add mocks for EmptyIcon, ErrorStateIcon, TriangleAlert, update ProjectCard mock signature, add LoaderContext/useLoader mock, and extend assertions for loading/empty/error flows.

Sequence Diagram(s)

sequenceDiagram
    participant User as "User"
    participant ProjectHub as "ProjectHub\n(component)"
    participant Loader as "LoaderContext\n(useLoader)"
    participant API as "Projects API"
    participant EmptyIcon as "EmptyIcon\n(component)"
    participant ErrorIcon as "ErrorStateIcon\n(component)"
    Note over ProjectHub: UI load sequence
    User->>ProjectHub: navigate
    ProjectHub->>Loader: showLoader()
    ProjectHub->>API: fetchProjects()
    alt API returns error
        API-->>ProjectHub: error
        ProjectHub->>Loader: hideLoader()
        ProjectHub->>ErrorIcon: render ErrorStateIcon
        ProjectHub->>User: display error header & message
    else API returns empty list
        API-->>ProjectHub: []
        ProjectHub->>Loader: hideLoader()
        ProjectHub->>EmptyIcon: render EmptyIcon
        ProjectHub->>User: display "No Projects Yet" header & message
    else API returns projects
        API-->>ProjectHub: projects[]
        ProjectHub->>Loader: hideLoader()
        ProjectHub->>User: render project list and normal header
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • v15a1
  • shayanmalinda
  • Rashmika998

Poem

🐇
I hopped in with a cheerful spin,
drew bright icons for when projects thin,
when errors bloom or lists are bare,
I tuck a calm illustration there —
refresh, dear friend, and find your grin! 🎨✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description does not follow the required template structure and is missing several required sections. Complete the description by adding Purpose (with issue links), Goals, Approach, User Stories, Release Note, Documentation, Training, Certification, Marketing, Automation Tests (with coverage details), Security Checks, Samples, Related PRs, Migrations, Test Environment, and Learning sections.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly summarizes the main changes: introducing error and empty state components for the Project Hub and refactoring its test suite to support them.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@dileepapeiris dileepapeiris changed the title Feat/add error state [Customer Portal][FE][Web] Implement Error States for Project Hub Feb 11, 2026
@dileepapeiris dileepapeiris self-assigned this Feb 11, 2026
@dileepapeiris dileepapeiris added Type/Improvement Marks enhancements or improvements to existing features Type/UX Refers to user experience-related tasks or issues App/Customer Portal Area/Frontend Platform/Web labels Feb 11, 2026
@dileepapeiris dileepapeiris moved this from Todo to Done in Customer Portal Development Feb 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apps/customer-portal/webapp/src/components/common/error-state/ErrorStateIcon.tsx`:
- Around line 27-34: The SVG in ErrorStateIcon.tsx has mismatched intrinsic size
vs viewBox (width="268" height="229" vs viewBox="0 0 592 421") causing
letterboxing; update the <svg> in the ErrorStateIcon component to use
width/height that match the viewBox aspect ratio (e.g., scale to 592x421 or a
proportional pair) or adjust the viewBox to 268x229 so the intrinsic size and
viewBox align, and make the aria attributes consistent with EmptyIcon by using
aria-hidden="true" and focusable="false" instead of the mixed boolean forms.
🧹 Nitpick comments (5)
apps/customer-portal/webapp/src/components/common/empty-state/EmptyIcon.tsx (1)

136-213: Static gradient IDs will clash if multiple EmptyIcon instances coexist in the DOM.

IDs like paint0_linear_1857_52 are global to the document. If two EmptyIcon components render simultaneously, the second instance's <path fill="url(#paint0_linear_1857_52)"> will resolve to the first instance's gradient definition, which may produce incorrect rendering (especially if one is hidden or removed).

This is unlikely given the current single-use in ProjectHub, but worth noting for future reuse. A common fix is to use React.useId() to namespace the IDs.

apps/customer-portal/webapp/src/components/common/error-state/__tests__/ErrorStateIcon.test.tsx (1)

21-35: Tests look good — consider adding a matching test file for EmptyIcon.

The two tests adequately cover SVG rendering and prop forwarding. However, there's no corresponding EmptyIcon.test.tsx in this PR. For consistency, consider adding analogous tests for the EmptyIcon component.

apps/customer-portal/webapp/src/pages/ProjectHub.tsx (1)

116-148: Duplicated container sx between error and empty states — consider extracting.

The Box wrappers at lines 118–127 and 135–144 share identical sx props (display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 2, py: 10). A small constant or shared wrapper would reduce duplication.

♻️ Example extraction
+ const centeredContainerSx = {
+   display: "flex",
+   flexDirection: "column",
+   alignItems: "center",
+   justifyContent: "center",
+   gap: 2,
+   py: 10,
+ } as const;
+
  // ... then in renderContent:
  if (isError) {
    return (
-     <Box
-       sx={{
-         display: "flex",
-         flexDirection: "column",
-         alignItems: "center",
-         justifyContent: "center",
-         gap: 2,
-         py: 10,
-       }}
-     >
+     <Box sx={centeredContainerSx}>
        <ErrorStateIcon />
      </Box>
    );
  }

  if (projects.length === 0) {
    return (
-     <Box
-       sx={{
-         display: "flex",
-         flexDirection: "column",
-         alignItems: "center",
-         justifyContent: "center",
-         gap: 2,
-         py: 10,
-       }}
-     >
+     <Box sx={centeredContainerSx}>
        <EmptyIcon />
      </Box>
    );
  }
apps/customer-portal/webapp/src/pages/__tests__/ProjectHub.test.tsx (2)

197-222: Error state test is thorough — optionally verify the TriangleAlert icon is rendered.

The test checks for error-state-icon, error title, and error subtitle — good coverage. You could additionally assert screen.getByTestId("triangle-alert-icon") to verify the header icon switches to the alert icon in error state.


125-141: Good test setup — consider adding a test for single-project auto-navigation.

ProjectHub navigates to /${projects[0].id}/dashboard when exactly one project is returned (line 60-62 of ProjectHub.tsx). This behavior isn't covered by any test case. A test with a single project in mockUseGetProjects could verify this redirect.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request modernizes the error and empty state handling in the Project Hub page by introducing dedicated icon components (EmptyIcon and ErrorStateIcon) to replace basic text messages and the legacy ErrorIndicator component. The changes improve visual consistency and user experience with more descriptive messaging and better-structured UI layouts.

Changes:

  • Added new ErrorStateIcon component with unit tests for displaying full-page error states
  • Added new EmptyIcon component for displaying empty state visuals
  • Updated ProjectHub component to use the new icon components with improved conditional rendering and enhanced error/empty state messages

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
apps/customer-portal/webapp/src/components/common/error-state/ErrorStateIcon.tsx New SVG icon component for error states with documentation
apps/customer-portal/webapp/src/components/common/error-state/__tests__/ErrorStateIcon.test.tsx Unit tests for ErrorStateIcon component
apps/customer-portal/webapp/src/components/common/empty-state/EmptyIcon.tsx New SVG icon component for empty states with documentation
apps/customer-portal/webapp/src/pages/ProjectHub.tsx Updated error/empty state rendering logic with new icon components and improved messaging; removed ErrorIndicator dependency
apps/customer-portal/webapp/src/pages/__tests__/ProjectHub.test.tsx Updated test mocks and assertions to reflect new UI components and messaging

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/customer-portal/webapp/src/components/common/error-state/ErrorStateIcon.tsx Outdated
Comment thread apps/customer-portal/webapp/src/pages/ProjectHub.tsx
Update ErrorStateIcon: change SVG height from 229 to 191 to match layout/design, and normalize accessibility attributes by setting aria-hidden="true" and focusable="false" (instead of bare booleans). Other props are still forwarded to the SVG.
Update ErrorStateIcon.test to assert that the SVG's aria-hidden attribute has an explicit empty-string value (expect(svg).toHaveAttribute("aria-hidden", "")). This makes the test verify the exact attribute value rather than only its presence, preventing false positives and ensuring the component renders the expected accessibility attribute.
Change EmptyIcon's focusable attribute from the string "false" to the boolean false to match JSX/SVG prop typing. Add unit tests for EmptyIcon to verify the SVG renders, has the expected viewBox and aria-hidden attributes, and passes through arbitrary SVG props (data-testid).
Change ErrorStateIcon focusable prop to a boolean (focusable={false}) to match SVG/TypeScript expectations and ensure correct DOM rendering. Update the test to expect aria-hidden="true" on the rendered SVG element. Adjustments keep component attributes consistent and tests accurate.
Replace conditional title strings and icon logic in ProjectHub with explicit Typography blocks for error, empty and normal states. Removed the TriangleAlert import and always use FolderOpen for the header; added distinct h4 and subtitle2 texts for the error and empty states and simplified the header rendering/spacing logic. This clarifies the UI structure and consolidates subtitle content for the normal project selection view.
@dileepapeiris dileepapeiris changed the title [Customer Portal][FE][Web] Implement Error States for Project Hub [Customer Portal][FE][Web] Implement Error States for Project Hub and Refactor Test Suite Feb 11, 2026
@Rashmika998
Rashmika998 merged commit e83e1cb into wso2-open-operations:customer-portal-milestone-1 Feb 12, 2026
1 check passed
@dileepapeiris dileepapeiris moved this from Done to Staging Deployed in Customer Portal Development Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/Customer Portal Area/Frontend Platform/Web Type/Improvement Marks enhancements or improvements to existing features Type/UX Refers to user experience-related tasks or issues

Projects

Status: Staging Deployed

Development

Successfully merging this pull request may close these issues.

3 participants