-
Notifications
You must be signed in to change notification settings - Fork 11
feat(APP-4058): Implement ActionSimulation component #572
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
Merged
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a0d05c1
Initial AI version
milosh86 8e7deb4
Initial AI version
milosh86 45c03e2
Implement MD breakpoint
milosh86 bd6795d
Fix label
milosh86 85296c3
Wrap in DataListItem
milosh86 7783cb1
Add copy
milosh86 cf40399
Refactor status props
milosh86 e6aed69
Add error message
milosh86 68da41f
Add isSimulatable flag
milosh86 c63951b
Disable button if no tenderly url
milosh86 a3ebe2a
Cleanup
milosh86 33eb4c4
Cleanup stories
milosh86 25aa7d2
Fix tests
milosh86 54cc47d
Add changeset
milosh86 54cd5c0
Fix lint
milosh86 a2cf1f7
Update error story
milosh86 31308a5
Update story folder position
milosh86 769de3f
Add variant prop to Dropdown
milosh86 2caf8f6
Refactor props structure
milosh86 1cc6e66
Rename props
milosh86 97648f5
Remove custom date formatting
milosh86 a977bf4
Update dropdownItem to support submit button
milosh86 e9fcb6d
Align Tenderly button to the left when not simulatable
milosh86 86e5c42
Refactor module structure - add action module
milosh86 de79dae
Update changeset
milosh86 656198b
Include action module
milosh86 ed94713
p -> div to avoid hydration error
milosh86 304690b
Merge branch 'main' into APP-4058-tenderly
cgero-eth 356ad24
Create IActionSimulationRun interface
milosh86 cc8fca0
Update tests to use copy
milosh86 a784306
Address PR commets
milosh86 0b69f28
Update exports
milosh86 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
There are no files selected for viewing
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,5 @@ | ||
| --- | ||
| '@aragon/gov-ui-kit': minor | ||
| --- | ||
|
|
||
| Implement `ActionSimulation` component |
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
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
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
98 changes: 98 additions & 0 deletions
98
src/modules/components/action/actionSimulation/actionSimulation.stories.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,98 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import { DateTime } from 'luxon'; | ||
| import { ActionSimulation } from './actionSimulation'; | ||
|
|
||
| const meta: Meta<typeof ActionSimulation> = { | ||
| title: 'Modules/Components/Action/ActionSimulation', | ||
| component: ActionSimulation, | ||
| parameters: { | ||
| design: { | ||
| type: 'figma', | ||
| url: 'https://www.figma.com/design/ISSDryshtEpB7SUSdNqAcw/Governance-UI-Kit?node-id=30069-34747&t=tQiF5klPD9cjUit6-4', | ||
| }, | ||
| }, | ||
| args: { | ||
| className: 'flex-1', | ||
| }, | ||
| }; | ||
|
|
||
| type Story = StoryObj<typeof ActionSimulation>; | ||
|
|
||
| /** | ||
| * Completed simulation with positive outcome | ||
| */ | ||
| export const Success: Story = { | ||
| args: { | ||
| totalActions: 3, | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().minus({ seconds: 10 }).toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'success', | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Completed simulation with negative outcome (can't be executed) | ||
| */ | ||
| export const Failure: Story = { | ||
| args: { | ||
| totalActions: 2, | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().minus({ seconds: 10 }).toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'failure', | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Loading state while simulation is running | ||
| */ | ||
| export const Loading: Story = { | ||
| args: { | ||
| totalActions: 5, | ||
| isLoading: true, | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * No simulation has been run yet | ||
| */ | ||
| export const NoPreviousSimulation: Story = { | ||
| args: { | ||
| totalActions: 1, | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * With error message displayed | ||
| */ | ||
| export const WithErrorMessage: Story = { | ||
| args: { | ||
| totalActions: 2, | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().minus({ weeks: 2 }).toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'success', | ||
| }, | ||
| error: 'Simulation failed to run. Please try again.', | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Not simulatable - only shows Tenderly link | ||
| */ | ||
| export const NotSimulatable: Story = { | ||
| args: { | ||
| totalActions: 3, | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().minus({ hours: 2 }).toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'success', | ||
| }, | ||
| isEnabled: false, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; |
96 changes: 96 additions & 0 deletions
96
src/modules/components/action/actionSimulation/actionSimulation.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,96 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { DateTime } from 'luxon'; | ||
| import { GukCoreProvider } from '../../../../core'; | ||
| import type { IActionSimulationProps } from './actionSimulation'; | ||
| import { ActionSimulation } from './actionSimulation'; | ||
|
|
||
| describe('<ActionSimulation /> component', () => { | ||
| const createTestComponent = (props?: Partial<IActionSimulationProps>) => { | ||
| const completeProps: IActionSimulationProps = { | ||
| totalActions: 3, | ||
| ...props, | ||
| }; | ||
|
|
||
| return ( | ||
| <GukCoreProvider> | ||
| <ActionSimulation {...completeProps} /> | ||
| </GukCoreProvider> | ||
| ); | ||
| }; | ||
|
|
||
| it('renders all definition list items', () => { | ||
| render(createTestComponent()); | ||
|
|
||
| expect(screen.getByText('Total actions')).toBeInTheDocument(); | ||
| expect(screen.getByText('Last simulation')).toBeInTheDocument(); | ||
| expect(screen.getByText('Executable')).toBeInTheDocument(); | ||
|
milosh86 marked this conversation as resolved.
Outdated
|
||
| }); | ||
|
|
||
| it('renders the total actions count', () => { | ||
| render(createTestComponent({ totalActions: 5 })); | ||
| expect(screen.getByText('5 actions')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders singular action text for one action', () => { | ||
| render(createTestComponent({ totalActions: 1 })); | ||
| expect(screen.getByText('1 action')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders "Never" when no last simulation is provided', () => { | ||
| render(createTestComponent()); | ||
| expect(screen.getByText('Never')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the execution status label', () => { | ||
| render( | ||
| createTestComponent({ | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'success', | ||
| }, | ||
| }), | ||
| ); | ||
|
milosh86 marked this conversation as resolved.
|
||
| expect(screen.getByText('Likely to succeed')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders failure status label', () => { | ||
| render( | ||
| createTestComponent({ | ||
| lastSimulation: { | ||
| timestamp: DateTime.now().toMillis(), | ||
| url: 'https://dashboard.tenderly.co/simulation/12345', | ||
| status: 'failure', | ||
| }, | ||
| }), | ||
| ); | ||
| expect(screen.getByText('Likely to fail')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders unknown status when no lastSimulation is provided', () => { | ||
| render(createTestComponent()); | ||
| expect(screen.getByText('Unknown')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders loading state when execution status is loading', () => { | ||
| render( | ||
| createTestComponent({ | ||
| isLoading: true, | ||
| }), | ||
| ); | ||
|
milosh86 marked this conversation as resolved.
Outdated
|
||
|
|
||
| expect(screen.getAllByText('Simulating')).toHaveLength(3); | ||
| }); | ||
|
|
||
| it('shows simulate button by default when isSimulatable is not specified', () => { | ||
| render(createTestComponent()); | ||
|
|
||
| expect(screen.getByText(/simulate/i)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('hides simulate button when isSimulatable is false', () => { | ||
|
milosh86 marked this conversation as resolved.
Outdated
|
||
| render(createTestComponent({ isEnabled: false })); | ||
|
|
||
| expect(screen.queryByText(/simulate/i)).toBeNull(); | ||
|
milosh86 marked this conversation as resolved.
Outdated
|
||
| }); | ||
| }); | ||
Oops, something went wrong.
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.