Merge pull request #27637 from virzen/progress-placeholder-id

Add data-testid to Progress placeholder
This commit is contained in:
Patrik Oldsberg
2024-11-26 15:38:02 +01:00
committed by GitHub
3 changed files with 8 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Added data-testid to placeholder rendered by Progress component to simplify assertions in tests
@@ -16,19 +16,12 @@
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { act } from '@testing-library/react';
import { Progress } from './Progress';
describe('<Progress />', () => {
it('renders without exploding', async () => {
jest.useFakeTimers();
const { getByTestId, queryByTestId } = await renderInTestApp(<Progress />);
expect(queryByTestId('progress')).not.toBeInTheDocument();
act(() => {
jest.advanceTimersByTime(250);
});
expect(getByTestId('progress')).toBeInTheDocument();
jest.useRealTimers();
const { queryByTestId } = await renderInTestApp(<Progress />);
expect(queryByTestId('progress')).toBeInTheDocument();
});
});
@@ -36,6 +36,6 @@ export function Progress(props: PropsWithChildren<LinearProgressProps>) {
return isVisible ? (
<LinearProgress {...props} data-testid="progress" />
) : (
<Box display="none" />
<Box display="none" data-testid="progress" />
);
}