Repository navigation
[Customer Portal][FE][Web] Implement Change Request Card on Support Page #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Rashmika998
merged 9 commits into
wso2-open-operations:customer-portal-milestone-1
from
dileepapeiris:feat/add-change-requests-card
Feb 10, 2026
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
382bf71
Add ChangeRequestCard component
dileepapeiris d2d9524
Add ChangeRequestCard unit tests
dileepapeiris 008a61b
Add RequestCard component unit tests
dileepapeiris 8bb2f93
Enhance SupportPage tests with additional mocks
dileepapeiris af86a51
Use theme grey as fallback for palette colors
dileepapeiris d604176
Use RequestCard import and add listStyle
dileepapeiris 1687f6d
Adjust RequestCard layout and fix tests/constants
dileepapeiris c4ce9a3
Mock @wso2/oxygen-ui in RequestCard tests
dileepapeiris 9aba9b0
Merge branch 'customer-portal-milestone-1' into feat/add-change-reque…
dileepapeiris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
apps/customer-portal/webapp/src/components/support/request-cards/ChangeRequestCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { useNavigate } from "react-router"; | ||
| import type { JSX } from "react"; | ||
| import { colors } from "@wso2/oxygen-ui"; | ||
| import { CalendarDays } from "@wso2/oxygen-ui-icons-react"; | ||
| import RequestCard from "@components/support/request-cards/RequestCard"; | ||
| import { CHANGE_REQUEST_BULLET_ITEMS } from "@constants/supportConstants"; | ||
|
|
||
| /** | ||
| * Change Requests card for the Support page. | ||
| * Renders overview and CTA for change request management. | ||
| * | ||
| * @returns {JSX.Element} The Change Request card. | ||
| */ | ||
| export default function ChangeRequestCard(): JSX.Element { | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <RequestCard | ||
| title="Change Requests" | ||
| subtitle="Track infrastructure changes" | ||
| icon={CalendarDays} | ||
| paletteKey="secondary" | ||
| accentColor={colors.purple[600]} | ||
| infoBoxTitle="What are Change Requests?" | ||
| infoBoxDescription="Structured workflow for planned infrastructure changes:" | ||
| bulletItems={CHANGE_REQUEST_BULLET_ITEMS} | ||
| secondaryButtonLabel="View All Change Requests" | ||
| onSecondaryClick={() => navigate("../dashboard")} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...r-portal/webapp/src/components/support/request-cards/__tests__/ChangeRequestCard.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { render, screen } from "@testing-library/react"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { MemoryRouter } from "react-router"; | ||
| import ChangeRequestCard from "@components/support/request-cards/ChangeRequestCard"; | ||
| import { CHANGE_REQUEST_BULLET_ITEMS } from "@constants/supportConstants"; | ||
|
|
||
| // Mock the child component to isolate the test | ||
| vi.mock("@components/support/request-cards/RequestCard", () => ({ | ||
| default: ({ | ||
| title, | ||
| subtitle, | ||
| bulletItems, | ||
| }: { | ||
| title: string; | ||
| subtitle: string; | ||
| bulletItems: string[]; | ||
| }) => ( | ||
| <div data-testid="mock-request-card"> | ||
| <span data-testid="card-title">{title}</span> | ||
| <span data-testid="card-subtitle">{subtitle}</span> | ||
| <ul> | ||
| {bulletItems.map((item) => ( | ||
| <li key={item} data-testid="card-item"> | ||
| {item} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ), | ||
| })); | ||
|
|
||
| describe("ChangeRequestCard", () => { | ||
| it("should render with correct props", () => { | ||
| render( | ||
| <MemoryRouter> | ||
| <ChangeRequestCard /> | ||
| </MemoryRouter>, | ||
| ); | ||
|
|
||
| expect(screen.getByTestId("mock-request-card")).toBeInTheDocument(); | ||
| expect(screen.getByTestId("card-title")).toHaveTextContent( | ||
| "Change Requests", | ||
| ); | ||
| expect(screen.getByTestId("card-subtitle")).toHaveTextContent( | ||
| "Track infrastructure changes", | ||
| ); | ||
|
|
||
| const items = screen.getAllByTestId("card-item"); | ||
| expect(items).toHaveLength(CHANGE_REQUEST_BULLET_ITEMS.length); | ||
| expect(items[0]).toHaveTextContent(CHANGE_REQUEST_BULLET_ITEMS[0]); | ||
| }); | ||
| }); |
124 changes: 124 additions & 0 deletions
124
...ustomer-portal/webapp/src/components/support/request-cards/__tests__/RequestCard.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { render, screen, fireEvent } from "@testing-library/react"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import RequestCard from "@components/support/request-cards/RequestCard"; | ||
|
|
||
| const MockIcon = () => <span data-testid="mock-icon">Icon</span>; | ||
|
|
||
| describe("RequestCard", () => { | ||
| it("should render title, subtitle, info box and buttons", () => { | ||
| render( | ||
| <RequestCard | ||
| title="Test Card" | ||
| subtitle="Test subtitle" | ||
| icon={MockIcon} | ||
| paletteKey="info" | ||
| accentColor="#1976D2" | ||
| infoBoxTitle="What is this?" | ||
| infoBoxDescription="A test description." | ||
| bulletItems={["Item one", "Item two"]} | ||
| secondaryButtonLabel="View All" | ||
| onSecondaryClick={vi.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByText("Test Card")).toBeInTheDocument(); | ||
| expect(screen.getByText("Test subtitle")).toBeInTheDocument(); | ||
| expect(screen.getByText("What is this?")).toBeInTheDocument(); | ||
| expect(screen.getByText("A test description.")).toBeInTheDocument(); | ||
| expect(screen.getByText("Item one")).toBeInTheDocument(); | ||
| expect(screen.getByText("Item two")).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByRole("button", { name: /view all/i }), | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByTestId("mock-icon")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should render primary button when provided", () => { | ||
| render( | ||
| <RequestCard | ||
| title="Test" | ||
| subtitle="Sub" | ||
| icon={MockIcon} | ||
| paletteKey="info" | ||
| accentColor="#1976D2" | ||
| infoBoxTitle="Title" | ||
| infoBoxDescription="Desc" | ||
| bulletItems={[]} | ||
| secondaryButtonLabel="Secondary" | ||
| onSecondaryClick={vi.fn()} | ||
| primaryButton={{ | ||
| label: "Create New", | ||
| onClick: vi.fn(), | ||
| icon: MockIcon, | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByRole("button", { name: /create new/i }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should call onSecondaryClick when secondary button is clicked", () => { | ||
| const onSecondaryClick = vi.fn(); | ||
| render( | ||
| <RequestCard | ||
| title="Test" | ||
| subtitle="Sub" | ||
| icon={MockIcon} | ||
| paletteKey="info" | ||
| accentColor="#1976D2" | ||
| infoBoxTitle="Title" | ||
| infoBoxDescription="Desc" | ||
| bulletItems={[]} | ||
| secondaryButtonLabel="View All" | ||
| onSecondaryClick={onSecondaryClick} | ||
| />, | ||
| ); | ||
|
|
||
| fireEvent.click(screen.getByRole("button", { name: /view all/i })); | ||
| expect(onSecondaryClick).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it("should call primaryButton.onClick when primary button is clicked", () => { | ||
| const onPrimaryClick = vi.fn(); | ||
| render( | ||
| <RequestCard | ||
| title="Test" | ||
| subtitle="Sub" | ||
| icon={MockIcon} | ||
| paletteKey="info" | ||
| accentColor="#1976D2" | ||
| infoBoxTitle="Title" | ||
| infoBoxDescription="Desc" | ||
| bulletItems={[]} | ||
| secondaryButtonLabel="Secondary" | ||
| onSecondaryClick={vi.fn()} | ||
| primaryButton={{ | ||
| label: "Create", | ||
| onClick: onPrimaryClick, | ||
| icon: MockIcon, | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| fireEvent.click(screen.getByRole("button", { name: /create/i })); | ||
| expect(onPrimaryClick).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.