-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(25160): Add devices and brokers to the workspace * feat(25160): add mock for bi-directional * feat(25160): add type for DEVICE node * feat(25160): add custom node for DEVICE * refactor(25160): remove the show host option * refactor(25160): add device-related handle to adapter * feat(25160): add device node and link to adapter to the workspace * test(25160): add tests * test(25160): fix tests * test(25160): add tests * test(25160): fix tests and rename the file * refactor(25160): updated type
- Loading branch information
Showing
18 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
30 changes: 30 additions & 0 deletions
30
hivemq-edge/src/frontend/src/modules/Workspace/components/nodes/NodeDevice.spec.cy.tsx
This file contains 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,30 @@ | ||
import { MOCK_NODE_DEVICE } from '@/__test-utils__/react-flow/nodes.ts' | ||
import { mockReactFlow } from '@/__test-utils__/react-flow/providers.tsx' | ||
|
||
import { NodeDevice } from '@/modules/Workspace/components/nodes/index.ts' | ||
|
||
describe('NodeDevice', () => { | ||
beforeEach(() => { | ||
cy.viewport(400, 400) | ||
}) | ||
|
||
it.only('should render properly', () => { | ||
cy.mountWithProviders(mockReactFlow(<NodeDevice {...MOCK_NODE_DEVICE} />)) | ||
|
||
cy.getByTestId('device-description') | ||
.should('have.text', 'Simulation') | ||
.find('svg') | ||
.should('have.attr', 'data-type', 'INDUSTRIAL') | ||
|
||
cy.getByTestId('device-capabilities').find('svg').as('capabilities').should('have.length', 2) | ||
cy.get('@capabilities').eq(0).should('have.attr', 'data-type', 'READ') | ||
cy.get('@capabilities').eq(1).should('have.attr', 'data-type', 'DISCOVER') | ||
}) | ||
|
||
it('should be accessible', () => { | ||
cy.injectAxe() | ||
cy.mountWithProviders(mockReactFlow(<NodeDevice {...MOCK_NODE_DEVICE} />)) | ||
cy.checkAccessibility() | ||
cy.percySnapshot('Component: NodeDevice') | ||
}) | ||
}) |
38 changes: 38 additions & 0 deletions
38
hivemq-edge/src/frontend/src/modules/Workspace/components/nodes/NodeDevice.tsx
This file contains 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,38 @@ | ||
import { FC } from 'react' | ||
import { Handle, Position, NodeProps } from 'reactflow' | ||
import { HStack, Icon, Text, VStack } from '@chakra-ui/react' | ||
|
||
import { ProtocolAdapter } from '@/api/__generated__' | ||
import NodeWrapper from '@/modules/Workspace/components/parts/NodeWrapper.tsx' | ||
import { deviceCapabilityIcon, deviceCategoryIcon } from '@/modules/Workspace/utils/adapter.utils.ts' | ||
|
||
const NodeDevice: FC<NodeProps<ProtocolAdapter>> = ({ selected, data }) => { | ||
const { category, capabilities } = data | ||
return ( | ||
<> | ||
<NodeWrapper | ||
isSelected={selected} | ||
wordBreak="break-word" | ||
maxW={200} | ||
textAlign="center" | ||
p={3} | ||
borderTopRadius={30} | ||
> | ||
<VStack> | ||
<HStack w="100%" justifyContent="flex-end" gap={1} data-testid="device-capabilities"> | ||
{capabilities?.map((capability) => ( | ||
<Icon key={capability} boxSize={4} as={deviceCapabilityIcon[capability]} data-type={capability} /> | ||
))} | ||
</HStack> | ||
<HStack w="100%" data-testid="device-description"> | ||
<Icon as={deviceCategoryIcon[category?.name || 'SIMULATION']} data-type={category?.name} /> | ||
<Text>{data.protocol}</Text> | ||
</HStack> | ||
</VStack> | ||
</NodeWrapper> | ||
<Handle type="target" position={Position.Bottom} isConnectable={false} /> | ||
</> | ||
) | ||
} | ||
|
||
export default NodeDevice |
This file contains 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 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 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 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 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 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 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
10 changes: 10 additions & 0 deletions
10
hivemq-edge/src/frontend/src/modules/Workspace/utils/adapter.utils.spec.ts
This file contains 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,10 @@ | ||
import { expect } from 'vitest' | ||
import { isBidirectional } from '@/modules/Workspace/utils/adapter.utils.ts' | ||
import { mockProtocolAdapter } from '@/api/hooks/useProtocolAdapters/__handlers__' | ||
|
||
describe('isBidirectional', () => { | ||
it('should return the layout characteristics of a group', async () => { | ||
expect(isBidirectional(mockProtocolAdapter)).toStrictEqual(false) | ||
expect(isBidirectional({ ...mockProtocolAdapter, id: 'opc-ua-client' })).toStrictEqual(true) | ||
}) | ||
}) |
This file contains 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 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