Skip to content

Commit

Permalink
[Cases] Fix FilesTable flaky test (#170504)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
cnasikas and kibanamachine authored Nov 3, 2023
1 parent d3c50cd commit 55b9c01
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions x-pack/plugins/cases/public/components/files/files_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('FilesTable', () => {
)
);

expect(await screen.queryByTestId('cases-files-image-preview')).not.toBeInTheDocument();
expect(screen.queryByTestId('cases-files-image-preview')).not.toBeInTheDocument();
});

it('image rows open file preview', async () => {
Expand Down Expand Up @@ -132,10 +132,15 @@ describe('FilesTable', () => {
it('download button renders correctly', async () => {
appMockRender.render(<FilesTable {...defaultProps} />);

expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
});

await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
});
});

expect(await screen.findByTestId('cases-files-download-button')).toBeInTheDocument();
Expand All @@ -144,10 +149,15 @@ describe('FilesTable', () => {
it('delete button renders correctly', async () => {
appMockRender.render(<FilesTable {...defaultProps} />);

expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
});

await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
});
});

expect(await screen.findByTestId('cases-files-delete-button')).toBeInTheDocument();
Expand All @@ -156,10 +166,15 @@ describe('FilesTable', () => {
it('clicking delete button opens deletion modal', async () => {
appMockRender.render(<FilesTable {...defaultProps} />);

expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toBeCalledTimes(1);
});

await waitFor(() => {
expect(appMockRender.getFilesClient().getDownloadHref).toHaveBeenCalledWith({
fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
id: basicFileMock.id,
});
});

const deleteButton = await screen.findByTestId('cases-files-delete-button');
Expand Down Expand Up @@ -216,9 +231,9 @@ describe('FilesTable', () => {
<FilesTable {...defaultProps} items={[{ ...basicFileMock }, { ...basicFileMock }]} />
);

userEvent.click(screen.getByTestId('tablePaginationPopoverButton'));
userEvent.click(await screen.findByTestId('tablePaginationPopoverButton'));

const pageSizeOption = screen.getByTestId('tablePagination-50-rows');
const pageSizeOption = await screen.findByTestId('tablePagination-50-rows');

pageSizeOption.style.pointerEvents = 'all';

Expand Down

0 comments on commit 55b9c01

Please sign in to comment.