Add destroy for core view resolvers (#13745)
Add destroy for core view resolvers --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+2
@@ -87,4 +87,6 @@ export class ViewFieldController {
|
||||
|
||||
return { success: isDefined(deletedViewField) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
+2
@@ -89,4 +89,6 @@ export class ViewFilterGroupController {
|
||||
|
||||
return { success: isDefined(deletedViewFilterGroup) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
+2
@@ -87,4 +87,6 @@ export class ViewFilterController {
|
||||
|
||||
return { success: isDefined(deletedViewFilter) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
+2
@@ -87,4 +87,6 @@ export class ViewGroupController {
|
||||
|
||||
return { success: isDefined(deletedViewGroup) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
+2
@@ -84,4 +84,6 @@ export class ViewSortController {
|
||||
|
||||
return { success: isDefined(deletedViewSort) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
@@ -84,4 +84,6 @@ export class ViewController {
|
||||
|
||||
return { success: isDefined(deletedView) };
|
||||
}
|
||||
|
||||
// TODO: the destroy endpoint will be implemented when we settle on a strategy
|
||||
}
|
||||
|
||||
@@ -67,4 +67,17 @@ export class ViewFieldResolver {
|
||||
|
||||
return isDefined(deletedViewField);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreViewField(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedViewField = await this.viewFieldService.destroy(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return isDefined(deletedViewField);
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -73,4 +73,17 @@ export class ViewFilterGroupResolver {
|
||||
|
||||
return isDefined(deletedViewFilterGroup);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreViewFilterGroup(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedViewFilterGroup = await this.viewFilterGroupService.destroy(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return isDefined(deletedViewFilterGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,17 @@ export class ViewFilterResolver {
|
||||
|
||||
return isDefined(deletedViewFilter);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreViewFilter(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedViewFilter = await this.viewFilterService.destroy(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return isDefined(deletedViewFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,17 @@ export class ViewGroupResolver {
|
||||
|
||||
return isDefined(deletedViewGroup);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreViewGroup(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedViewGroup = await this.viewGroupService.destroy(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return isDefined(deletedViewGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,17 @@ export class ViewSortResolver {
|
||||
|
||||
return isDefined(deletedViewSort);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreViewSort(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedViewSort = await this.viewSortService.destroy(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return isDefined(deletedViewSort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,14 @@ export class ViewResolver {
|
||||
|
||||
return isDefined(deletedView);
|
||||
}
|
||||
|
||||
@Mutation(() => Boolean)
|
||||
async destroyCoreView(
|
||||
@Args('id', { type: () => String }) id: string,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<boolean> {
|
||||
const deletedView = await this.viewService.destroy(id, workspace.id);
|
||||
|
||||
return isDefined(deletedView);
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -294,4 +294,20 @@ describe('ViewFieldService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view field successfully', async () => {
|
||||
const id = 'view-field-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest.spyOn(viewFieldService, 'findById').mockResolvedValue(mockViewField);
|
||||
jest.spyOn(viewFieldRepository, 'delete').mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewFieldService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewFieldService.findById).toHaveBeenCalledWith(id, workspaceId);
|
||||
expect(viewFieldRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+24
@@ -41,6 +41,7 @@ describe('ViewFilterGroupService', () => {
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
softDelete: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -329,4 +330,27 @@ describe('ViewFilterGroupService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view filter group successfully', async () => {
|
||||
const id = 'view-filter-group-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest
|
||||
.spyOn(viewFilterGroupService, 'findById')
|
||||
.mockResolvedValue(mockViewFilterGroup);
|
||||
jest
|
||||
.spyOn(viewFilterGroupRepository, 'delete')
|
||||
.mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewFilterGroupService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewFilterGroupService.findById).toHaveBeenCalledWith(
|
||||
id,
|
||||
workspaceId,
|
||||
);
|
||||
expect(viewFilterGroupRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+19
@@ -43,6 +43,7 @@ describe('ViewFilterService', () => {
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
softDelete: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -310,4 +311,22 @@ describe('ViewFilterService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view filter successfully', async () => {
|
||||
const id = 'view-filter-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest
|
||||
.spyOn(viewFilterService, 'findById')
|
||||
.mockResolvedValue(mockViewFilter);
|
||||
jest.spyOn(viewFilterRepository, 'delete').mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewFilterService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewFilterService.findById).toHaveBeenCalledWith(id, workspaceId);
|
||||
expect(viewFilterRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+17
@@ -42,6 +42,7 @@ describe('ViewGroupService', () => {
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
softDelete: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -294,4 +295,20 @@ describe('ViewGroupService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view group successfully', async () => {
|
||||
const id = 'view-group-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest.spyOn(viewGroupService, 'findById').mockResolvedValue(mockViewGroup);
|
||||
jest.spyOn(viewGroupRepository, 'delete').mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewGroupService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewGroupService.findById).toHaveBeenCalledWith(id, workspaceId);
|
||||
expect(viewGroupRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+17
@@ -41,6 +41,7 @@ describe('ViewSortService', () => {
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
softDelete: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -281,4 +282,20 @@ describe('ViewSortService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view sort successfully', async () => {
|
||||
const id = 'view-sort-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest.spyOn(viewSortService, 'findById').mockResolvedValue(mockViewSort);
|
||||
jest.spyOn(viewSortRepository, 'delete').mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewSortService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewSortService.findById).toHaveBeenCalledWith(id, workspaceId);
|
||||
expect(viewSortRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+17
@@ -50,6 +50,7 @@ describe('ViewService', () => {
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
softDelete: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -295,4 +296,20 @@ describe('ViewService', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
it('should destroy a view successfully', async () => {
|
||||
const id = 'view-id';
|
||||
const workspaceId = 'workspace-id';
|
||||
|
||||
jest.spyOn(viewService, 'findById').mockResolvedValue(mockView);
|
||||
jest.spyOn(viewRepository, 'delete').mockResolvedValue({} as any);
|
||||
|
||||
const result = await viewService.destroy(id, workspaceId);
|
||||
|
||||
expect(viewService.findById).toHaveBeenCalledWith(id, workspaceId);
|
||||
expect(viewRepository.delete).toHaveBeenCalledWith(id);
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -149,4 +149,22 @@ export class ViewFieldService {
|
||||
|
||||
return viewField;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const viewField = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(viewField)) {
|
||||
throw new ViewFieldException(
|
||||
generateViewFieldExceptionMessage(
|
||||
ViewFieldExceptionMessageKey.VIEW_FIELD_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewFieldExceptionCode.VIEW_FIELD_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewFieldRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -161,4 +161,22 @@ export class ViewFilterGroupService {
|
||||
|
||||
return viewFilterGroup;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const viewFilterGroup = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(viewFilterGroup)) {
|
||||
throw new ViewFilterGroupException(
|
||||
generateViewFilterGroupExceptionMessage(
|
||||
ViewFilterGroupExceptionMessageKey.VIEW_FILTER_GROUP_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewFilterGroupExceptionCode.VIEW_FILTER_GROUP_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewFilterGroupRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,4 +149,22 @@ export class ViewFilterService {
|
||||
|
||||
return viewFilter;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const viewFilter = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(viewFilter)) {
|
||||
throw new ViewFilterException(
|
||||
generateViewFilterExceptionMessage(
|
||||
ViewFilterExceptionMessageKey.VIEW_FILTER_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewFilterExceptionCode.VIEW_FILTER_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewFilterRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,4 +149,22 @@ export class ViewGroupService {
|
||||
|
||||
return viewGroup;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const viewGroup = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(viewGroup)) {
|
||||
throw new ViewGroupException(
|
||||
generateViewGroupExceptionMessage(
|
||||
ViewGroupExceptionMessageKey.VIEW_GROUP_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewGroupExceptionCode.VIEW_GROUP_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewGroupRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,4 +144,22 @@ export class ViewSortService {
|
||||
|
||||
return viewSort;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const viewSort = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(viewSort)) {
|
||||
throw new ViewSortException(
|
||||
generateViewSortExceptionMessage(
|
||||
ViewSortExceptionMessageKey.VIEW_SORT_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewSortExceptionCode.VIEW_SORT_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewSortRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,4 +156,22 @@ export class ViewService {
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
async destroy(id: string, workspaceId: string): Promise<boolean> {
|
||||
const view = await this.findById(id, workspaceId);
|
||||
|
||||
if (!isDefined(view)) {
|
||||
throw new ViewException(
|
||||
generateViewExceptionMessage(
|
||||
ViewExceptionMessageKey.VIEW_NOT_FOUND,
|
||||
id,
|
||||
),
|
||||
ViewExceptionCode.VIEW_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.viewRepository.delete(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -4,6 +4,7 @@ import {
|
||||
} from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewFieldOperationFactory } from 'test/integration/graphql/utils/create-view-field-operation-factory.util';
|
||||
import { deleteViewFieldOperationFactory } from 'test/integration/graphql/utils/delete-view-field-operation-factory.util';
|
||||
import { destroyViewFieldOperationFactory } from 'test/integration/graphql/utils/destroy-view-field-operation-factory.util';
|
||||
import { findViewFieldsOperationFactory } from 'test/integration/graphql/utils/find-view-fields-operation-factory.util';
|
||||
import {
|
||||
assertGraphQLErrorResponse,
|
||||
@@ -210,4 +211,39 @@ describe('View Field Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreViewField', () => {
|
||||
it('should destroy an existing view field', async () => {
|
||||
const fieldData = createViewFieldData(testViewId);
|
||||
const createOperation = createViewFieldOperationFactory({
|
||||
data: fieldData,
|
||||
});
|
||||
const createResponse = await makeGraphqlAPIRequest(createOperation);
|
||||
const viewField = createResponse.body.data.createCoreViewField;
|
||||
|
||||
const destroyOperation = destroyViewFieldOperationFactory({
|
||||
viewFieldId: viewField.id,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(response);
|
||||
expect(response.body.data.destroyCoreViewField).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent view field', async () => {
|
||||
const operation = destroyViewFieldOperationFactory({
|
||||
viewFieldId: TEST_NOT_EXISTING_VIEW_FIELD_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewFieldExceptionMessage(
|
||||
ViewFieldExceptionMessageKey.VIEW_FIELD_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_FIELD_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+39
@@ -1,6 +1,7 @@
|
||||
import { TEST_NOT_EXISTING_VIEW_FILTER_GROUP_ID } from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewFilterGroupOperationFactory } from 'test/integration/graphql/utils/create-view-filter-group-operation-factory.util';
|
||||
import { deleteViewFilterGroupOperationFactory } from 'test/integration/graphql/utils/delete-view-filter-group-operation-factory.util';
|
||||
import { destroyViewFilterGroupOperationFactory } from 'test/integration/graphql/utils/destroy-view-filter-group-operation-factory.util';
|
||||
import { findViewFilterGroupOperationFactory } from 'test/integration/graphql/utils/find-view-filter-group-operation-factory.util';
|
||||
import { findViewFilterGroupsOperationFactory } from 'test/integration/graphql/utils/find-view-filter-groups-operation-factory.util';
|
||||
import {
|
||||
@@ -401,4 +402,42 @@ describe('View Filter Group Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreViewFilterGroup', () => {
|
||||
it('should destroy an existing filter group', async () => {
|
||||
const filterGroupData = createViewFilterGroupData(testViewId, {
|
||||
logicalOperator: ViewFilterGroupLogicalOperator.AND,
|
||||
});
|
||||
const createOperation = createViewFilterGroupOperationFactory({
|
||||
data: filterGroupData,
|
||||
});
|
||||
const createResponse = await makeGraphqlAPIRequest(createOperation);
|
||||
const filterGroupId =
|
||||
createResponse.body.data.createCoreViewFilterGroup.id;
|
||||
|
||||
const destroyOperation = destroyViewFilterGroupOperationFactory({
|
||||
viewFilterGroupId: filterGroupId,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(response);
|
||||
expect(response.body.data.destroyCoreViewFilterGroup).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent filter group', async () => {
|
||||
const operation = destroyViewFilterGroupOperationFactory({
|
||||
viewFilterGroupId: TEST_NOT_EXISTING_VIEW_FILTER_GROUP_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewFilterGroupExceptionMessage(
|
||||
ViewFilterGroupExceptionMessageKey.VIEW_FILTER_GROUP_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_FILTER_GROUP_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+41
@@ -4,6 +4,7 @@ import {
|
||||
} from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewFilterOperationFactory } from 'test/integration/graphql/utils/create-view-filter-operation-factory.util';
|
||||
import { deleteViewFilterOperationFactory } from 'test/integration/graphql/utils/delete-view-filter-operation-factory.util';
|
||||
import { destroyViewFilterOperationFactory } from 'test/integration/graphql/utils/destroy-view-filter-operation-factory.util';
|
||||
import { findViewFiltersOperationFactory } from 'test/integration/graphql/utils/find-view-filters-operation-factory.util';
|
||||
import {
|
||||
assertGraphQLErrorResponse,
|
||||
@@ -222,4 +223,44 @@ describe('View Filter Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreViewFilter', () => {
|
||||
it('should destroy an existing view filter', async () => {
|
||||
const createOperation = createViewFilterOperationFactory({
|
||||
data: createViewFilterData(testViewId, {
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
value: 'to destroy',
|
||||
}),
|
||||
});
|
||||
|
||||
const createResponse = await makeGraphqlAPIRequest(createOperation);
|
||||
|
||||
const viewFilterId = createResponse.body.data.createCoreViewFilter.id;
|
||||
|
||||
const destroyOperation = destroyViewFilterOperationFactory({
|
||||
viewFilterId: viewFilterId,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(response);
|
||||
expect(response.body.data.destroyCoreViewFilter).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent view filter', async () => {
|
||||
const operation = destroyViewFilterOperationFactory({
|
||||
viewFilterId: TEST_NOT_EXISTING_VIEW_FILTER_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewFilterExceptionMessage(
|
||||
ViewFilterExceptionMessageKey.VIEW_FILTER_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_FILTER_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+40
@@ -4,6 +4,7 @@ import {
|
||||
} from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewGroupOperationFactory } from 'test/integration/graphql/utils/create-view-group-operation-factory.util';
|
||||
import { deleteViewGroupOperationFactory } from 'test/integration/graphql/utils/delete-view-group-operation-factory.util';
|
||||
import { destroyViewGroupOperationFactory } from 'test/integration/graphql/utils/destroy-view-group-operation-factory.util';
|
||||
import { findViewGroupsOperationFactory } from 'test/integration/graphql/utils/find-view-groups-operation-factory.util';
|
||||
import {
|
||||
assertGraphQLErrorResponse,
|
||||
@@ -215,4 +216,43 @@ describe('View Group Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreViewGroup', () => {
|
||||
it('should destroy an existing view group', async () => {
|
||||
const groupData = createViewGroupData(testViewId, {
|
||||
isVisible: true,
|
||||
fieldValue: 'to destroy',
|
||||
position: 0,
|
||||
});
|
||||
const createOperation = createViewGroupOperationFactory({
|
||||
data: groupData,
|
||||
});
|
||||
const createResponse = await makeGraphqlAPIRequest(createOperation);
|
||||
const viewGroup = createResponse.body.data.createCoreViewGroup;
|
||||
|
||||
const destroyOperation = destroyViewGroupOperationFactory({
|
||||
viewGroupId: viewGroup.id,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(response);
|
||||
expect(response.body.data.destroyCoreViewGroup).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent view group', async () => {
|
||||
const operation = destroyViewGroupOperationFactory({
|
||||
viewGroupId: TEST_NOT_EXISTING_VIEW_GROUP_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewGroupExceptionMessage(
|
||||
ViewGroupExceptionMessageKey.VIEW_GROUP_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_GROUP_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+31
@@ -5,6 +5,7 @@ import {
|
||||
} from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewOperationFactory } from 'test/integration/graphql/utils/create-view-operation-factory.util';
|
||||
import { deleteViewOperationFactory } from 'test/integration/graphql/utils/delete-view-operation-factory.util';
|
||||
import { destroyViewOperationFactory } from 'test/integration/graphql/utils/destroy-view-operation-factory.util';
|
||||
import { findViewOperationFactory } from 'test/integration/graphql/utils/find-view-operation-factory.util';
|
||||
import { findViewsOperationFactory } from 'test/integration/graphql/utils/find-views-operation-factory.util';
|
||||
import {
|
||||
@@ -258,4 +259,34 @@ describe('View Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreView', () => {
|
||||
it('should destroy an existing view', async () => {
|
||||
const view = await createTestViewWithGraphQL({
|
||||
name: 'View to Destroy',
|
||||
});
|
||||
|
||||
const destroyOperation = destroyViewOperationFactory({ viewId: view.id });
|
||||
const destroyResponse = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(destroyResponse);
|
||||
expect(destroyResponse.body.data.destroyCoreView).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent view', async () => {
|
||||
const operation = destroyViewOperationFactory({
|
||||
viewId: TEST_NOT_EXISTING_VIEW_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewExceptionMessage(
|
||||
ViewExceptionMessageKey.VIEW_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+36
@@ -4,6 +4,7 @@ import {
|
||||
} from 'test/integration/constants/test-view-ids.constants';
|
||||
import { createViewSortOperationFactory } from 'test/integration/graphql/utils/create-view-sort-operation-factory.util';
|
||||
import { deleteViewSortOperationFactory } from 'test/integration/graphql/utils/delete-view-sort-operation-factory.util';
|
||||
import { destroyViewSortOperationFactory } from 'test/integration/graphql/utils/destroy-view-sort-operation-factory.util';
|
||||
import { findViewSortsOperationFactory } from 'test/integration/graphql/utils/find-view-sorts-operation-factory.util';
|
||||
import {
|
||||
assertGraphQLErrorResponse,
|
||||
@@ -191,4 +192,39 @@ describe('View Sort Resolver', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroyCoreViewSort', () => {
|
||||
it('should destroy an existing view sort', async () => {
|
||||
const sortData = createViewSortData(testViewId);
|
||||
const createOperation = createViewSortOperationFactory({
|
||||
data: sortData,
|
||||
});
|
||||
const createResponse = await makeGraphqlAPIRequest(createOperation);
|
||||
const viewSort = createResponse.body.data.createCoreViewSort;
|
||||
|
||||
const destroyOperation = destroyViewSortOperationFactory({
|
||||
viewSortId: viewSort.id,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
assertGraphQLSuccessfulResponse(response);
|
||||
expect(response.body.data.destroyCoreViewSort).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw an error when destroying non-existent view sort', async () => {
|
||||
const operation = destroyViewSortOperationFactory({
|
||||
viewSortId: TEST_NOT_EXISTING_VIEW_SORT_ID,
|
||||
});
|
||||
const response = await makeGraphqlAPIRequest(operation);
|
||||
|
||||
assertGraphQLErrorResponse(
|
||||
response,
|
||||
ErrorCode.NOT_FOUND,
|
||||
generateViewSortExceptionMessage(
|
||||
ViewSortExceptionMessageKey.VIEW_SORT_NOT_FOUND,
|
||||
TEST_NOT_EXISTING_VIEW_SORT_ID,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewFieldOperationFactory = ({
|
||||
viewFieldId,
|
||||
}: {
|
||||
viewFieldId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreViewField($id: String!) {
|
||||
destroyCoreViewField(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewFieldId,
|
||||
},
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewFilterGroupOperationFactory = ({
|
||||
viewFilterGroupId,
|
||||
}: {
|
||||
viewFilterGroupId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreViewFilterGroup($id: String!) {
|
||||
destroyCoreViewFilterGroup(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewFilterGroupId,
|
||||
},
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewFilterOperationFactory = ({
|
||||
viewFilterId,
|
||||
}: {
|
||||
viewFilterId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreViewFilter($id: String!) {
|
||||
destroyCoreViewFilter(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewFilterId,
|
||||
},
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewGroupOperationFactory = ({
|
||||
viewGroupId,
|
||||
}: {
|
||||
viewGroupId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreViewGroup($id: String!) {
|
||||
destroyCoreViewGroup(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewGroupId,
|
||||
},
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewOperationFactory = ({
|
||||
viewId,
|
||||
}: {
|
||||
viewId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreView($id: String!) {
|
||||
destroyCoreView(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewId,
|
||||
},
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const destroyViewSortOperationFactory = ({
|
||||
viewSortId,
|
||||
}: {
|
||||
viewSortId: string;
|
||||
}) => ({
|
||||
query: gql`
|
||||
mutation DestroyCoreViewSort($id: String!) {
|
||||
destroyCoreViewSort(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: viewSortId,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user