-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: group & proposal theme and layout #41
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request involves the deletion of the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
==========================================
- Coverage 59.07% 58.92% -0.15%
==========================================
Files 148 147 -1
Lines 13860 13824 -36
==========================================
- Hits 8188 8146 -42
- Misses 5672 5678 +6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (14)
components/groups/components/__tests__/groupProposals.test.tsx (1)
Line range hint
1-142
: Consider adding theme-related test coverage.Since this PR focuses on theming improvements, consider adding test cases to verify:
- Component rendering in both dark and light modes
- Proper application of theme colors
- Hover state styling for interactive elements
Example test case:
test('applies correct theme styles', () => { const { rerender } = renderWithChainProvider( <ProposalsForPolicy {...mockProps} />, { theme: 'light' } ); // Verify light theme styles const element = screen.getByTestId('proposals-container'); expect(element).toHaveClass('bg-light-theme'); // Verify dark theme styles rerender( <ProposalsForPolicy {...mockProps} />, { theme: 'dark' } ); expect(element).toHaveClass('bg-dark-theme'); });tailwind.config.js (2)
117-118
: Review tooltip color consistency across themes.The tooltip color is set to white (
#ffffff
) in both themes, which might not be optimal for the light theme. Consider using theme-specific colors for better visibility.light: { // ... - 'tooltip-color': '#ffffff', + 'tooltip-color': '#161616', // ... }
96-99
: Consider theme-specific status colors.The status colors (info, success, warning, error) are identical in both themes. While this maintains consistency, consider adjusting their brightness or saturation for better visibility in dark mode.
For dark theme, consider slightly brighter variants:
dark: { // ... - info: '#3F51B5', - success: '#4CAF50', - warning: '#FFB300', - error: '#E53935', + info: '#5C6BC0', + success: '#66BB6A', + warning: '#FFCA28', + error: '#EF5350', }Also applies to: 119-122
components/groups/components/myGroups.tsx (3)
Line range hint
86-95
: Consider using Tailwind classes for font stylesInstead of using inline styles for font properties, consider using Tailwind's utility classes for better maintainability and consistency.
- style={{ fontSize: '20px', fontWeight: 700, lineHeight: '24px' }} + className="text-secondary-content text-xl font-bold leading-6"
124-152
: Add tests for skeleton loading UIThe skeleton loading UI is not covered by tests. Consider adding tests to verify proper rendering of the loading state.
Would you like me to help generate test cases for the skeleton loading UI? Here's what we should test:
- Verify skeleton renders when isLoading is true
- Verify correct number of skeleton rows (12)
- Verify skeleton doesn't render when isLoading is false
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 126-150: components/groups/components/myGroups.tsx#L126-L150
Added lines #L126 - L150 were not covered by tests
Line range hint
227-269
: Improve accessibility for clickable rowsWhile the styling is consistent, consider these accessibility improvements:
- Add role="button" to the row
- Add keyboard navigation support
- Add aria-label for better screen reader support
<tr - className="group text-black dark:text-white rounded-lg cursor-pointer transition-colors" + className="group text-black dark:text-white rounded-lg cursor-pointer transition-colors focus:outline-none focus:ring-2 focus:ring-primary" + role="button" + tabIndex={0} + aria-label={`Select group ${groupName}`} onClick={e => { e.stopPropagation(); onSelectGroup(policyAddress, groupName, ...); }} + onKeyDown={e => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + onSelectGroup(policyAddress, groupName, ...); + } + }} >components/groups/components/groupProposals.tsx (3)
Line range hint
244-268
: Add ARIA labels for better accessibilityThe header buttons lack proper accessibility attributes which could make navigation difficult for screen reader users.
Apply these changes to improve accessibility:
- <button onClick={onBack} className="btn btn-circle rounded-[16px] bg-secondary btn-md"> + <button + onClick={onBack} + className="btn btn-circle rounded-[16px] bg-secondary btn-md" + aria-label="Go back" + > <ArrowRightIcon className="text-primary" /> </button> <button className="btn w-[140px] h-[52px] rounded-[12px] focus:outline-none dark:bg-[#FFFFFF0F] bg-[#0000000A]" onClick={openInfoModal} + aria-label="Open group information" > Info </button> <button className="btn w-[140px] h-[52px] rounded-[12px] focus:outline-none dark:bg-[#FFFFFF0F] bg-[#0000000A]" onClick={openMemberModal} + aria-label="Open member management" > Members </button>
269-287
: Enhance search input with debouncingThe search functionality directly updates on every keystroke, which could cause performance issues with large datasets.
Consider implementing debouncing:
+import { useCallback } from 'react'; +import debounce from 'lodash/debounce'; const [searchTerm, setSearchTerm] = useState(''); +const debouncedSearch = useCallback( + debounce((value: string) => { + setSearchTerm(value); + }, 300), + [] +); <input type="text" placeholder="Search for a proposal..." className="input input-bordered w-[224px] h-[40px] rounded-[12px] border-none bg-secondary text-secondary-content pl-10" - value={searchTerm} - onChange={e => setSearchTerm(e.target.value)} + defaultValue={searchTerm} + onChange={e => debouncedSearch(e.target.value)} + aria-label="Search proposals" />
Line range hint
357-388
: Improve table accessibility and keyboard navigationThe table rows are clickable but lack proper keyboard navigation support and ARIA attributes.
Apply these changes to improve accessibility:
<tr key={proposal.id.toString()} onClick={() => handleRowClick(proposal)} - className="group text-black dark:text-white rounded-lg cursor-pointer" + className="group text-black dark:text-white rounded-lg cursor-pointer focus-within:ring-2 focus-within:ring-primary" + role="button" + tabIndex={0} + onKeyPress={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + handleRowClick(proposal); + } + }} + aria-label={`Proposal ${proposal.id}: ${proposal.title}`} >Also, consider adding a
role="status"
to the loading spinner and empty state message for better screen reader support.components/groups/modals/voteDetailsModal.tsx (5)
69-69
: Theme colors should be defined in the theme configurationThe hardcoded color values (
#FFFFFF
,#161616
) and chart colors should be moved to the theme configuration for better maintainability and consistency.Consider moving these values to your theme configuration:
- const textColor = theme === 'dark' ? '#FFFFFF' : '#161616'; + const textColor = theme === 'dark' ? colors.dark.text : colors.light.text; - colors: ['#4CAF50', '#E53935', '#FFB300', '#3F51B5'], + colors: theme === 'dark' + ? colors.dark.chart + : colors.light.chart,Also applies to: 188-188
515-516
: Improve table accessibility and responsivenessThe table implementation could be enhanced for better accessibility and mobile responsiveness.
- Add
role="table"
for better screen reader support- Consider using CSS Grid for better mobile layout
- Add proper ARIA labels for the table cells
- <div className="bg-base-300 rounded-[12px] p-4 w-full"> - <div className="overflow-x-auto w-full min-h-64 max-h-[22.5rem] overflow-y-auto"> - <table className="table-auto w-full text-sm"> + <div className="bg-base-300 rounded-[12px] p-4 w-full"> + <div className="overflow-x-auto w-full min-h-64 max-h-[22.5rem] overflow-y-auto"> + <table role="table" className="table-auto w-full text-sm" aria-label="Group Members">Also applies to: 541-541, 545-547
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 515-516: components/groups/modals/voteDetailsModal.tsx#L515-L516
Added lines #L515 - L516 were not covered by tests
509-511
: Consider adding loading states for the chartThe chart rendering doesn't handle loading states, which could lead to a poor user experience during data fetching.
+ const [isChartLoading, setIsChartLoading] = useState(true); <div className="bg-base-300 rounded-[12px] w-full"> + {isChartLoading && <div className="loading loading-lg" />} <Chart options={options} series={[{ data: chartData }]} type="bar" height={200} /> </div>🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 509-509: components/groups/modals/voteDetailsModal.tsx#L509
Added line #L509 was not covered by tests
518-532
: Improve table header accessibilityThe table headers could be enhanced for better accessibility and semantic meaning.
- <thead className="text-xs uppercase bg-neutral"> + <thead className="text-xs uppercase bg-neutral" role="rowgroup"> <tr> <th scope="col" + role="columnheader" + aria-sort="none" className="px-6 py-3 first:rounded-tl-[12px] text-primary-content" > Address </th>🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 518-518: components/groups/modals/voteDetailsModal.tsx#L518
Added line #L518 was not covered by tests
[warning] 520-522: components/groups/modals/voteDetailsModal.tsx#L520-L522
Added lines #L520 - L522 were not covered by tests
[warning] 526-526: components/groups/modals/voteDetailsModal.tsx#L526
Added line #L526 was not covered by tests
[warning] 529-531: components/groups/modals/voteDetailsModal.tsx#L529-L531
Added lines #L529 - L531 were not covered by tests
133-135
: Chart legend markers configuration could be simplifiedThe current chart legend marker configuration can be simplified using the theme's color palette.
- markers: { - strokeWidth: 0, - }, + markers: { + strokeWidth: 0, + fillColors: theme === 'dark' ? colors.dark.chart : colors.light.chart, + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (9)
components/admins/components/__tests__/adminOptions.test.tsx
(0 hunks)components/admins/components/adminOptions.tsx
(0 hunks)components/admins/components/index.tsx
(0 hunks)components/groups/components/CountdownTimer.tsx
(1 hunks)components/groups/components/__tests__/groupProposals.test.tsx
(1 hunks)components/groups/components/groupProposals.tsx
(4 hunks)components/groups/components/myGroups.tsx
(5 hunks)components/groups/modals/voteDetailsModal.tsx
(10 hunks)tailwind.config.js
(1 hunks)
💤 Files with no reviewable changes (3)
- components/admins/components/tests/adminOptions.test.tsx
- components/admins/components/adminOptions.tsx
- components/admins/components/index.tsx
✅ Files skipped from review due to trivial changes (1)
- components/groups/components/CountdownTimer.tsx
🧰 Additional context used
🪛 GitHub Check: codecov/patch
components/groups/components/myGroups.tsx
[warning] 126-150: components/groups/components/myGroups.tsx#L126-L150
Added lines #L126 - L150 were not covered by tests
components/groups/modals/voteDetailsModal.tsx
[warning] 355-355: components/groups/modals/voteDetailsModal.tsx#L355
Added line #L355 was not covered by tests
[warning] 357-357: components/groups/modals/voteDetailsModal.tsx#L357
Added line #L357 was not covered by tests
[warning] 366-366: components/groups/modals/voteDetailsModal.tsx#L366
Added line #L366 was not covered by tests
[warning] 376-376: components/groups/modals/voteDetailsModal.tsx#L376
Added line #L376 was not covered by tests
[warning] 380-382: components/groups/modals/voteDetailsModal.tsx#L380-L382
Added lines #L380 - L382 were not covered by tests
[warning] 461-463: components/groups/modals/voteDetailsModal.tsx#L461-L463
Added lines #L461 - L463 were not covered by tests
[warning] 467-467: components/groups/modals/voteDetailsModal.tsx#L467
Added line #L467 was not covered by tests
[warning] 474-475: components/groups/modals/voteDetailsModal.tsx#L474-L475
Added lines #L474 - L475 were not covered by tests
[warning] 479-480: components/groups/modals/voteDetailsModal.tsx#L479-L480
Added lines #L479 - L480 were not covered by tests
[warning] 487-487: components/groups/modals/voteDetailsModal.tsx#L487
Added line #L487 was not covered by tests
[warning] 509-509: components/groups/modals/voteDetailsModal.tsx#L509
Added line #L509 was not covered by tests
[warning] 515-516: components/groups/modals/voteDetailsModal.tsx#L515-L516
Added lines #L515 - L516 were not covered by tests
[warning] 518-518: components/groups/modals/voteDetailsModal.tsx#L518
Added line #L518 was not covered by tests
[warning] 520-522: components/groups/modals/voteDetailsModal.tsx#L520-L522
Added lines #L520 - L522 were not covered by tests
[warning] 526-526: components/groups/modals/voteDetailsModal.tsx#L526
Added line #L526 was not covered by tests
[warning] 529-531: components/groups/modals/voteDetailsModal.tsx#L529-L531
Added lines #L529 - L531 were not covered by tests
🔇 Additional comments (4)
components/groups/components/__tests__/groupProposals.test.tsx (1)
111-111
: LGTM! Text update matches UI changes.
The updated assertion correctly reflects the new message displayed when no proposals are found.
tailwind.config.js (2)
81-122
: Theme configuration looks good overall!
The updated color scheme provides a consistent visual hierarchy and maintains the purple-based theme identity across both light and dark modes. The changes align well with the PR objectives of fixing theme-related issues.
81-83
: Consider accessibility implications of the primary color.
The primary color #A087FF
might not provide sufficient contrast against white backgrounds for smaller text elements. Consider using a darker shade for better accessibility or ensuring it's not used for critical text elements.
components/groups/modals/voteDetailsModal.tsx (1)
Line range hint 355-382
: Add test coverage for new UI elements
Several new UI elements and text formatting changes lack test coverage. This includes message rendering, title display, and various text elements.
Would you like me to help create test cases for these new UI elements? I can generate comprehensive tests that cover:
- Theme-based text color rendering
- Message field formatting
- Modal layout responsiveness
Also applies to: 461-463, 467-467, 474-475, 479-480, 487-487
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 376-376: components/groups/modals/voteDetailsModal.tsx#L376
Added line #L376 was not covered by tests
[warning] 380-382: components/groups/modals/voteDetailsModal.tsx#L380-L382
Added lines #L380 - L382 were not covered by tests
@@ -416,21 +421,23 @@ | |||
|
|||
return ( | |||
<dialog id={modalId} className="modal"> | |||
<div className="modal-box relative max-w-4xl min-h-96 flex flex-col md:flex-row md:ml-20 -mt-12 rounded-[24px] shadow-lg dark:bg-[#1D192D] bg-[#FFFFFF] transition-all duration-300 z-[1000]"> | |||
<div className="modal-box relative max-w-4xl min-h-96 max-h-[80vh] overflow-y-hidden flex flex-col md:flex-row md:ml-20 -mt-12 rounded-[24px] shadow-lg bg-secondary transition-all duration-300 z-[1000]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve modal positioning and layout
The modal's positioning uses negative margin (-mt-12
) which is a fragile solution. Consider using proper positioning techniques.
- <div className="modal-box relative max-w-4xl min-h-96 max-h-[80vh] overflow-y-hidden flex flex-col md:flex-row md:ml-20 -mt-12 rounded-[24px] shadow-lg bg-secondary transition-all duration-300 z-[1000]">
+ <div className="modal-box relative max-w-4xl min-h-96 max-h-[80vh] overflow-y-hidden flex flex-col md:flex-row rounded-[24px] shadow-lg bg-secondary transition-all duration-300">
Also applies to: 424-424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
components/groups/modals/voteDetailsModal.tsx (1)
Based on the initial search results, I can generate the final response since we found enough context showing:
- The existence of
ProposalMessages.test.tsx
with commented-out message-related tests- The
renderMessageField
function implementation invoteDetailsModal.tsx
- No existing test file for
voteDetailsModal.tsx
Add test coverage for message field rendering
The
renderMessageField
function handles complex rendering logic for different types of message fields (arrays, objects, strings) but lacks test coverage. Consider:
- Creating a new test file
voteDetailsModal.test.tsx
- Adding test cases for:
- Array type message fields
- Object type message fields
- String fields with address-like content
- Regular string fields with truncation
🔗 Analysis chain
Line range hint
355-382
: Add test coverage for message renderingThe
renderMessageField
function and its text styling changes lack test coverage. Consider adding unit tests for different message types and their rendering outcomes.
Let me gather more information about the test coverage and related components.
Let me try one more search with corrected file type flags:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Find existing test files for this component fd "voteDetailsModal.test" --type f # Check for any existing message rendering tests rg -A 5 "renderMessageField|test\(.*message"Length of output: 9395
Script:
#!/bin/bash # Look for test files related to vote details or message rendering fd "test.(tsx|ts)" --type f | rg -i "vote|message" # Check for any existing test setup or utilities for modal testing rg -A 5 "render.*Modal|Modal.*test" --type ts --type tsx # Look for any existing snapshot tests rg "toMatchSnapshot|snapshot" --type ts --type tsxLength of output: 290
Script:
#!/bin/bash # Look for modal test patterns and snapshots rg -t typescript -t typescriptreact -A 5 "render.*Modal|Modal.*test" # Check for any existing test utilities or helpers fd "test-utils|testing" --type f # Look for similar components with tests rg -t typescript -t typescriptreact "describe.*Modal.*|test.*Modal.*" -A 5Length of output: 252
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 376-376: components/groups/modals/voteDetailsModal.tsx#L376
Added line #L376 was not covered by tests
[warning] 380-382: components/groups/modals/voteDetailsModal.tsx#L380-L382
Added lines #L380 - L382 were not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
components/groups/modals/voteDetailsModal.tsx
(10 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
components/groups/modals/voteDetailsModal.tsx
[warning] 355-355: components/groups/modals/voteDetailsModal.tsx#L355
Added line #L355 was not covered by tests
[warning] 357-357: components/groups/modals/voteDetailsModal.tsx#L357
Added line #L357 was not covered by tests
[warning] 366-366: components/groups/modals/voteDetailsModal.tsx#L366
Added line #L366 was not covered by tests
[warning] 376-376: components/groups/modals/voteDetailsModal.tsx#L376
Added line #L376 was not covered by tests
[warning] 380-382: components/groups/modals/voteDetailsModal.tsx#L380-L382
Added lines #L380 - L382 were not covered by tests
[warning] 463-465: components/groups/modals/voteDetailsModal.tsx#L463-L465
Added lines #L463 - L465 were not covered by tests
[warning] 469-469: components/groups/modals/voteDetailsModal.tsx#L469
Added line #L469 was not covered by tests
[warning] 476-477: components/groups/modals/voteDetailsModal.tsx#L476-L477
Added lines #L476 - L477 were not covered by tests
[warning] 481-482: components/groups/modals/voteDetailsModal.tsx#L481-L482
Added lines #L481 - L482 were not covered by tests
[warning] 489-489: components/groups/modals/voteDetailsModal.tsx#L489
Added line #L489 was not covered by tests
[warning] 511-511: components/groups/modals/voteDetailsModal.tsx#L511
Added line #L511 was not covered by tests
[warning] 517-518: components/groups/modals/voteDetailsModal.tsx#L517-L518
Added lines #L517 - L518 were not covered by tests
[warning] 520-520: components/groups/modals/voteDetailsModal.tsx#L520
Added line #L520 was not covered by tests
[warning] 522-524: components/groups/modals/voteDetailsModal.tsx#L522-L524
Added lines #L522 - L524 were not covered by tests
[warning] 528-528: components/groups/modals/voteDetailsModal.tsx#L528
Added line #L528 was not covered by tests
[warning] 531-533: components/groups/modals/voteDetailsModal.tsx#L531-L533
Added lines #L531 - L533 were not covered by tests
🔇 Additional comments (2)
components/groups/modals/voteDetailsModal.tsx (2)
424-428
: Previous review comment about modal positioning is still applicable
520-534
: LGTM: Table styling follows theme guidelines
The table header styling properly uses theme-aware classes for text colors and maintains consistency.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 520-520: components/groups/modals/voteDetailsModal.tsx#L520
Added line #L520 was not covered by tests
[warning] 522-524: components/groups/modals/voteDetailsModal.tsx#L522-L524
Added lines #L522 - L524 were not covered by tests
[warning] 528-528: components/groups/modals/voteDetailsModal.tsx#L528
Added line #L528 was not covered by tests
[warning] 531-533: components/groups/modals/voteDetailsModal.tsx#L531-L533
Added lines #L531 - L533 were not covered by tests
@@ -66,7 +66,7 @@ | |||
|
|||
const { theme } = useTheme(); | |||
|
|||
const textColor = theme === 'dark' ? '#E0D1D4' : '#2e2e2e'; | |||
const textColor = theme === 'dark' ? '#FFFFFF' : '#161616'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use theme variables instead of hardcoded colors
The hardcoded colors bypass the theme system. Consider using Tailwind's theme variables for better maintainability and consistency.
- const textColor = theme === 'dark' ? '#FFFFFF' : '#161616';
+ const textColor = theme === 'dark' ? 'rgb(var(--color-neutral-content))' : 'rgb(var(--color-base-content))';
// ...
- colors: ['#4CAF50', '#E53935', '#FFB300', '#3F51B5'],
+ colors: ['rgb(var(--color-success))', 'rgb(var(--color-error))', 'rgb(var(--color-warning))', 'rgb(var(--color-info))'],
Also applies to: 188-188
<h1 className="text-2xl font-bold max-w-[20ch] truncate text-primary-content"> | ||
{proposal?.title} | ||
</h1> | ||
<span className="text-sm font-light text-gray-500 dark:text-gray-400 mt-2"> | ||
SUBMITTED | ||
</span> | ||
<span className="text-sm"> | ||
<span className="text-sm text-primary-content"> | ||
{new Date(proposal?.submit_time).toDateString().toLocaleString()} | ||
</span> | ||
</div> | ||
<div className="divider my-"></div> | ||
<div className="w-full"> | ||
<p className="text-sm font-light text-gray-500 dark:text-gray-400 mb-2 ">SUMMARY</p> | ||
<div className="dark:bg-[#FFFFFF0F] bg-[#0000000A] rounded-[12px] p-4"> | ||
<p className="text-sm">{proposal?.summary}</p> | ||
<div className="bg-base-300 rounded-[12px] p-4"> | ||
<p className="text-sm text-primary-content">{proposal?.summary}</p> | ||
</div> | ||
</div> | ||
<div className="w-full"> | ||
<p className="text-sm font-light text-gray-500 dark:text-gray-400 mb-2 ">MESSAGES</p> | ||
<div className="dark:bg-[#FFFFFF0F] bg-[#0000000A] rounded-[12px] p-4 overflow-y-auto max-h-[20rem]"> | ||
<p className="text-sm font-light text-gray-500 dark:text-gray-400 mb-2">MESSAGES</p> | ||
<div className="bg-base-300 rounded-[12px] p-4 overflow-y-auto max-h-[20rem]"> | ||
{proposal?.messages?.map((message: any, index: number) => { | ||
const messageType = message['@type']; | ||
const fieldsToShow = importantFields[messageType] || defaultFields; | ||
|
||
return ( | ||
<div key={index} className="mb-4"> | ||
<h3 className="text-lg font-semibold mb-2"> | ||
<h3 className="text-lg font-semibold mb-2 text-primary-content"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Implement comprehensive UI test coverage
Multiple UI elements lack test coverage. Consider implementing:
- Snapshot tests for theme variations
- Unit tests for conditional rendering
- Integration tests for user interactions
This will help ensure theme and layout changes don't introduce regressions.
Would you like me to help create a test suite template that covers these scenarios?
Also applies to: 511-534
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 463-465: components/groups/modals/voteDetailsModal.tsx#L463-L465
Added lines #L463 - L465 were not covered by tests
[warning] 469-469: components/groups/modals/voteDetailsModal.tsx#L469
Added line #L469 was not covered by tests
[warning] 476-477: components/groups/modals/voteDetailsModal.tsx#L476-L477
Added lines #L476 - L477 were not covered by tests
[warning] 481-482: components/groups/modals/voteDetailsModal.tsx#L481-L482
Added lines #L481 - L482 were not covered by tests
[warning] 489-489: components/groups/modals/voteDetailsModal.tsx#L489
Added line #L489 was not covered by tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, write some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmorency, sure! Here's a test suite for the VoteDetailsModal
component that covers snapshot tests for theme variations, unit tests for conditional rendering, and placeholders for integration tests of user interactions:
// File: components/groups/modals/__tests__/voteDetailsModal.test.tsx
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import VoteDetailsModal from '../voteDetailsModal';
import { ChainProvider } from '@/contexts/chain';
import { ProposalSDKType, MemberSDKType, VoteSDKType } from '@liftedinit/manifestjs/dist/codegen/cosmos/group/v1/types';
import { QueryTallyResultResponseSDKType } from '@liftedinit/manifestjs/dist/codegen/cosmos/group/v1/query';
describe('VoteDetailsModal Component Tests', () => {
const mockProposal: ProposalSDKType = {
id: BigInt(1),
address: 'cosmos1address',
proposers: ['cosmos1proposer'],
submit_time: '2023-11-10T00:00:00Z',
voting_period_end: '2023-11-11T00:00:00Z',
status: 'PROPOSAL_STATUS_SUBMITTED',
executor_result: 'PROPOSAL_EXECUTOR_RESULT_NOT_RUN',
title: 'Test Proposal Title',
summary: 'This is a test summary for the proposal.',
messages: [
{
'@type': '/cosmos.bank.v1beta1.MsgSend',
from_address: 'cosmos1from',
to_address: 'cosmos1to',
amount: [{ denom: 'uatom', amount: '1000' }],
},
],
};
const mockTally: QueryTallyResultResponseSDKType = {
tally: {
yes_count: '10',
abstain_count: '2',
no_count: '3',
no_with_veto_count: '1',
},
};
const mockVotes: VoteSDKType[] = [
{
proposal_id: BigInt(1),
voter: 'cosmos1voter1',
option: 'VOTE_OPTION_YES',
metadata: '',
submit_time: '',
},
// Add more mock votes as needed
];
const mockMembers: MemberSDKType[] = [
{
address: 'cosmos1member1',
weight: '1',
metadata: '',
},
// Add more mock members as needed
];
const defaultProps = {
tallies: mockTally,
votes: mockVotes,
members: mockMembers,
proposal: mockProposal,
onClose: jest.fn(),
modalId: 'voteDetailsModal',
refetchVotes: jest.fn(),
refetchTally: jest.fn(),
refetchProposals: jest.fn(),
};
const renderComponent = (props = {}) => {
return render(
<ChainProvider>
<VoteDetailsModal {...defaultProps} {...props} />
</ChainProvider>
);
};
test('renders the component with provided props', () => {
renderComponent();
expect(screen.getByText(`#${mockProposal.id.toString()}`)).toBeInTheDocument();
expect(screen.getByText(mockProposal.title)).toBeInTheDocument();
expect(screen.getByText('SUMMARY')).toBeInTheDocument();
expect(screen.getByText(mockProposal.summary)).toBeInTheDocument();
});
test('renders the tally chart', () => {
renderComponent();
expect(screen.getByText('TALLY')).toBeInTheDocument();
// Additional checks can be implemented based on how the chart renders
});
test('renders voting countdown timer', () => {
renderComponent();
expect(screen.getByText('VOTING COUNTDOWN')).toBeInTheDocument();
});
test('renders messages section with correct data', () => {
renderComponent();
expect(screen.getByText('MESSAGES')).toBeInTheDocument();
expect(screen.getByText('MsgSend')).toBeInTheDocument();
expect(screen.getByText('from_address:')).toBeInTheDocument();
expect(screen.getByText('to_address:')).toBeInTheDocument();
});
test('conditionally renders execute button when proposal is accepted', () => {
renderComponent({
proposal: { ...mockProposal, status: 'PROPOSAL_STATUS_ACCEPTED' },
});
expect(screen.getByText('Execute')).toBeInTheDocument();
});
test('conditionally renders vote button when proposal is open and user has not voted', () => {
renderComponent();
expect(screen.getByText('Vote')).toBeInTheDocument();
});
test('does not render vote button when user has already voted', () => {
renderComponent({
votes: [{ ...mockVotes[0], voter: 'cosmos1address' }], // Assuming cosmos1address is the current user
});
expect(screen.queryByText('Vote')).not.toBeInTheDocument();
});
test('handles vote button click and opens voting modal', () => {
renderComponent();
const voteButton = screen.getByText('Vote');
fireEvent.click(voteButton);
expect(document.getElementById('vote_modal')).toBeVisible();
});
test('handles execute button click', () => {
// Implement test logic for execute action
});
test('matches snapshot for light theme', () => {
renderComponent();
expect(screen.baseElement).toMatchSnapshot();
});
test('matches snapshot for dark theme', () => {
// Assuming a ThemeProvider or context to change the theme
renderComponent();
expect(screen.baseElement).toMatchSnapshot();
});
});
This test suite includes:
- Snapshot Tests: Ensuring the component's render output matches the expected snapshots for both light and dark themes.
- Unit Tests for Conditional Rendering: Testing the visibility of buttons and sections based on different proposal statuses and user actions.
- Integration Tests Placeholders: Places where you can implement tests for user interactions like executing a proposal or voting.
These tests will help ensure that theme and layout changes don't introduce regressions.
Let me know if you need any further assistance or additional tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will integrate those in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmorency, understood. Would you like me to open a GitHub issue to track adding the tests in a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmorency, I've opened a GitHub issue to track adding tests for the VoteDetailsModal
component as discussed:
This will help ensure that theme and layout changes don't introduce regressions in the future.
🔗 Analysis chain
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Create a GitHub issue to track adding tests for VoteDetailsModal component
gh issue create \
--title "Add tests for VoteDetailsModal component" \
--body "As per the discussion in [PR #41](https://github.com/liftedinit/manifest-app/pull/41), we should add a test suite for the `VoteDetailsModal` component to cover snapshot tests for theme variations, unit tests for conditional rendering, and integration tests for user interactions.
Refer to the code review comment: https://github.com/liftedinit/manifest-app/pull/41#discussion_r1843838029
Requested by: @fmorency" \
--assignee "fmorency"
Length of output: 650
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Félix C. Morency <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
components/groups/components/myGroups.tsx (2)
124-152
: Add test coverage for skeleton loading stateThe skeleton loading implementation looks good, but test coverage is missing for this section.
Would you like me to help generate test cases for the skeleton loading state? This should include:
- Verifying skeleton renders when isLoading is true
- Checking correct number of skeleton rows
- Validating skeleton styling classes
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 126-150: components/groups/components/myGroups.tsx#L126-L150
Added lines #L126 - L150 were not covered by tests
Line range hint
227-238
: Enhance keyboard accessibilityWhile the styling improvements look good, consider adding keyboard accessibility for better user experience.
<tr className="group text-black dark:text-white rounded-lg cursor-pointer transition-colors" + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + onSelectGroup( + policyAddress, + groupName, + (group.policies && + (group.policies[0]?.decision_policy as ThresholdDecisionPolicySDKType)?.threshold) ?? + '0' + ); + } + }} onClick={e => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
components/groups/components/myGroups.tsx
(5 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
components/groups/components/myGroups.tsx
[warning] 126-150: components/groups/components/myGroups.tsx#L126-L150
Added lines #L126 - L150 were not covered by tests
🔇 Additional comments (3)
components/groups/components/myGroups.tsx (3)
Line range hint 86-95
: LGTM: Theme-consistent styling applied
The updated styling for the title and search input properly utilizes theme colors, ensuring visibility in both dark and light modes.
112-122
: Skip comment about column width inconsistency
247-249
: LGTM: Improved badge visibility
The badge styling now properly uses theme colors for better visibility.
This PR
adminOptions
component and testsGroup
page dark and light theming to use theme colorsFixes #40
Partially fixes #32
Summary by CodeRabbit
New Features
AdminOptions
component, streamlining the admin interface.Bug Fixes
UI Improvements
CountdownTimer
,GroupProposals
,myGroups
, andVoteDetailsModal
.Configuration