diff --git a/src/components/OrgListCard/OrgListCard.test.tsx b/src/components/OrgListCard/OrgListCard.test.tsx index 969f730498..25d7f01ed1 100644 --- a/src/components/OrgListCard/OrgListCard.test.tsx +++ b/src/components/OrgListCard/OrgListCard.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; @@ -19,6 +19,9 @@ const MOCKS = [ { request: { query: IS_SAMPLE_ORGANIZATION_QUERY, + variables: { + isSampleOrganizationId: 'xyz', + }, }, result: { data: { @@ -30,6 +33,14 @@ const MOCKS = [ const link = new StaticMockLink(MOCKS, true); +async function wait(ms = 100): Promise { + await act(() => { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); + }); +} + const props: InterfaceOrgListCardProps = { data: { _id: 'xyz', @@ -64,7 +75,7 @@ const props: InterfaceOrgListCardProps = { }; describe('Testing the Super Dash List', () => { - test('should render props and text elements test for the page component', () => { + test('should render props and text elements test for the page component', async () => { removeItem('id'); setItem('id', '123'); // Means the user is an admin @@ -77,12 +88,15 @@ describe('Testing the Super Dash List', () => { , ); + await wait(); expect(screen.getByAltText(/Dogs Care image/i)).toBeInTheDocument(); expect(screen.getByText(/Admins:/i)).toBeInTheDocument(); expect(screen.getByText(/Members:/i)).toBeInTheDocument(); expect(screen.getByText('Dogs Care')).toBeInTheDocument(); expect(screen.getByText(/Sample City/i)).toBeInTheDocument(); expect(screen.getByText(/123 Sample Street/i)).toBeInTheDocument(); + expect(screen.getByTestId(/manageBtn/i)).toBeInTheDocument(); + expect(screen.getByTestId(/flaskIcon/i)).toBeInTheDocument(); userEvent.click(screen.getByTestId(/manageBtn/i)); removeItem('id'); }); diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index 854fa5e22a..ef1e5efeba 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -99,6 +99,7 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { width={12} className={styles.flaskIcon} title={t('sampleOrganization')} + data-testid="flaskIcon" /> )} {' '}