Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/fossflow-lib/src/components/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const Label = ({
sx={{
position: 'absolute',
top: -labelHeight,
left: -CONNECTOR_DOT_SIZE / 2
left: -CONNECTOR_DOT_SIZE / 2,
pointerEvents: 'none'
}}
>
<line
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Label } from '../Label';

describe('Label', () => {
describe('dotted line', () => {
it('should render dotted line with pointerEvents none to not block clicks', () => {
const { container } = render(
<Label maxWidth={200} labelHeight={50}>
<span>Test Label</span>
</Label>
);

// Find the SVG element (the dotted line container)
const svg = container.querySelector('svg');
expect(svg).toBeTruthy();

// Check that the SVG has pointerEvents set to none
const svgStyles = window.getComputedStyle(svg!);
expect(svgStyles.pointerEvents).toBe('none');
});

it('should not render dotted line when labelHeight is 0', () => {
const { container } = render(
<Label maxWidth={200} labelHeight={0}>
<span>Test Label</span>
</Label>
);

const svg = container.querySelector('svg');
expect(svg).toBeNull();
});

it('should not render dotted line when showLine is false', () => {
const { container } = render(
<Label maxWidth={200} labelHeight={50} showLine={false}>
<span>Test Label</span>
</Label>
);

const svg = container.querySelector('svg');
expect(svg).toBeNull();
});

it('should render children correctly', () => {
render(
<Label maxWidth={200} labelHeight={50}>
<span data-testid="label-content">Test Label Content</span>
</Label>
);

expect(screen.getByTestId('label-content')).toHaveTextContent(
'Test Label Content'
);
});
});
});