Skip to content

Commit

Permalink
test(28866): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Dec 12, 2024
1 parent 4b43370 commit ca35626
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/// <reference types="cypress" />

import { mockReactFlow } from '@/__test-utils__/react-flow/providers.tsx'
import { CustomNodeTesting } from '@/__test-utils__/react-flow/CustomNodeTesting.tsx'
import { MOCK_NODE_ADAPTER } from '@/__test-utils__/react-flow/nodes.ts'
import { MOCK_TOPIC_REF1, MOCK_TOPIC_REF2 } from '@/__test-utils__/react-flow/topics.ts'
import { MOCK_ADAPTER_ID } from '@/__test-utils__/mocks.ts'

import { mockProtocolAdapter } from '@/api/hooks/useProtocolAdapters/__handlers__'
import { formatTopicString } from '@/components/MQTT/topic-utils.ts'
import { NodeTypes } from '@/modules/Workspace/types.ts'

import NodeAdapter from './NodeAdapter.tsx'
import {
MOCK_NORTHBOUND_MAPPING,
MOCK_SOUTHBOUND_MAPPING,
} from '@/api/hooks/useProtocolAdapters/__handlers__/mapping.mocks.ts'

describe('NodeAdapter', () => {
beforeEach(() => {
Expand All @@ -25,17 +26,22 @@ describe('NodeAdapter', () => {
},
],
})

cy.intercept('/api/v1/management/protocol-adapters/adapters/*/northboundMappings', {
items: [MOCK_NORTHBOUND_MAPPING],
}).as('getNorthboundMappings')

cy.intercept('/api/v1/management/protocol-adapters/adapters/*/southboundMappings', {
items: [MOCK_SOUTHBOUND_MAPPING],
}).as('getSouthboundMappings')
})

it('should render properly', () => {
cy.mountWithProviders(mockReactFlow(<NodeAdapter {...MOCK_NODE_ADAPTER} />))

cy.getByTestId('adapter-node-name').should('contain', MOCK_ADAPTER_ID)
cy.getByTestId('connection-status').should('contain.text', 'Connected')
cy.getByTestId('topics-container')
.should('be.visible')
.should('contain.text', formatTopicString(MOCK_TOPIC_REF1))
.should('contain.text', formatTopicString(MOCK_TOPIC_REF2))
cy.getByTestId('topics-container').should('be.visible').should('contain.text', formatTopicString('my/topic'))
})

it('should render the selected adapter properly', () => {
Expand Down

0 comments on commit ca35626

Please sign in to comment.