Skip to content

Commit

Permalink
test(20611): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed May 3, 2024
1 parent 6091734 commit fe99686
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { Node } from 'reactflow'
import { MockStoreWrapper } from '@datahub/__test-utils__/MockStoreWrapper.tsx'
import { DataHubNodeType, TopicFilterData } from '@datahub/types.ts'
import { TopicFilterPanel } from './TopicFilterPanel.tsx'
import { mockDataPolicy } from '@datahub/api/hooks/DataHubDataPoliciesService/__handlers__'

const MOCK_TOPIC_FILTER: Node<TopicFilterData> = {
id: '3',
type: DataHubNodeType.CLIENT_FILTER,
position: { x: 0, y: 0 },
data: { topics: ['root/test1', 'root/test2'] },
data: { topics: ['root/test1', 'root/test2', 'root/test1', 'root/topic/ref/1'] },
}

const wrapper: React.JSXElementConstructor<{ children: React.ReactNode }> = ({ children }) => (
Expand All @@ -33,6 +34,7 @@ describe('TopicFilterPanel', () => {
beforeEach(() => {
cy.viewport(800, 800)
cy.intercept('/api/v1/management/protocol-adapters/adapters', { statusCode: 404 })
cy.intercept('/api/v1/data-hub/data-validation/policies', { statusCode: 404 })
})

it('should render the fields for a Validator', () => {
Expand All @@ -47,6 +49,22 @@ describe('TopicFilterPanel', () => {
cy.get('label#root_topics_1-label + input').should('have.value', 'root/test2')
})

it('should validate properly the topic filters', () => {
cy.intercept('/api/v1/data-hub/data-validation/policies', {
items: [mockDataPolicy],
}).as('getPolicies')
cy.mountWithProviders(<TopicFilterPanel selectedNode="3" />, { wrapper })
cy.get('label#root_topics_0-label').should('have.attr', 'data-invalid')
cy.get('label#root_topics_1-label').should('not.have.attr', 'data-invalid')
cy.get('label#root_topics_2-label').should('have.attr', 'data-invalid')
cy.get('label#root_topics_3-label').should('not.have.attr', 'data-invalid')

cy.wait('@getPolicies')

cy.get('button[type=submit]').click()
cy.get('label#root_topics_3-label').should('have.attr', 'data-invalid')
})

it('should be accessible', () => {
cy.injectAxe()
cy.mountWithProviders(<TopicFilterPanel selectedNode="3" />, { wrapper })
Expand Down

0 comments on commit fe99686

Please sign in to comment.