Skip to content

Commit 0061f34

Browse files
authored
fix(classification): Fix flaky ai-icon check (#4323)
1 parent 4d89663 commit 0061f34

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/features/classification/__tests__/Classification.test.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
import { render, screen } from '../../../test-utils/testing-library';
3+
import { render, screen, waitFor } from '../../../test-utils/testing-library';
44
import Classification from '../Classification';
55

66
import messages from '../messages';
@@ -258,23 +258,23 @@ describe('features/classification/Classification', () => {
258258
});
259259

260260
// Wait for the async component to load
261-
const boxAiIcon = await screen.findByTestId('box-ai-icon');
262-
const appliedByTitle = screen.getByText(messages.appliedByTitle.defaultMessage);
263-
const appliedByDetails = screen.getByText('Box AI on January 15, 2024'); // expected text based on provided mocks
264-
const reasonText = screen.getByText(aiClassificationReason.answer);
265-
const citationsLabel = screen.queryByTestId('content-answers-references-label');
266-
const citationElements = screen.getAllByTestId('content-answers-citation-status');
267-
const modifiedByPlaintext = screen.queryByTestId('classification-modifiedby');
268-
269-
expect(boxAiIcon).toBeVisible();
270-
expect(appliedByTitle).toBeVisible();
271-
expect(appliedByDetails).toBeVisible();
272-
expect(reasonText).toBeVisible();
273-
expect(citationsLabel).toBeVisible();
274-
expect(citationElements).toHaveLength(expectedCitationsCount);
275-
276-
// Assert the plaintext version of modified by details is not rendered
277-
expect(modifiedByPlaintext).not.toBeInTheDocument();
261+
await waitFor(() => {
262+
const appliedByTitle = screen.getByText(messages.appliedByTitle.defaultMessage);
263+
const appliedByDetails = screen.getByText('Box AI on January 15, 2024'); // expected text based on provided mocks
264+
const reasonText = screen.getByText(aiClassificationReason.answer);
265+
const citationsLabel = screen.queryByTestId('content-answers-references-label');
266+
const citationElements = screen.getAllByTestId('content-answers-citation-status');
267+
const modifiedByPlaintext = screen.queryByTestId('classification-modifiedby');
268+
269+
expect(appliedByTitle).toBeVisible();
270+
expect(appliedByDetails).toBeVisible();
271+
expect(reasonText).toBeVisible();
272+
expect(citationsLabel).toBeVisible();
273+
expect(citationElements).toHaveLength(expectedCitationsCount);
274+
275+
// Assert the plaintext version of modified by details is not rendered
276+
expect(modifiedByPlaintext).not.toBeInTheDocument();
277+
});
278278
},
279279
);
280280

0 commit comments

Comments
 (0)