Skip to content

Commit

Permalink
unit test for add button
Browse files Browse the repository at this point in the history
  • Loading branch information
OraldoDoci committed Nov 28, 2024
1 parent e1b4cf4 commit dc6e220
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/pages/dashboardOverview/__tests__/DashboardOverview.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import i18n from '@pagopa/selfcare-common-frontend/lib/locale/locale-utils';
import { fireEvent, screen } from '@testing-library/react';
import React from 'react';
import '../../../locale';
import { mockedParties } from '../../../services/__mocks__/partyService';
import { mockedPartyProducts } from '../../../services/__mocks__/productService';
import { renderWithProviders } from '../../../utils/test-utils';
import DashboardOverview from '../DashboardOverview';
import i18n from '@pagopa/selfcare-common-frontend/lib/locale/locale-utils';

beforeAll(() => {
i18n.changeLanguage('it');
Expand Down Expand Up @@ -75,6 +75,13 @@ test('should render component DashboardOverview with institutionType AS and Prod
<DashboardOverview party={mockedInsuranceCompany} products={mockedPartyProducts} />
);

const addButtons = await screen.findAllByText('Aggiungi');

const addMobilePhoneButton = addButtons[0];

expect(addMobilePhoneButton).toBeInTheDocument();
fireEvent.click(addMobilePhoneButton);

// Avaible products section is not visible for AS
expect(screen.queryByText('Prodotti disponibili')).not.toBeInTheDocument();
});
Expand All @@ -94,7 +101,9 @@ test('should render component DashboardOverview with no geoTaxonomy', async () =

fireEvent.click(geoTaxModal);

const modifyButton = await screen.findByText('Aggiungi');
const addButtons = await screen.findAllByText('Aggiungi');

const modifyButton = addButtons[0];

expect(modifyButton).toBeInTheDocument();
fireEvent.click(modifyButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function WelcomeDashboard({ setOpen, partyId }: Readonly<Props>)
history.push(
resolvePathVariables(`${ENV.ROUTES.USERS}/:userId/edit`, {
partyId,
userId: storageUserOps.read().uid,
userId: storageUserOps.read()?.uid ?? '',
}) + '?activeField=mobilePhone'
)
}
Expand Down

0 comments on commit dc6e220

Please sign in to comment.