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

feat: add zero state for customer view headers #415

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -16,6 +16,10 @@ const CustomerIntegrations = ({
integrationCount++;
}

if (!integrationCount) {
return null;
}

return (
<div>
{(integrationCount > 0) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,31 @@ const CustomerPlanContainer = ({ slug }) => {
const renderInActiveSubscriptions = inactiveSubscriptions.map(subscription => (
<SubscriptionPlanCard key={subscription.uuid} isActive={false} slug={slug} subscription={subscription} />
));

const hasActivePlans = activePolicies.length > 0 || renderActiveSubscriptions.length > 0;

if (!hasActivePlans) {
return null;
}

return (
<div>
{!isLoading ? (
<div>
<div className="d-flex justify-content-between">
<h2>Associated subsidy plans ({showInactive ? countOfAllPlans : countOfActivePlans})</h2>
<Form.Switch
className="ml-2.5 mt-2.5"
checked={showInactive}
disabled={countOfAllPlans === countOfActivePlans}
onChange={() => {
setShowInactive(prevState => !prevState);
}}
data-testid="show-removed-toggle"
>
Show inactive
</Form.Switch>
{(countOfAllPlans !== countOfActivePlans) && (
<Form.Switch
className="ml-2.5 mt-2.5"
checked={showInactive}
onChange={() => {
setShowInactive(prevState => !prevState);
}}
data-testid="show-removed-toggle"
>
Show inactive
</Form.Switch>
)}
</div>
<hr />
{renderActivePoliciesCard}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const EnterpriseCustomerUsersTable = () => {
enterpriseUsersTableData,
fetchEnterpriseUsersData,
} = useCustomerUsersTableData(id);

if (!enterpriseUsersTableData.itemCount) {
katrinan029 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

return (
<div>
<h2>Associated users ({enterpriseUsersTableData.itemCount})</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,26 @@ describe('CustomerPlanContainer', () => {
await waitFor(() => expect(screen.getByText('Associated subsidy plans (3)')).toBeInTheDocument());
expect(screen.getByText('Inactive')).toBeInTheDocument();
});
it('does not render CustomerPlanContainer data', async () => {
getConfig.mockImplementation(() => ({
ADMIN_PORTAL_BASE_URL: 'http://www.testportal.com',
ENTERPRISE_ACCESS_BASE_URL: 'http:www.enterprise-access.com',
LICENSE_MANAGER_URL: 'http:www.license-manager.com',
}));
useAllAssociatedPlans.mockReturnValue({
isLoading: false,
activePolicies: [],
activeSubscriptions: [],
countOfActivePlans: 0,
countOfAllPlans: 0,
inactiveSubscriptions: [],
inactivePolicies: [],
});
render(
<IntlProvider locale="en">
<CustomerPlanContainer slug={CUSTOMER_SLUG} />
</IntlProvider>,
);
expect(screen.queryByText('Associated subsidy plans (0)')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,20 @@ describe('CustomerViewIntegrations', () => {
expect(screen.getByText('API')).toBeInTheDocument();
});
});
it('does not render cards', async () => {
formatDate.mockReturnValue('September 15, 2024');
render(
<IntlProvider locale="en">
<CustomerIntegrations
slug="marcel-the-shell"
activeIntegrations={mockIntegratedChannelData}
activeSSO={[]}
apiCredentialsEnabled={false}
/>
</IntlProvider>,
);
await waitFor(() => {
expect(screen.queryByText('Associated integrations (0)')).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,24 @@ describe('EnterpriseCustomerUsersTable', () => {
});
});
});

it('does not render user table section', () => {
const emptyResults = {
isLoading: false,
enterpriseUsersTableData: {
itemCount: 0,
pageCount: 1,
results: [],
},
fetchEnterpriseUsersData: mockFetchEnterpriseUsersData,
};
useCustomerUsersTableData.mockReturnValue(emptyResults);
render(
<IntlProvider locale="en">
<EnterpriseCustomerUsersTable />
</IntlProvider>,
);
expect(screen.queryByText('Search user details')).not.toBeInTheDocument();
expect(screen.queryByText('Associated users (0)')).not.toBeInTheDocument();
});
});