Pre hook for dashboard creation + updates on the entity (#14354)
Closes https://github.com/twentyhq/core-team-issues/issues/1417 - The pre-hook creates a page-layout and links it to the dashboard - Added `position`, `createdBy`, `attachments`, `searchVector`, `favorites` to the dashboard entity - Updated the view seed - Updated the page layout services to work within a transaction
This commit is contained in:
+67
@@ -1,3 +1,4 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { TEST_NOT_EXISTING_PAGE_LAYOUT_ID } from 'test/integration/constants/test-page-layout-ids.constants';
|
||||
import { createPageLayoutOperationFactory } from 'test/integration/graphql/utils/create-page-layout-operation-factory.util';
|
||||
import { deletePageLayoutOperationFactory } from 'test/integration/graphql/utils/delete-page-layout-operation-factory.util';
|
||||
@@ -367,6 +368,72 @@ describe('Page Layout Resolver', () => {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it('should destroy all associated dashboards when page layout is of type dashboard', async () => {
|
||||
const dashboardId = '20202020-304c-44f2-ba7b-070762ff0e8a';
|
||||
|
||||
const pageLayout = await createTestPageLayoutWithGraphQL({
|
||||
name: 'Page Layout to Destroy',
|
||||
type: PageLayoutType.DASHBOARD,
|
||||
});
|
||||
|
||||
const findOneDashboardOperation = {
|
||||
query: gql`
|
||||
query Dashboard($filter: DashboardFilterInput!) {
|
||||
dashboard(filter: $filter) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
filter: { id: { eq: dashboardId } },
|
||||
},
|
||||
};
|
||||
|
||||
await makeGraphqlAPIRequest({
|
||||
query: gql`
|
||||
mutation CreateDashboard($input: CreateDashboardInput!) {
|
||||
createDashboard(input: $input) {
|
||||
pageLayoutId
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input: {
|
||||
id: dashboardId,
|
||||
name: 'Dashboard to Destroy',
|
||||
pageLayoutId: pageLayout.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findOneDashboardResponseBeforeDestroy = await makeGraphqlAPIRequest(
|
||||
findOneDashboardOperation,
|
||||
);
|
||||
|
||||
expect(
|
||||
findOneDashboardResponseBeforeDestroy.body.data.dashboard,
|
||||
).toBeDefined();
|
||||
|
||||
const destroyOperation = destroyPageLayoutOperationFactory({
|
||||
pageLayoutId: pageLayout.id,
|
||||
});
|
||||
const destroyResponse = await makeGraphqlAPIRequest(destroyOperation);
|
||||
|
||||
const findOneDashboardResponseAfterDestroy = await makeGraphqlAPIRequest(
|
||||
findOneDashboardOperation,
|
||||
);
|
||||
|
||||
assertGraphQLSuccessfulResponse(destroyResponse);
|
||||
expect(destroyResponse.body.data.destroyPageLayout).toBe(true);
|
||||
|
||||
expect(findOneDashboardResponseAfterDestroy.body.errors).toBeDefined();
|
||||
expect(
|
||||
findOneDashboardResponseAfterDestroy.body.errors[0].extensions.code,
|
||||
).toBe(ErrorCode.NOT_FOUND);
|
||||
});
|
||||
});
|
||||
|
||||
describe('restorePageLayout', () => {
|
||||
|
||||
Reference in New Issue
Block a user