generated from finos-labs/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 51
Visualizer styling updates #1373
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
Draft
oliviajanejohns
wants to merge
2
commits into
finos:main
Choose a base branch
from
oliviajanejohns:hackday
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||
import Visualizer from './Visualizer.js'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { CalmArchitectureSchema } from '@finos/calm-shared'; | ||
import { Data } from '../model/calm.js'; | ||
import { ReactNode } from 'react'; | ||
|
||
vi.mock('./components/drawer/Drawer.js', () => ({ | ||
Drawer: ({ | ||
calmInstance, | ||
title, | ||
data, | ||
}: { | ||
calmInstance?: CalmArchitectureSchema; | ||
title: string; | ||
data?: Data; | ||
}) => ( | ||
<div data-testid="drawer"> | ||
<span>{title}</span> | ||
<span>{JSON.stringify(calmInstance)}</span> | ||
<span>{JSON.stringify(data)}</span> | ||
</div> | ||
), | ||
})); | ||
vi.mock('../components/navbar/Navbar.js', () => ({ | ||
Navbar: () => <nav data-testid="navbar" />, | ||
})); | ||
|
||
const mockFileContent = JSON.stringify({ foo: 'bar' }); | ||
const mockFile = { | ||
name: 'test.json', | ||
type: 'application/json', | ||
text: () => Promise.resolve(mockFileContent), | ||
} as File; | ||
vi.mock('./components/menu/Menu.js', () => ({ | ||
Menu: ({ handleUpload }: { handleUpload: (instanceFile: File) => void }) => ( | ||
<button data-testid="upload" onClick={() => handleUpload(mockFile)}> | ||
Upload Architecture | ||
</button> | ||
), | ||
})); | ||
|
||
describe('Visualizer', () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('renders Navbar, Menu, and Drawer', () => { | ||
render( | ||
<MemoryRouter> | ||
<Visualizer /> | ||
</MemoryRouter> | ||
); | ||
expect(screen.getByTestId('navbar')).toBeInTheDocument(); | ||
expect(screen.getByTestId('upload')).toBeInTheDocument(); | ||
expect(screen.getByTestId('drawer')).toBeInTheDocument(); | ||
}); | ||
|
||
it('uses location.state data for title and calmInstance', () => { | ||
const state = { | ||
name: 'Test Title', | ||
data: { | ||
id: 'test-id', | ||
version: '1.0.0', | ||
name: 'test-name', | ||
calmType: 'Architectures', | ||
data: { key: 'value' }, | ||
}, | ||
}; | ||
const Wrapper = ({ children }: { children: ReactNode }) => ( | ||
<MemoryRouter initialEntries={[{ pathname: '/', state }]}>{children}</MemoryRouter> | ||
); | ||
render( | ||
<Wrapper> | ||
<Visualizer /> | ||
</Wrapper> | ||
); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
expect(screen.getByText(JSON.stringify(state.data))).toBeInTheDocument(); | ||
}); | ||
|
||
it('updates title and calmInstance when file is uploaded', async () => { | ||
render( | ||
<MemoryRouter> | ||
<Visualizer /> | ||
</MemoryRouter> | ||
); | ||
fireEvent.click(screen.getByTestId('upload')); | ||
await waitFor(() => { | ||
expect(screen.getByText('test.json')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('falls back to location.state if no file uploaded', () => { | ||
const state = { name: 'Fallback Title', data: { fallback: true } }; | ||
const Wrapper = ({ children }: { children: ReactNode }) => ( | ||
<MemoryRouter initialEntries={[{ pathname: '/', state }]}>{children}</MemoryRouter> | ||
); | ||
render( | ||
<Wrapper> | ||
<Visualizer /> | ||
</Wrapper> | ||
); | ||
expect(screen.getByText('Fallback Title')).toBeInTheDocument(); | ||
expect(screen.getByText(JSON.stringify({ fallback: true }))).toBeInTheDocument(); | ||
}); | ||
}); |
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
52 changes: 52 additions & 0 deletions
52
...-ui/src/visualizer/components/cytoscape/cytoscape-control-panel/CytoscapeControlPanel.tsx
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs tests |
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,52 @@ | ||
export interface CytoscapeControlPanelProps { | ||
title: string; | ||
isNodeDescActive: boolean; | ||
isRelationshipDescActive: boolean; | ||
toggleConnectionDesc: () => void; | ||
toggleNodeDesc: () => void; | ||
} | ||
export function CytoscapeControlPanel({ | ||
title, | ||
isNodeDescActive, | ||
isRelationshipDescActive, | ||
toggleConnectionDesc, | ||
toggleNodeDesc, | ||
}: CytoscapeControlPanelProps) { | ||
return ( | ||
<div className="graph-title absolute m-5 btn-outline btn-primary shadow-md p-4"> | ||
<div className="mb-4"> | ||
<span className="text-lg font-thin text-primary">Architecture: </span> | ||
<span className="text-lg font-semibold text-primary">{title}</span> | ||
</div> | ||
<hr className="my-4 border-base-300" /> | ||
<div> | ||
<div className="text-sm font-semibold mb-2 text-primary">Display Settings</div> | ||
<div className="flex flex-col gap-2 text-sm"> | ||
<label className="label cursor-pointer"> | ||
<input | ||
type="checkbox" | ||
className="checkbox" | ||
name="connection-description" | ||
aria-label="connection-description" | ||
checked={isRelationshipDescActive} | ||
onChange={toggleConnectionDesc} | ||
/> | ||
<span className="label-text text-base-content ml-2"> | ||
Relationship Descriptions | ||
</span> | ||
</label> | ||
<label className="label cursor-pointer"> | ||
<input | ||
className="checkbox" | ||
type="checkbox" | ||
aria-label="node-description" | ||
checked={isNodeDescActive} | ||
onChange={toggleNodeDesc} | ||
/> | ||
<span className="label-text text-base-content ml-2">Node Descriptions</span> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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
File renamed without changes.
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
Oops, something went wrong.
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.
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.
lovely refactor