Aggregate queries follow up (#9581)
In this PR - fixing Collapse on view groups views: aggregate bar should be included in the collapse (@magrinj ) - respect the html table pattern: the aggregate bar is now a <tr> element included in a <table> (before that, it was a <tr> not included in anything) - add a top-border on the aggregate bar - introduce short labels for the on-cell value display (display "Empty" instead of "Count empty" to lighten the interface) - remove the feature flag !
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { useRefetchAggregateQueries } from '@/object-record/hooks/useRefetchAggregateQueries';
|
||||
import { getAggregateQueryName } from '@/object-record/utils/getAggregateQueryName';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
|
||||
@ -8,16 +7,6 @@ jest.mock('@apollo/client', () => ({
|
||||
useApolloClient: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('@/workspace/hooks/useIsFeatureEnabled', () => ({
|
||||
useIsFeatureEnabled: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('~/generated/graphql', () => ({
|
||||
FeatureFlagKey: {
|
||||
IsAggregateQueryEnabled: 'IsAggregateQueryEnabled',
|
||||
},
|
||||
}));
|
||||
|
||||
describe('useRefetchAggregateQueries', () => {
|
||||
const mockRefetchQueries = jest.fn();
|
||||
const mockApolloClient = {
|
||||
@ -29,9 +18,8 @@ describe('useRefetchAggregateQueries', () => {
|
||||
(useApolloClient as jest.Mock).mockReturnValue(mockApolloClient);
|
||||
});
|
||||
|
||||
it('should refetch queries when feature flag is enabled', async () => {
|
||||
it('should refetch queries', async () => {
|
||||
// Arrange
|
||||
(useIsFeatureEnabled as jest.Mock).mockReturnValue(true);
|
||||
const objectMetadataNamePlural = 'opportunities';
|
||||
const expectedQueryName = getAggregateQueryName(objectMetadataNamePlural);
|
||||
|
||||
@ -48,24 +36,8 @@ describe('useRefetchAggregateQueries', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not refetch queries when feature flag is disabled', async () => {
|
||||
// Arrange
|
||||
(useIsFeatureEnabled as jest.Mock).mockReturnValue(false);
|
||||
const objectMetadataNamePlural = 'opportunities';
|
||||
|
||||
// Act
|
||||
const { result } = renderHook(() =>
|
||||
useRefetchAggregateQueries({ objectMetadataNamePlural }),
|
||||
);
|
||||
await result.current.refetchAggregateQueries();
|
||||
|
||||
// Assert
|
||||
expect(mockRefetchQueries).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle errors during refetch', async () => {
|
||||
// Arrange
|
||||
(useIsFeatureEnabled as jest.Mock).mockReturnValue(true);
|
||||
const error = new Error('Refetch failed');
|
||||
mockRefetchQueries.mockRejectedValue(error);
|
||||
const objectMetadataNamePlural = 'opportunities';
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { getAggregateQueryName } from '@/object-record/utils/getAggregateQueryName';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
|
||||
export const useRefetchAggregateQueries = ({
|
||||
objectMetadataNamePlural,
|
||||
@ -9,17 +7,13 @@ export const useRefetchAggregateQueries = ({
|
||||
objectMetadataNamePlural: string;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const isAggregateQueryEnabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IsAggregateQueryEnabled,
|
||||
);
|
||||
const refetchAggregateQueries = async () => {
|
||||
if (isAggregateQueryEnabled) {
|
||||
const queryName = getAggregateQueryName(objectMetadataNamePlural);
|
||||
|
||||
await apolloClient.refetchQueries({
|
||||
include: [queryName],
|
||||
});
|
||||
}
|
||||
const refetchAggregateQueries = async () => {
|
||||
const queryName = getAggregateQueryName(objectMetadataNamePlural);
|
||||
|
||||
await apolloClient.refetchQueries({
|
||||
include: [queryName],
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user