test: improve utils coverage (#4230)
* test: improve utils coverage * refactor: review - rename isDefined to isNonNullable, update tests and return statement
This commit is contained in:
@ -20,7 +20,7 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||
import { MenuItemDraggable } from '@/ui/navigation/menu-item/components/MenuItemDraggable';
|
||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { groupArrayItemsBy } from '~/utils/array/groupArrayItemsBy';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
type ViewFieldsVisibilityDropdownSectionProps = {
|
||||
fields: Omit<ColumnDefinition<FieldMetadata>, 'size'>[];
|
||||
@ -69,7 +69,7 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
||||
Icon: field.isVisible ? IconMinus : IconPlus,
|
||||
onClick: () => onVisibilityChange(field),
|
||||
},
|
||||
].filter(isDefined);
|
||||
].filter(isNonNullable);
|
||||
|
||||
return iconButtons.length ? iconButtons : undefined;
|
||||
};
|
||||
@ -134,7 +134,7 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
||||
/>
|
||||
)}
|
||||
</DropdownMenuItemsContainer>
|
||||
{isDefined(openToolTipIndex) &&
|
||||
{isNonNullable(openToolTipIndex) &&
|
||||
createPortal(
|
||||
<AppTooltip
|
||||
anchorSelect={`.${title}-${
|
||||
|
||||
@ -20,7 +20,7 @@ import { MOBILE_VIEWPORT } from '@/ui/theme/constants/MobileViewport';
|
||||
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
||||
import { VIEWS_DROPDOWN_ID } from '@/views/constants/ViewsDropdownId';
|
||||
import { useViewBar } from '@/views/hooks/useViewBar';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { useViewScopedStates } from '../hooks/internal/useViewScopedStates';
|
||||
|
||||
@ -161,7 +161,7 @@ export const ViewsDropdownButton = ({
|
||||
handleDeleteViewButtonClick(event, view.id),
|
||||
}
|
||||
: null,
|
||||
].filter(assertNotNull)}
|
||||
].filter(isNonNullable)}
|
||||
onClick={() => handleViewSelect(view.id)}
|
||||
LeftIcon={IconList}
|
||||
text={view.name}
|
||||
|
||||
@ -14,7 +14,7 @@ import { useGenerateFindManyRecordsQuery } from '@/object-record/hooks/useGenera
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { ViewFilter } from '@/views/types/ViewFilter';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
const filterQueryParamsSchema = z.object({
|
||||
filter: z.record(
|
||||
@ -142,7 +142,7 @@ export const useFiltersFromQueryParams = () => {
|
||||
},
|
||||
),
|
||||
)
|
||||
).filter(assertNotNull);
|
||||
).filter(isNonNullable);
|
||||
},
|
||||
[
|
||||
apolloClient,
|
||||
|
||||
@ -7,8 +7,8 @@ import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-i
|
||||
import { ViewField } from '@/views/types/ViewField';
|
||||
import { ViewFilter } from '@/views/types/ViewFilter';
|
||||
import { ViewSort } from '@/views/types/ViewSort';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { ViewScopeInternalContext } from '../scopes/scope-internal-context/ViewScopeInternalContext';
|
||||
import { currentViewFieldsScopedFamilyState } from '../states/currentViewFieldsScopedFamilyState';
|
||||
@ -116,9 +116,7 @@ export const useViewBar = (props?: UseViewProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const queriedViewFields = viewFields
|
||||
.map((viewField) => viewField)
|
||||
.filter(assertNotNull);
|
||||
const queriedViewFields = viewFields.filter(isNonNullable);
|
||||
|
||||
if (isPersistingView) {
|
||||
return;
|
||||
@ -173,7 +171,7 @@ export const useViewBar = (props?: UseViewProps) => {
|
||||
definition: availableFilterDefinition,
|
||||
};
|
||||
})
|
||||
.filter(assertNotNull);
|
||||
.filter(isNonNullable);
|
||||
|
||||
if (!isDeeplyEqual(savedViewFilters, queriedViewFilters)) {
|
||||
set(savedViewFiltersState, queriedViewFilters);
|
||||
@ -220,7 +218,7 @@ export const useViewBar = (props?: UseViewProps) => {
|
||||
definition: availableSortDefinition,
|
||||
};
|
||||
})
|
||||
.filter(assertNotNull);
|
||||
.filter(isNonNullable);
|
||||
|
||||
if (!isDeeplyEqual(savedViewSorts, queriedViewSorts)) {
|
||||
set(savedViewSortsState, queriedViewSorts);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { BoardFieldDefinition } from '@/object-record/record-board-deprecated/types/BoardFieldDefinition';
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { ViewField } from '../types/ViewField';
|
||||
|
||||
@ -28,5 +28,5 @@ export const mapViewFieldsToBoardFieldDefinitions = (
|
||||
}
|
||||
: null;
|
||||
})
|
||||
.filter(assertNotNull);
|
||||
.filter(isNonNullable);
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@ import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'
|
||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||
import { mapArrayToObject } from '~/utils/array/mapArrayToObject';
|
||||
import { moveArrayItem } from '~/utils/array/moveArrayItem';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { ViewField } from '../types/ViewField';
|
||||
|
||||
@ -48,7 +48,7 @@ export const mapViewFieldsToColumnDefinitions = ({
|
||||
viewFieldId: viewField.id,
|
||||
};
|
||||
})
|
||||
.filter(assertNotNull);
|
||||
.filter(isNonNullable);
|
||||
|
||||
// No label identifier set for this object
|
||||
if (!labelIdentifierFieldMetadataId) return columnDefinitionsFromViewFields;
|
||||
|
||||
Reference in New Issue
Block a user