Skip to content

Commit

Permalink
feat: Hide SFDC for partners (#2229)
Browse files Browse the repository at this point in the history
* feat: Hide SFDC for partners

* fixup! feat: Hide SFDC for partners
  • Loading branch information
aleixhub authored Oct 25, 2024
1 parent e1940fa commit 4786e12
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 184 deletions.
26 changes: 18 additions & 8 deletions catalog/ui/src/app/Catalog/CatalogItemForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import CatalogItemForm from './CatalogItemForm';
import catalogItemObj from '../__mocks__/catalogItem.json';
import userEvent from '@testing-library/user-event';
import { CatalogItem, ServiceNamespace, UserNamespace } from '@app/types';
import useSession from '@app/utils/useSession';
import useHelpLink from '@app/utils/useHelpLink';

jest.mock('@app/api', () => ({
...jest.requireActual('@app/api'),
Expand All @@ -32,8 +30,20 @@ jest.mock('@app/utils/useSession', () =>
userNamespace: namespace as UserNamespace,
groups: ['rhpds-devs', 'rhpds-admins'],
}),
})),
}))
);
jest.mock('@app/utils/useInterfaceConfig', () => {
return jest.fn(() => ({
incidents_enabled: false,
ratings_enabled: false,
status_page_id: '123',
status_page_url: 'https://redhat.com',
help_text: '',
help_link: '',
internal_help_link: '',
sfdc_enabled: true,
}));
});
jest.mock('@app/utils/useHelpLink', () => {
return jest.fn(() => 'https://red.ht/open-support');
});
Expand Down Expand Up @@ -66,12 +76,12 @@ describe('CatalogItemForm Component', () => {
const button = await waitFor(() =>
getByRole('button', {
name: /Order/i,
}),
})
);
expect(button).toBeDisabled();

const termsOfServiceAck = getByText('I confirm that I understand the above warnings.').parentElement.querySelector(
'input[type="checkbox"]',
'input[type="checkbox"]'
);
expect(termsOfServiceAck).not.toBeChecked();
fireEvent.click(termsOfServiceAck);
Expand All @@ -88,7 +98,7 @@ describe('CatalogItemForm Component', () => {
const { queryByText, getByLabelText } = render(<CatalogItemForm />);

const sfidLabel = await waitFor(() =>
getByLabelText('Salesforce ID (Opportunity ID, Campaign ID, CDH Party or Project ID)'),
getByLabelText('Salesforce ID (Opportunity ID, Campaign ID, CDH Party or Project ID)')
);
const sfidTypeDescriptionText = 'Salesforce ID type: Opportunity ID, Campaign ID, CDH Party or Project ID.';
expect(queryByText(sfidTypeDescriptionText)).not.toBeInTheDocument();
Expand Down Expand Up @@ -123,13 +133,13 @@ describe('CatalogItemForm Component', () => {
const button = await waitFor(() =>
getByRole('button', {
name: /Order/i,
}),
})
);

expect(button).toBeDisabled();

const termsOfServiceAck = getByText('I confirm that I understand the above warnings.').parentElement.querySelector(
'input[type="checkbox"]',
'input[type="checkbox"]'
);

fireEvent.click(termsOfServiceAck);
Expand Down
Loading

0 comments on commit 4786e12

Please sign in to comment.