Merge pull request #27637 from virzen/progress-placeholder-id
Add data-testid to Progress placeholder
This commit is contained in:
@@ -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" />
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user