Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-Jira] Flaky tests #862

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ describe('partnerGivingAnalysis page', () => {
expect(getByRole('tab', { name: 'Tasks' })).toBeInTheDocument();
});

it('renders navigation panel', () => {
const { getByRole } = render(<TestingComponent />);

userEvent.click(getByRole('button', { name: 'Toggle Navigation Panel' }));
expect(getByRole('heading', { name: 'Reports' })).toBeInTheDocument();
});

it('renders filters panel', async () => {
const { getByRole, findByRole } = render(<TestingComponent />);

userEvent.click(getByRole('img', { name: 'Toggle Filter Panel' }));
expect(await findByRole('heading', { name: 'Filter' })).toBeInTheDocument();
});

it('toggles filter panel', async () => {
const { findByTestId, getByRole, getByTestId } = render(
<TestingComponent />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import { ReportContactFilterSetInput } from 'pages/api/graphql-rest.page.generat
import { ContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/ContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
import { PartnerGivingAnalysisReport } from 'src/components/Reports/PartnerGivingAnalysisReport/PartnerGivingAnalysisReport';
import {
Panel,
PartnerGivingAnalysisReport,
} from 'src/components/Reports/PartnerGivingAnalysisReport/PartnerGivingAnalysisReport';
import { FilterPanel } from 'src/components/Shared/Filters/FilterPanel';
import {
MultiPageMenu,
NavTypeEnum,
} from 'src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu';
import { useAccountListId } from 'src/hooks/useAccountListId';
import { useDebouncedValue } from 'src/hooks/useDebounce';
import useGetAppSettings from 'src/hooks/useGetAppSettings';
Expand All @@ -31,13 +38,17 @@ const PartnerGivingAnalysisReportPage: React.FC = () => {
const { t } = useTranslation();
const accountListId = useAccountListId();
const { appName } = useGetAppSettings();
const [isNavListOpen, setNavListOpen] = useState<boolean>(false);
const [panelOpen, setPanelOpen] = useState<Panel | null>(null);

const router = useRouter();
const selectedContactId = getQueryParam(router.query, 'contactId');

const handleNavListToggle = () => {
setNavListOpen(!isNavListOpen);
setPanelOpen(panelOpen === Panel.Navigation ? null : Panel.Navigation);
};

const handleFilterListToggle = () => {
setPanelOpen(panelOpen === Panel.Filters ? null : Panel.Filters);
};

const [activeFilters, setActiveFilters] =
Expand Down Expand Up @@ -93,26 +104,36 @@ const PartnerGivingAnalysisReportPage: React.FC = () => {
<SidePanelsLayout
isScrollBox={true}
leftPanel={
isNavListOpen && filtersLoading ? (
<Loading loading />
) : (
<FilterPanel
filters={filterGroups}
defaultExpandedFilterGroups={new Set(['Report Filters'])}
savedFilters={[]}
selectedFilters={activeFilters}
onClose={() => setNavListOpen(false)}
onSelectedFiltersChanged={setActiveFilters}
panelOpen === Panel.Navigation ? (
<MultiPageMenu
isOpen
selectedId="donations"
onClose={() => setPanelOpen(null)}
navType={NavTypeEnum.Reports}
/>
)
) : panelOpen === Panel.Filters ? (
filtersLoading ? (
<Loading loading />
) : (
<FilterPanel
filters={filterGroups}
defaultExpandedFilterGroups={new Set(['Report Filters'])}
savedFilters={[]}
selectedFilters={activeFilters}
onClose={() => setPanelOpen(null)}
onSelectedFiltersChanged={setActiveFilters}
/>
)
) : undefined
}
leftOpen={isNavListOpen}
leftOpen={panelOpen !== null}
leftWidth="290px"
mainContent={
<PartnerGivingAnalysisReport
accountListId={accountListId}
activeFilters={activeFilters}
isNavListOpen={isNavListOpen}
panelOpen={panelOpen}
onFilterListToggle={handleFilterListToggle}
onNavListToggle={handleNavListToggle}
onSelectContact={handleSelectContact}
title={t('Partner Giving Analysis')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</TestRouter>
Expand All @@ -62,6 +63,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</TestRouter>
Expand Down Expand Up @@ -115,6 +117,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</TestRouter>
Expand Down Expand Up @@ -175,7 +178,7 @@ describe('CreateMultipleContacts', () => {
primaryAddressId: 'address-1',
},
});
}, 80000);
}, 20000);

it('creates one referral', async () => {
const { getByRole, getAllByRole } = render(
Expand All @@ -197,6 +200,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
referredById={'referrer-1'}
/>
</GqlMockedProvider>
Expand Down Expand Up @@ -231,6 +235,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</TestRouter>
Expand Down Expand Up @@ -290,12 +295,12 @@ describe('CreateMultipleContacts', () => {
expect(operation4.variables.attributes.firstName).toEqual(first2);
expect(operation4.variables.attributes.lastName).toEqual(last2);

// Contact 1 Person 1 - Awaiting on Contact 1 Person 1 to resolve.
// Contact 1 Person 2 - Awaiting on Contact 1 Person 1 to resolve.
const { operation: operation3 } = mutationSpy.mock.calls[5][0];
expect(operation3.variables.accountListId).toEqual(accountListId);
expect(operation3.variables.attributes.firstName).toEqual(spouse);
expect(operation3.variables.attributes.lastName).toEqual(last);
}, 60000);
});

it('creates multiple contacts - part 2', async () => {
const { getByText, getAllByRole } = render(
Expand All @@ -306,6 +311,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</TestRouter>
Expand All @@ -331,7 +337,7 @@ describe('CreateMultipleContacts', () => {
// Contact 2
const { operation: operation1 } = mutationSpy.mock.calls[1][0];
expect(operation1.variables.accountListId).toEqual(accountListId);
expect(operation1.variables.attributes.name).toEqual(`${first3}`);
expect(operation1.variables.attributes.name).toEqual(first3);

// Contact 2 Person 1
const { operation: operation2 } = mutationSpy.mock.calls[3][0];
Expand All @@ -350,7 +356,7 @@ describe('CreateMultipleContacts', () => {
expect(operation3.variables.accountListId).toEqual(accountListId);
expect(operation3.variables.attributes.firstName).toEqual(spouse2);
expect(operation3.variables.attributes.lastName).toEqual('');
}, 80000);
});

it('handles chosen address predictions', async () => {
jest.useFakeTimers();
Expand All @@ -362,6 +368,7 @@ describe('CreateMultipleContacts', () => {
<CreateMultipleContacts
accountListId={accountListId}
handleClose={handleClose}
rows={3}
/>
</GqlMockedProvider>
</ThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface Props {
accountListId: string;
handleClose: () => void;
referredById?: string;
rows?: number;
}

interface ContactRow {
Expand Down Expand Up @@ -114,11 +115,12 @@ export const CreateMultipleContacts = ({
accountListId,
handleClose,
referredById,
rows = 10,
}: Props): ReactElement<Props> => {
const { t } = useTranslation();
const { enqueueSnackbar } = useSnackbar();
const initialContacts: ContactTable = {
contacts: new Array(10).fill(defaultContact),
contacts: new Array(rows).fill(defaultContact),
};

const [createContact] = useCreateContactMutation();
Expand Down
Loading
Loading