Skip to content

Commit

Permalink
test(28974): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Jan 10, 2025
1 parent 337ae57 commit 91defdf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MOCK_METRICS } from '@/api/hooks/useGetMetrics/__handlers__'
import { MetricList } from '@/api/__generated__'
import { MOCK_NODE_ADAPTER } from '@/__test-utils__/react-flow/nodes.ts'
import { MOCK_ADAPTER_ID, MOCK_ADAPTER_ID2 } from '@/__test-utils__/mocks.ts'
import { mockEdgeEvent } from '@/api/hooks/useEvents/__handlers__'

const mockNode: Node<Group> = {
position: { x: 0, y: 0 },
Expand Down Expand Up @@ -37,7 +38,7 @@ describe('GroupPropertyDrawer', () => {
cy.intercept('/api/v1/metrics/**', []).as('getMetricForX')
})

it('should render properly', () => {
it('should render the minimal metrics properly', () => {
const onClose = cy.stub().as('onClose')
const onEditEntity = cy.stub()
cy.mountWithProviders(
Expand Down Expand Up @@ -67,6 +68,47 @@ describe('GroupPropertyDrawer', () => {
cy.getByTestId('metrics-toggle').should('be.visible')
})

it.only('should render the full config tabs properly', () => {
cy.intercept('/api/v1/management/events?*', { items: [...mockEdgeEvent(150)] })
const onClose = cy.stub().as('onClose')
const onEditEntity = cy.stub()
cy.mountWithProviders(
<GroupPropertyDrawer
showConfig
nodeId="adapter@fgffgf"
nodes={mockNodes}
selectedNode={mockNode}
isOpen={true}
onClose={onClose}
onEditEntity={onEditEntity}
/>
)

cy.wait('@getMetricForX')

// check the panel header
cy.getByTestId('group-panel-title').should('contain.text', 'Group Overview')

// check the panel control
cy.get('@onClose').should('not.have.been.called')
cy.getByAriaLabel('Close').click()
cy.get('@onClose').should('have.been.calledOnce')

// check the panel tabs
cy.get('[role="tablist"] [role="tab"]').should('have.length', 3)
cy.get('[role="tablist"] [role="tab"]').eq(0).should('have.text', 'Configuration')
cy.get('[role="tablist"] [role="tab"]').eq(1).should('have.text', 'Events')
cy.get('[role="tablist"] [role="tab"]').eq(2).should('have.text', 'Metrics')

cy.get('[role="tablist"] + div > [role="tabpanel"]').should('have.length', 3)
cy.get('[role="tablist"] + div > [role="tabpanel"]').eq(0).should('not.have.attr', 'hidden')
cy.get('[role="tablist"] + div > [role="tabpanel"]').eq(1).should('have.attr', 'hidden')
cy.get('[role="tablist"] + div > [role="tabpanel"]').eq(2).should('have.attr', 'hidden')

cy.getByTestId('group-metadata-header').should('be.visible')
cy.getByTestId('group-content-header').should('be.visible')
})

it('should be accessible', () => {
cy.injectAxe()
cy.mountWithProviders(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const GroupMetadataEditor: FC<GroupMetadataEditorProps> = ({ group, onSubmit })

return (
<Card size="sm">
<CardHeader data-testid="group-metadata-header"> {t('workspace.grouping.editor.title')}</CardHeader>
<CardHeader data-testid="group-metadata-header">{t('workspace.grouping.editor.title')}</CardHeader>
<CardBody>
<form
id="group-form"
Expand Down

0 comments on commit 91defdf

Please sign in to comment.