Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
FeimeiChen committed Oct 5, 2024
1 parent 986c4e2 commit dd48822
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
20 changes: 20 additions & 0 deletions ui/tests/components/table/groupings-table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,24 @@ describe('GroupingsTable', () => {
await checkPageContent('Last', mockData.length - pageSize, mockData.length - 1);
await checkPageContent('Previous', mockData.length - pageSize * 2, mockData.length - pageSize - 1);
});
it('should show tooltip if description content is truncated', async () => {
Object.defineProperties(HTMLElement.prototype, {
scrollWidth: { get: () => 500, configurable: true },
clientWidth: { get: () => 30, configurable: true }
});
render(<GroupingsTable groupingPaths={mockData} />);
const firstButton = screen.getByText('First');

fireEvent.click(firstButton);

const description = screen.getByText('Test Description 0');
await waitFor(async () => {
await userEvent.hover(description);
});

// Wait for the tooltip to appear
await waitFor(() => {
expect(screen.getAllByTestId('tooltip-on-truncate')[0]).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,24 @@ describe('GroupingPathCell', () => {
{ timeout: 2000 }
);
});

it('should show tooltip if content is truncated', async () => {
Object.defineProperties(HTMLElement.prototype, {
scrollWidth: { get: () => 500, configurable: true },
clientWidth: { get: () => 30, configurable: true }
});
render(<GroupingPathCell path={path} />);

const inputElement = screen.getByRole('textbox');
expect(inputElement).toHaveValue(path);

await waitFor(async () => {
await userEvent.hover(inputElement);
});

// Wait for the tooltip to appear
await waitFor(() => {
expect(screen.getAllByTestId('tooltip-on-truncate')[0]).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describe('TooltipOnTruncate component', () => {
</TooltipOnTruncate>
);
const button = screen.getByRole('button');
await userEvent.hover(button);
await waitFor(async () => {
await userEvent.hover(button);
});

// Wait for the tooltip to appear
await waitFor(() => {
Expand All @@ -33,7 +35,10 @@ describe('TooltipOnTruncate component', () => {
</TooltipOnTruncate>
);
const button = screen.getByRole('button');
await userEvent.hover(button);

await waitFor(async () => {
await userEvent.hover(button);
});

await waitFor(() => {
expect(screen.queryByTestId('tooltip-on-truncate')).not.toBeInTheDocument();
Expand Down

0 comments on commit dd48822

Please sign in to comment.